Trouble finding the error!

Asked

Viewed 59 times

0

Guys I made a code and then I performed a scanner and gave that the code leaves the site with a gap, I’m not able to find where the error is and whether it is serious or not. That is the code:

var $K2 = jQuery.noConflict();

$K2(document).ready(function(){

  // Generic function to get URL params passed in .js script include
    function getUrlParams(targetScript, varName) {
        var scripts = document.getElementsByTagName('script');
        var scriptCount = scripts.length;
        for (var a = 0; a < scriptCount; a++) {
            var scriptSrc = scripts[a].src;
            if (scriptSrc.indexOf(targetScript) >= 0) {
                varName = varName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var re = new RegExp("[\\?&]" + varName + "=([^&#]*)");
                var parsedVariables = re.exec(scriptSrc);
                if (parsedVariables !== null) {
                    return parsedVariables[1];
                }
            }
        }
    }
  • Which breach ?

  • The Scanner alerted me about a possible loophole that allows someone to hack the site through this code, and also says that Jquery is not set. I wanted to know if the code is correct or not? If you need some adjustments or the scanner gave me the wrong information, unfortunately I don’t know what the loophole is either, only the question is if the code is correct.

  • In relation to the jQuery not being set, it is because it lacks to import it: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

  • thank you even vlw

  • 1

    @wmsouza Tagged the answer that has nothing to do with the question.

  • 1

    Which scanner did you use? What is the entire error message? Copy and paste everything here, we need details.

  • Guilherme used the Shadow Security Scanner. First it informs me the script with error with a link, it says q the error is on line 9 whose and the first line of the code I posted, also comes with character 1. ERROR:'jQuery' is not defined Code: 800A1391 Origin: Error at Microsoft Jscript execution time. That’s the information he gives me

Show 2 more comments

1 answer

-2


In the code you posted said a key lock } at the end of the code to end the first function:

var $K2 = jQuery.noConflict();

$K2(document).ready(function(){

  // Generic function to get URL params passed in .js script include
    function getUrlParams(targetScript, varName) {
        var scripts = document.getElementsByTagName('script');
        var scriptCount = scripts.length;
        for (var a = 0; a < scriptCount; a++) {
            var scriptSrc = scripts[a].src;
            if (scriptSrc.indexOf(targetScript) >= 0) {
                varName = varName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var re = new RegExp("[\\?&]" + varName + "=([^&#]*)");
                var parsedVariables = re.exec(scriptSrc);
                if (parsedVariables !== null) {
                    return parsedVariables[1];
                }
            }
        }
    }
}); // Faltou
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

  • Friend, when so ask via comment, maybe it is only the question that is missing and the real code not.

  • vlw by the answer tbm

  • @dvd where is wrong, have to be clearer friend? But then who scored as correct? You have privilege to reverse the situation? Thanks. And the key was missing, yes.It must have been an error by the requester.

  • foul ); in the after the }, of course the question also lacks, but by using stacksnippet to test it would be better to add

  • 1

    Thank you @Guilhermenascimento, I hadn’t noticed. @dvd I had already tested on 2 browsers (Firefox and Opera) and gave no error, I put several Tags with scripts pulled from other sites and no error happened, I believe the breach is in some script listada HTML by function. Otherwise the code works.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.