@@ -66,6 +66,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
6666 finalValue = None
6767 retrievedLength = 0
6868 asciiTbl = getCharset (charsetType )
69+ threadData = getCurrentThreadData ()
6970 timeBasedCompare = (kb .technique in (PAYLOAD .TECHNIQUE .TIME , PAYLOAD .TECHNIQUE .STACKED ))
7071 retVal = hashDBRetrieve (expression , checkConf = True )
7172
@@ -254,9 +255,43 @@ def getChar(idx, charTbl=None, continuousOrder=True, expand=charsetType is None,
254255
255256 maxChar = maxValue = charTbl [- 1 ]
256257 minChar = minValue = charTbl [0 ]
258+ firstCheck = False
259+ lastCheck = False
257260
258261 while len (charTbl ) != 1 :
259- position = (len (charTbl ) >> 1 )
262+ position = None
263+
264+ if charsetType is None :
265+ if not firstCheck :
266+ try :
267+ try :
268+ lastChar = [_ for _ in threadData .shared .value if _ is not None ][- 1 ]
269+ except IndexError :
270+ lastChar = None
271+ if 'a' <= lastChar <= 'z' :
272+ position = charTbl .index (ord ('a' ) - 1 ) # 96
273+ elif 'A' <= lastChar <= 'Z' :
274+ position = charTbl .index (ord ('A' ) - 1 ) # 64
275+ elif '0' <= lastChar <= '9' :
276+ position = charTbl .index (ord ('0' ) - 1 ) # 47
277+ except ValueError :
278+ pass
279+ finally :
280+ firstCheck = True
281+
282+ elif not lastCheck :
283+ if charTbl [(len (charTbl ) >> 1 )] < ord (' ' ):
284+ try :
285+ # favorize last char check if current value inclines toward 0
286+ position = charTbl .index (1 )
287+ except ValueError :
288+ pass
289+ finally :
290+ lastCheck = True
291+
292+ if position is None :
293+ position = (len (charTbl ) >> 1 )
294+
260295 posValue = charTbl [position ]
261296 falsePayload = None
262297
@@ -376,8 +411,6 @@ def getChar(idx, charTbl=None, continuousOrder=True, expand=charsetType is None,
376411
377412 # Go multi-threading (--threads > 1)
378413 if conf .threads > 1 and isinstance (length , int ) and length > 1 :
379- threadData = getCurrentThreadData ()
380-
381414 threadData .shared .value = [None ] * length
382415 threadData .shared .index = [firstChar ] # As list for python nested function scoping
383416 threadData .shared .start = firstChar
@@ -476,6 +509,7 @@ def blindThread():
476509 # No multi-threading (--threads = 1)
477510 else :
478511 index = firstChar
512+ threadData .shared .value = ""
479513
480514 while True :
481515 index += 1
@@ -551,7 +585,7 @@ def blindThread():
551585 if kb .data .processChar :
552586 val = kb .data .processChar (val )
553587
554- partialValue += val
588+ threadData . shared . value = partialValue = partialValue + val
555589
556590 if showEta :
557591 progress .progress (time .time () - charStart , index )
0 commit comments