1111import cookielib
1212import ctypes
1313import difflib
14+ import inspect
1415import logging
1516import os
1617import re
@@ -531,34 +532,33 @@ def __setDBMS():
531532
532533def __setTamperingFunctions ():
533534 """
534- Loads tampering functions from given module path (s).
535+ Loads tampering functions from given script (s)
535536 """
536- if conf .tamper :
537- kb .tamperFunctions = []
538537
539- import inspect
538+ if conf .tamper :
539+ for tfile in conf .tamper .split (';' ):
540+ found = False
540541
541- for file in conf .tamper .split (';' ):
542- if not file :
542+ if not tfile :
543543 continue
544544
545- elif not os .path .exists (file ):
546- errMsg = "missing tampering module file '%s'" % file
545+ elif not os .path .exists (tfile ):
546+ errMsg = "tamper script '%s' does not exist " % tfile
547547 raise sqlmapFilePathException , errMsg
548548
549- elif os . path . splitext ( file )[ 1 ] != '.py' :
550- errMsg = "tampering module file should have an extension '.py'"
549+ elif not tfile . endswith ( '.py' ) :
550+ errMsg = "tamper script '%s' should have an extension '.py'" % tfile
551551 raise sqlmapSyntaxException , errMsg
552552
553- dirname , filename = os .path .split (file )
553+ dirname , filename = os .path .split (tfile )
554554 dirname = os .path .abspath (dirname )
555555
556- infoMsg = "loading tampering module: '%s'" % filename [:- 3 ]
556+ infoMsg = "loading tamper script '%s'" % filename [:- 3 ]
557557 logger .info (infoMsg )
558558
559559 if not os .path .exists (os .path .join (dirname , '__init__.py' )):
560560 errMsg = "make sure that there is an empty file '__init__.py' "
561- errMsg += "inside of tampering module directory '%s'" % dirname
561+ errMsg += "inside of tamper scripts directory '%s'" % dirname
562562 raise sqlmapGenericException , errMsg
563563
564564 if dirname not in sys .path :
@@ -567,17 +567,17 @@ def __setTamperingFunctions():
567567 try :
568568 module = __import__ (filename [:- 3 ])
569569 except ImportError , msg :
570- raise sqlmapSyntaxException , "can't import module file '%s' (%s)" % (file , msg )
570+ raise sqlmapSyntaxException , "can not import tamper script '%s' (%s)" % (filename [: - 3 ] , msg )
571571
572- found = False
573572 for name , function in inspect .getmembers (module , inspect .isfunction ):
574- if name == "tamper" and function .func_code .co_argcount == 2 :
573+ if name == "tamper" and function .func_code .co_argcount == 2 :
575574 kb .tamperFunctions .append (function )
576575 found = True
576+
577577 break
578578
579579 if not found :
580- raise sqlmapGenericException , "missing function 'tamper(place, value)' in tampering module '%s'" % filename
580+ raise sqlmapGenericException , "missing function 'tamper(place, value)' in tamper script '%s'" % tfile
581581
582582def __setThreads ():
583583 if not isinstance (conf .threads , int ) or conf .threads <= 0 :
@@ -943,6 +943,9 @@ def __cleanupOptions():
943943 else :
944944 conf .testParameter = []
945945
946+ if conf .tamper :
947+ conf .tamper = conf .tamper .replace (" " , "" )
948+
946949 if conf .db :
947950 conf .db = conf .db .replace (" " , "" )
948951
@@ -1071,7 +1074,7 @@ def __setKnowledgeBaseAttributes():
10711074 kb .queryCounter = 0
10721075 kb .resumedQueries = {}
10731076 kb .stackedTest = None
1074- kb .tamperFunctions = None
1077+ kb .tamperFunctions = []
10751078 kb .targetUrls = set ()
10761079 kb .testedParams = set ()
10771080 kb .timeTest = None
0 commit comments