@@ -137,7 +137,7 @@ def checkSqlInjection(place, parameter, value):
137137 SUPPORTED_DBMS , True ) or kb .heuristicDbms or injection .dbms ):
138138 msg = "it looks like the back-end DBMS is '%s'. " % (Format .getErrorParsedDBMSes () or kb .heuristicDbms or injection .dbms )
139139 msg += "Do you want to skip test payloads specific for other DBMSes? [Y/n]"
140- kb .reduceTests = (Backend .getErrorParsedDBMSes () or [kb .heuristicDbms ]) if readInput (msg , default = 'Y' ). upper () == 'Y' else []
140+ kb .reduceTests = (Backend .getErrorParsedDBMSes () or [kb .heuristicDbms ]) if readInput (msg , default = 'Y' , boolean = True ) else []
141141
142142 # If the DBMS has been fingerprinted (via DBMS-specific error
143143 # message, via simple heuristic check or via DBMS-specific
@@ -152,7 +152,7 @@ def checkSqlInjection(place, parameter, value):
152152 msg += " and " if conf .level < 5 and conf .risk < 3 else ""
153153 msg += "risk (%d)" % conf .risk if conf .risk < 3 else ""
154154 msg += " values? [Y/n]" if conf .level < 5 and conf .risk < 3 else " value? [Y/n]"
155- kb .extendTests = (Backend .getErrorParsedDBMSes () or [kb .heuristicDbms ]) if readInput (msg , default = 'Y' ). upper () == 'Y' else []
155+ kb .extendTests = (Backend .getErrorParsedDBMSes () or [kb .heuristicDbms ]) if readInput (msg , default = 'Y' , boolean = True ) else []
156156
157157 title = test .title
158158 kb .testType = stype = test .stype
@@ -631,7 +631,8 @@ def genCmpPayload():
631631 msg += "extended UNION tests if there is not "
632632 msg += "at least one other (potential) "
633633 msg += "technique found. Do you want to skip? [Y/n] "
634- kb .futileUnion = readInput (msg , default = "Y" ).strip ().upper () == 'N'
634+
635+ kb .futileUnion = not readInput (msg , default = 'Y' , boolean = True )
635636 if kb .futileUnion is False :
636637 continue
637638
@@ -738,11 +739,9 @@ def genCmpPayload():
738739 logger .warn (warnMsg )
739740
740741 msg = "how do you want to proceed? [(S)kip current test/(e)nd detection phase/(n)ext parameter/(c)hange verbosity/(q)uit]"
741- choice = readInput (msg , default = "S" , checkBatch = False )
742+ choice = readInput (msg , default = 'S' , checkBatch = False ). strip (). upper ( )
742743
743- if choice [0 ] in ("s" , "S" ):
744- pass
745- elif choice [0 ] in ("c" , "C" ):
744+ if choice == 'C' :
746745 choice = None
747746 while not ((choice or "" ).isdigit () and 0 <= int (choice ) <= 6 ):
748747 if choice :
@@ -752,11 +751,11 @@ def genCmpPayload():
752751 conf .verbose = int (choice )
753752 setVerbosity ()
754753 tests .insert (0 , test )
755- elif choice [ 0 ] in ( "n" , "N" ) :
754+ elif choice == 'N' :
756755 return None
757- elif choice [ 0 ] in ( "e" , "E" ) :
756+ elif choice == 'E' :
758757 kb .endDetection = True
759- elif choice [ 0 ] in ( "q" , "Q" ) :
758+ elif choice == 'Q' :
760759 raise SqlmapUserQuitException
761760
762761 finally :
@@ -1177,19 +1176,19 @@ def checkStability():
11771176 logger .warn (warnMsg )
11781177
11791178 message = "how do you want to proceed? [(C)ontinue/(s)tring/(r)egex/(q)uit] "
1180- test = readInput (message , default = "C" )
1179+ choice = readInput (message , default = 'C' ). strip (). upper ( )
11811180
1182- if test and test [ 0 ] in ( "q" , "Q" ) :
1181+ if choice == 'Q' :
11831182 raise SqlmapUserQuitException
11841183
1185- elif test and test [ 0 ] in ( "s" , "S" ) :
1184+ elif choice == 'S' :
11861185 showStaticWords (firstPage , secondPage )
11871186
11881187 message = "please enter value for parameter 'string': "
1189- test = readInput (message )
1188+ string = readInput (message )
11901189
1191- if test :
1192- conf .string = test
1190+ if string :
1191+ conf .string = string
11931192
11941193 if kb .nullConnection :
11951194 debugMsg = "turning off NULL connection "
@@ -1201,12 +1200,12 @@ def checkStability():
12011200 errMsg = "Empty value supplied"
12021201 raise SqlmapNoneDataException (errMsg )
12031202
1204- elif test and test [ 0 ] in ( "r" , "R" ) :
1203+ elif choice == 'R' :
12051204 message = "please enter value for parameter 'regex': "
1206- test = readInput (message )
1205+ regex = readInput (message )
12071206
1208- if test :
1209- conf .regex = test
1207+ if regex :
1208+ conf .regex = regex
12101209
12111210 if kb .nullConnection :
12121211 debugMsg = "turning off NULL connection "
@@ -1372,13 +1371,13 @@ def _(*args, **kwargs):
13721371 if retVal :
13731372 message = "are you sure that you want to "
13741373 message += "continue with further target testing? [y/N] "
1375- output = readInput (message , default = "N" )
1374+ choice = readInput (message , default = 'N' , boolean = True )
13761375
13771376 if not conf .tamper :
13781377 warnMsg = "please consider usage of tamper scripts (option '--tamper')"
13791378 singleTimeWarnMessage (warnMsg )
13801379
1381- if output and output [ 0 ] not in ( "Y" , "y" ) :
1380+ if not choice :
13821381 raise SqlmapUserQuitException
13831382 else :
13841383 warnMsg = "WAF/IPS/IDS product hasn't been identified"
@@ -1494,7 +1493,7 @@ def checkConnection(suppressOutput=False):
14941493 return False
14951494
14961495 msg = "it is not recommended to continue in this kind of cases. Do you want to quit and make sure that everything is set up properly? [Y/n] "
1497- if readInput (msg , default = "Y" ) not in ( "n" , "N" ):
1496+ if readInput (msg , default = 'Y' , boolean = True ):
14981497 raise SqlmapSilentQuitException
14991498 else :
15001499 kb .ignoreNotFound = True
0 commit comments