10
10
import random
11
11
import re
12
12
import socket
13
+ import subprocess
13
14
import time
14
15
15
- from subprocess import Popen as execute
16
-
17
16
from extra .beep .beep import beep
18
17
from lib .core .agent import agent
19
18
from lib .core .common import Backend
@@ -200,7 +199,7 @@ def checkSqlInjection(place, parameter, value):
200
199
if conf .tech and isinstance (conf .tech , list ) and stype not in conf .tech :
201
200
debugMsg = "skipping test '%s' because the user " % title
202
201
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 )
204
203
logger .debug (debugMsg )
205
204
continue
206
205
@@ -651,20 +650,20 @@ def genCmpPayload():
651
650
652
651
# Feed with test details every time a test is successful
653
652
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
657
656
658
- if not isinstance (dValue , list ):
659
- Backend .setDbms (dValue )
657
+ if not isinstance (value , list ):
658
+ Backend .setDbms (value )
660
659
else :
661
- Backend .forceDbms (dValue [0 ], True )
660
+ Backend .forceDbms (value [0 ], True )
662
661
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 )
665
664
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 )
668
667
669
668
if vector is None and "vector" in test and test .vector is not None :
670
669
vector = test .vector
@@ -696,7 +695,7 @@ def genCmpPayload():
696
695
infoMsg = "executing alerting shell command(s) ('%s')" % conf .alert
697
696
logger .info (infoMsg )
698
697
699
- process = execute (conf .alert , shell = True )
698
+ process = subprocess . Popen (conf .alert , shell = True )
700
699
process .wait ()
701
700
702
701
kb .alerted = True
@@ -921,8 +920,10 @@ def heuristicCheckSqlInjection(place, parameter):
921
920
922
921
origValue = conf .paramDict [place ][parameter ]
923
922
paramType = conf .method if conf .method not in (None , HTTPMETHOD .GET , HTTPMETHOD .POST ) else place
923
+
924
924
prefix = ""
925
925
suffix = ""
926
+ randStr = ""
926
927
927
928
if conf .prefix or conf .suffix :
928
929
if conf .prefix :
@@ -931,8 +932,6 @@ def heuristicCheckSqlInjection(place, parameter):
931
932
if conf .suffix :
932
933
suffix = conf .suffix
933
934
934
- randStr = ""
935
-
936
935
while randStr .count ('\' ' ) != 1 or randStr .count ('\" ' ) != 1 :
937
936
randStr = randomStr (length = 10 , alphabet = HEURISTIC_CHECK_ALPHABET )
938
937
0 commit comments