128128from lib .core .settings import PRECONNECT_CANDIDATE_TIMEOUT
129129from lib .core .settings import PROXY_ENVIRONMENT_VARIABLES
130130from lib .core .settings import SOCKET_PRE_CONNECT_QUEUE_SIZE
131- from lib .core .settings import NONSQL_TECHNIQUES
132131from lib .core .settings import SQLMAP_ENVIRONMENT_PREFIX
133132from lib .core .settings import SUPPORTED_DBMS
134133from lib .core .settings import SUPPORTED_OS
@@ -423,10 +422,7 @@ def retrieve():
423422 conf .googlePage += 1
424423
425424def _setStdinPipeTargets ():
426- # Note: an explicit target source takes precedence. Without this, any non-interactive run (CI,
427- # cron, subprocess) would reroute '-m/-l/-r/-g' targets through the STDIN container, losing both
428- # their count and their order
429- if any ((conf .url , conf .direct , conf .logFile , conf .bulkFile , conf .requestFile , conf .googleDork , conf .openApiFile )):
425+ if conf .url :
430426 return
431427
432428 if isinstance (conf .stdinPipe , _collections .Iterable ):
@@ -830,6 +826,8 @@ def _setDBMS():
830826
831827 break
832828
829+ Backend .setDbms (conf .dbms )
830+
833831def _listTamperingFunctions ():
834832 """
835833 Lists available tamper functions
@@ -905,13 +903,6 @@ def _setTamperingFunctions():
905903 priority = PRIORITY .NORMAL if not hasattr (module , "__priority__" ) else module .__priority__
906904 priority = priority if priority is not None else PRIORITY .LOWEST
907905
908- if not isinstance (priority , int ):
909- warnMsg = "tamper module '%s' has an invalid value for '__priority__' " % filename [:- 3 ]
910- warnMsg += "(assuming '%d')" % PRIORITY .NORMAL
911- logger .warning (warnMsg )
912-
913- priority = PRIORITY .NORMAL
914-
915906 for name , function in inspect .getmembers (module , inspect .isfunction ):
916907 if name == "tamper" and (hasattr (inspect , "signature" ) and all (_ in inspect .signature (function ).parameters for _ in ("payload" , "kwargs" )) or inspect .getargspec (function ).args and inspect .getargspec (function ).keywords == "kwargs" ):
917908 found = True
@@ -955,14 +946,11 @@ def _setTamperingFunctions():
955946 warnMsg += "a good idea"
956947 logger .warning (warnMsg )
957948
958- # tamper scripts rewrite SQL injection payloads; the self-contained non-SQL engines do not run
959- # payloads through the tampering hook, so warn instead of silently ignoring the user's
960- # '--tamper'. One tuple drives both the test and the name lookup - keeping two lists in step is
961- # exactly how this raised StopIteration, and leaving an engine OUT (as '--hql' was) is how the
962- # warning silently stops covering one.
963- _nonSqlEngines = ("graphql" , "nosql" , "ldap" , "xpath" , "ssti" , "xslt" , "xxe" , "hql" , "sparql" , "odata" )
964- if kb .tamperFunctions and any (conf .get (_ ) for _ in _nonSqlEngines ):
965- engine = next (_ for _ in _nonSqlEngines if conf .get (_ ))
949+ # tamper scripts rewrite SQL injection payloads; the self-contained non-SQL engines
950+ # (--graphql/--nosql/--ldap/--xpath/--ssti/--xxe) do not run payloads through the tampering hook, so
951+ # warn instead of silently ignoring the user's '--tamper'
952+ if kb .tamperFunctions and any ((conf .graphql , conf .nosql , conf .ldap , conf .xpath , conf .ssti , conf .xxe )):
953+ engine = next (_ for _ in ("graphql" , "nosql" , "ldap" , "xpath" , "ssti" , "xxe" ) if conf .get (_ ))
966954 warnMsg = "tamper scripts are applied to SQL injection payloads only and "
967955 warnMsg += "will be ignored by the '--%s' engine" % engine
968956 logger .warning (warnMsg )
@@ -2205,17 +2193,9 @@ def _setKnowledgeBaseAttributes(flushAll=True):
22052193
22062194 kb .chars = AttribDict ()
22072195 kb .chars .delimiter = randomStr (length = 6 , lowercase = True )
2208- # NOTE: markers have to be mutually distinct (e.g. equal start/stop makes the delimited output ambiguous, while equal replacement markers make _errorReplaceChars() restore the wrong character). Also, none of the inner letters may be the boundary character itself, as that makes a marker contain a shorter one (e.g. 'qzqxq' carrying 'qzq')
2209- _ = set ()
2210- while len (_ ) < 2 :
2211- _ .add (randomStr (length = 3 , alphabet = KB_CHARS_LOW_FREQUENCY_ALPHABET ))
2212- kb .chars .start , kb .chars .stop = ("%s%s%s" % (KB_CHARS_BOUNDARY_CHAR , __ , KB_CHARS_BOUNDARY_CHAR ) for __ in _ )
2213-
2214- _ = set ()
2215- while len (_ ) < 4 :
2216- _ .add (randomStr (length = 1 , lowercase = True ))
2217- _ .discard (KB_CHARS_BOUNDARY_CHAR )
2218- kb .chars .at , kb .chars .space , kb .chars .dollar , kb .chars .hash_ = ("%s%s%s" % (KB_CHARS_BOUNDARY_CHAR , __ , KB_CHARS_BOUNDARY_CHAR ) for __ in _ )
2196+ kb .chars .start = "%s%s%s" % (KB_CHARS_BOUNDARY_CHAR , randomStr (length = 3 , alphabet = KB_CHARS_LOW_FREQUENCY_ALPHABET ), KB_CHARS_BOUNDARY_CHAR )
2197+ kb .chars .stop = "%s%s%s" % (KB_CHARS_BOUNDARY_CHAR , randomStr (length = 3 , alphabet = KB_CHARS_LOW_FREQUENCY_ALPHABET ), KB_CHARS_BOUNDARY_CHAR )
2198+ kb .chars .at , kb .chars .space , kb .chars .dollar , kb .chars .hash_ = ("%s%s%s" % (KB_CHARS_BOUNDARY_CHAR , _ , KB_CHARS_BOUNDARY_CHAR ) for _ in randomStr (length = 4 , lowercase = True ))
22192199
22202200 kb .checkWafMode = False
22212201 kb .choices = AttribDict (keycheck = False )
@@ -2262,7 +2242,6 @@ def _setKnowledgeBaseAttributes(flushAll=True):
22622242 kb .forkNote = None
22632243 kb .futileUnion = None
22642244 kb .fuzzUnionTest = None
2265- kb .gadget = None
22662245 kb .heavilyDynamic = False
22672246 kb .headersFile = None
22682247 kb .headersFp = {}
@@ -2299,7 +2278,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
22992278 kb .lastParserStatus = None
23002279
23012280 kb .locks = AttribDict ()
2302- for _ in ("cache" , "connError" , "count" , "handlers" , "hint" , "identYwaf" , "index" , "io" , "limit" , "liveCookies" , "log" , "multibit" , " prediction" , "socket" , "redirect" , "request" , "value" ):
2281+ for _ in ("cache" , "connError" , "count" , "handlers" , "hint" , "identYwaf" , "index" , "io" , "limit" , "liveCookies" , "log" , "prediction" , "socket" , "redirect" , "request" , "value" ):
23032282 kb .locks [_ ] = threading .Lock ()
23042283
23052284 kb .matchRatio = None
@@ -2308,8 +2287,6 @@ def _setKnowledgeBaseAttributes(flushAll=True):
23082287 kb .mergeCookies = None
23092288 kb .mysqlUtf8mb4 = None
23102289 kb .multiThreadMode = False
2311- kb .multibit = {} # per injection point: absent=untried, False=unusable, else the row channel profile
2312- kb .multibitHinted = False
23132290 kb .multipleCtrlC = False
23142291 kb .negativeLogic = False
23152292 kb .nchar = True
@@ -2778,7 +2755,9 @@ def _checkTor():
27782755 logger .info (infoMsg )
27792756
27802757def _basicOptionValidation ():
2781- _nonSqlTechniques = ["--%s" % _ for _ in NONSQL_TECHNIQUES if conf .get (_ )]
2758+ _nonSqlTechniques = [name for name , enabled in (
2759+ ("--graphql" , conf .graphql ), ("--nosql" , conf .nosql ), ("--ldap" , conf .ldap ),
2760+ ("--xpath" , conf .xpath ), ("--ssti" , conf .ssti ), ("--xxe" , conf .xxe ), ("--hql" , conf .hql )) if enabled ]
27822761 if len (_nonSqlTechniques ) > 1 :
27832762 errMsg = "only one non-SQL technique switch may be used at a time (found: %s). " % ", " .join (_nonSqlTechniques )
27842763 errMsg += "each is a self-contained scan for a different back-end class - pick one"
0 commit comments