1010import random
1111import re
1212import socket
13+ import subprocess
1314import time
1415
15- from subprocess import Popen as execute
16-
1716from extra .beep .beep import beep
1817from lib .core .agent import agent
1918from lib .core .common import Backend
@@ -200,7 +199,7 @@ def checkSqlInjection(place, parameter, value):
200199 if conf .tech and isinstance (conf .tech , list ) and stype not in conf .tech :
201200 debugMsg = "skipping test '%s' because the user " % title
202201 debugMsg += "specified to test only for "
203- debugMsg += "%s techniques" % " & " .join (map ( lambda x : PAYLOAD .SQLINJECTION [x ], conf .tech ) )
202+ debugMsg += "%s techniques" % " & " .join (PAYLOAD .SQLINJECTION [_ ] for _ in conf .tech )
204203 logger .debug (debugMsg )
205204 continue
206205
@@ -651,20 +650,20 @@ def genCmpPayload():
651650
652651 # Feed with test details every time a test is successful
653652 if hasattr (test , "details" ):
654- for dKey , dValue in test .details .items ():
655- if dKey == "dbms" :
656- injection .dbms = dValue
653+ for key , value in test .details .items ():
654+ if key == "dbms" :
655+ injection .dbms = value
657656
658- if not isinstance (dValue , list ):
659- Backend .setDbms (dValue )
657+ if not isinstance (value , list ):
658+ Backend .setDbms (value )
660659 else :
661- Backend .forceDbms (dValue [0 ], True )
660+ Backend .forceDbms (value [0 ], True )
662661
663- elif dKey == "dbms_version" and injection .dbms_version is None and not conf .testFilter :
664- injection .dbms_version = Backend .setVersion (dValue )
662+ elif key == "dbms_version" and injection .dbms_version is None and not conf .testFilter :
663+ injection .dbms_version = Backend .setVersion (value )
665664
666- elif dKey == "os" and injection .os is None :
667- injection .os = Backend .setOs (dValue )
665+ elif key == "os" and injection .os is None :
666+ injection .os = Backend .setOs (value )
668667
669668 if vector is None and "vector" in test and test .vector is not None :
670669 vector = test .vector
@@ -696,7 +695,7 @@ def genCmpPayload():
696695 infoMsg = "executing alerting shell command(s) ('%s')" % conf .alert
697696 logger .info (infoMsg )
698697
699- process = execute (conf .alert , shell = True )
698+ process = subprocess . Popen (conf .alert , shell = True )
700699 process .wait ()
701700
702701 kb .alerted = True
@@ -921,8 +920,10 @@ def heuristicCheckSqlInjection(place, parameter):
921920
922921 origValue = conf .paramDict [place ][parameter ]
923922 paramType = conf .method if conf .method not in (None , HTTPMETHOD .GET , HTTPMETHOD .POST ) else place
923+
924924 prefix = ""
925925 suffix = ""
926+ randStr = ""
926927
927928 if conf .prefix or conf .suffix :
928929 if conf .prefix :
@@ -931,8 +932,6 @@ def heuristicCheckSqlInjection(place, parameter):
931932 if conf .suffix :
932933 suffix = conf .suffix
933934
934- randStr = ""
935-
936935 while randStr .count ('\' ' ) != 1 or randStr .count ('\" ' ) != 1 :
937936 randStr = randomStr (length = 10 , alphabet = HEURISTIC_CHECK_ALPHABET )
938937
0 commit comments