@@ -157,6 +157,7 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True):
157157 forgedPayload = safeStringFormat (payload .replace ('%3E' , '%3D' ), (expressionUnescaped , idx , charTbl [0 ]))
158158 queriesCount [0 ] += 1
159159 result = Request .queryPage (urlencode (forgedPayload ))
160+
160161 if result :
161162 return chr (charTbl [0 ]) if charTbl [0 ] < 128 else unichr (charTbl [0 ])
162163 else :
@@ -171,10 +172,7 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True):
171172
172173 if kb .dbms == "SQLite" :
173174 posValueOld = posValue
174- if posValue < 128 :
175- posValue = chr (posValue )
176- else :
177- posValue = unichr (posValue )
175+ posValue = chr (posValue ) if posValue < 128 else unichr (posValue )
178176
179177 if not conf .useBetween or kb .dbms == "SQLite" :
180178 forgedPayload = safeStringFormat (payload , (expressionUnescaped , idx , posValue ))
@@ -189,12 +187,14 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True):
189187
190188 if result :
191189 minValue = posValue
190+
192191 if type (charTbl ) != xrange :
193192 charTbl = charTbl [position :]
194193 else :
195194 charTbl = xrange (charTbl [position ], charTbl [- 1 ] + 1 )
196195 else :
197196 maxValue = posValue
197+
198198 if type (charTbl ) != xrange :
199199 charTbl = charTbl [:position ]
200200 else :
@@ -214,12 +214,15 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True):
214214 else :
215215 if minValue == maxChar or maxValue == minChar :
216216 return None
217+
217218 for retVal in (originalTbl [originalTbl .index (minValue )], originalTbl [originalTbl .index (minValue ) + 1 ]):
218219 forgedPayload = safeStringFormat (payload .replace ('%3E' , '%3D' ), (expressionUnescaped , idx , retVal ))
219220 queriesCount [0 ] += 1
220221 result = Request .queryPage (urlencode (forgedPayload ))
222+
221223 if result :
222224 return chr (retVal ) if retVal < 128 else unichr (retVal )
225+
223226 return None
224227
225228 def etaProgressUpdate (charTime , index ):
@@ -390,9 +393,8 @@ def downloadThread():
390393 val = None
391394 singleValue , commonCharset , otherCharset = goGoodSamaritan (kb .partRun , finalValue , asciiTbl )
392395
393- # If there is no singleValue (single match from
394- # txt/common-outputs.txt) use the returned common
395- # charset only to retrieve the query output
396+ # If there is one single output in common-outputs, check
397+ # it via equal against the query output
396398 if singleValue is not None :
397399 # One-shot query containing equals singleValue
398400 query = agent .prefixQuery (" %s" % safeStringFormat ('AND (%s) = %s' , (expressionUnescaped , unescaper .unescape ('\' %s\' ' % singleValue ))))
@@ -412,7 +414,11 @@ def downloadThread():
412414 finalValue = singleValue
413415
414416 break
415- elif commonCharset :
417+
418+ # Otherwise if there is no singleValue (single match from
419+ # txt/common-outputs.txt) use the returned common
420+ # charset only to retrieve the query output
421+ if commonCharset :
416422 val = getChar (index , commonCharset , False )
417423
418424 # If we had no luck with singleValue and common charset,
0 commit comments