()
Loads tampering functions from given script(s)
Loads tampering functions from given script(s)
Loads tampering functions from given script ( s )
def _setTamperingFunctions():
    """
    Loads tampering functions from given script(s)
    """

    if conf.tamper:
        last_priority = PRIORITY.HIGHEST
        check_priority = True
        resolve_priorities = False
        priorities = []

        for tfile in re.split(PARAMETER_SPLITTING_REGEX, conf.tamper):
            found = False

            tfile = tfile.strip()

            if not tfile:
                continue

            elif os.path.exists(os.path.join(paths.SQLMAP_TAMPER_PATH, tfile if tfile.endswith('.py') else "%s.py" % tfile)):
                tfile = os.path.join(paths.SQLMAP_TAMPER_PATH, tfile if tfile.endswith('.py') else "%s.py" % tfile)

            elif not os.path.exists(tfile):
                errMsg = "tamper script '%s' does not exist" % tfile
                raise SqlmapFilePathException(errMsg)

            elif not tfile.endswith('.py'):
                errMsg = "tamper script '%s' should have an extension '.py'" % tfile
                raise SqlmapSyntaxException(errMsg)

            dirname, filename = os.path.split(tfile)
            dirname = os.path.abspath(dirname)

            infoMsg = "loading tamper script '%s'" % filename[:-3]
            logger.info(infoMsg)

            if not os.path.exists(os.path.join(dirname, '__init__.py')):
                errMsg = "make sure that there is an empty file '__init__.py' "
                errMsg += "inside of tamper scripts directory '%s'" % dirname
                raise SqlmapGenericException(errMsg)

            if dirname not in sys.path:
                sys.path.insert(0, dirname)

            try:
                module = __import__(filename[:-3])
            except (ImportError, SyntaxError), msg:
                raise SqlmapSyntaxException("cannot import tamper script '%s' (%s)" % (filename[:-3], msg))

            priority = PRIORITY.NORMAL if not hasattr(module, '__priority__') else module.__priority__

            for name, function in inspect.getmembers(module, inspect.isfunction):
                if name == "tamper" and inspect.getargspec(function).args and inspect.getargspec(function).keywords == "kwargs":
                    found = True
                    kb.tamperFunctions.append(function)
                    function.func_name = module.__name__

                    if check_priority and priority > last_priority:
                        message = "it seems that you might have mixed "
                        message += "the order of tamper scripts. "
                        message += "Do you want to auto resolve this? [Y/n/q] "
                        test = readInput(message, default="Y")

                        if not test or test[0] in ("y", "Y"):
                            resolve_priorities = True
                        elif test[0] in ("n", "N"):
                            resolve_priorities = False
                        elif test[0] in ("q", "Q"):
                            raise SqlmapUserQuitException

                        check_priority = False

                    priorities.append((priority, function))
                    last_priority = priority

                    break
                elif name == "dependencies":
                    function()

            if not found:
                errMsg = "missing function 'tamper(payload, **kwargs)' "
                errMsg += "in tamper script '%s'" % tfile
                raise SqlmapGenericException(errMsg)

        if kb.tamperFunctions and len(kb.tamperFunctions) > 3:
            warnMsg = "using too many tamper scripts is usually not "
            warnMsg += "a good idea"
            logger.warning(warnMsg)

        if resolve_priorities and priorities:
            priorities.sort(reverse=True)
            kb.tamperFunctions = []

            for _, function in priorities:
                kb.tamperFunctions.append(function)
def _setTamperingFunctions ( ) : if conf . tamper : last_priority = PRIORITY . HIGHEST check_priority = True resolve_priorities = False priorities = [ ] for tfile in re . split ( PARAMETER_SPLITTING_REGEX , conf . tamper ) : found = False tfile = tfile . strip ( ) if not tfile : continue elif os . path . exists ( os . path . join ( paths . SQLMAP_TAMPER_PATH , tfile if tfile . endswith ( '.py' ) else "%s.py" % tfile ) ) : tfile = os . path . join ( paths . SQLMAP_TAMPER_PATH , tfile if tfile . endswith ( '.py' ) else "%s.py" % tfile ) elif not os . path . exists ( tfile ) : errMsg = "tamper script '%s' does not exist" % tfile raise SqlmapFilePathException ( errMsg ) elif not tfile . endswith ( '.py' ) : errMsg = "tamper script '%s' should have an extension '.py'" % tfile raise SqlmapSyntaxException ( errMsg ) dirname , filename = os . path . split ( tfile ) dirname = os . path . abspath ( dirname ) infoMsg = "loading tamper script '%s'" % filename [ : - 3 ] logger . info ( infoMsg ) if not os . path . exists ( os . path . join ( dirname , '__init__.py' ) ) : errMsg = "make sure that there is an empty file '__init__.py' " errMsg += "inside of tamper scripts directory '%s'" % dirname raise SqlmapGenericException ( errMsg ) if dirname not in sys . path : sys . path . insert ( 0 , dirname ) try : module = __import__ ( filename [ : - 3 ] ) except ( ImportError , SyntaxError ) , msg : raise SqlmapSyntaxException ( "cannot import tamper script '%s' (%s)" % ( filename [ : - 3 ] , msg ) ) priority = PRIORITY . NORMAL if not hasattr ( module , '__priority__' ) else module . __priority__ for name , function in inspect . getmembers ( module , inspect . isfunction ) : if name == "tamper" and inspect . getargspec ( function ) . args and inspect . getargspec ( function ) . keywords == "kwargs" : found = True kb . tamperFunctions . append ( function ) function . func_name = module . __name__ if check_priority and priority > last_priority : message = "it seems that you might have mixed " message += "the order of tamper scripts. " message += "Do you want to auto resolve this? [Y/n/q] " test = readInput ( message , default = "Y" ) if not test or test [ 0 ] in ( "y" , "Y" ) : resolve_priorities = True elif test [ 0 ] in ( "n" , "N" ) : resolve_priorities = False elif test [ 0 ] in ( "q" , "Q" ) : raise SqlmapUserQuitException check_priority = False priorities . append ( ( priority , function ) ) last_priority = priority break elif name == "dependencies" : function ( ) if not found : errMsg = "missing function 'tamper(payload, **kwargs)' " errMsg += "in tamper script '%s'" % tfile raise SqlmapGenericException ( errMsg ) if kb . tamperFunctions and len ( kb . tamperFunctions ) > 3 : warnMsg = "using too many tamper scripts is usually not " warnMsg += "a good idea" logger . warning ( warnMsg ) if resolve_priorities and priorities : priorities . sort ( reverse = True ) kb . tamperFunctions = [ ] for _ , function in priorities : kb . tamperFunctions . append ( function )