Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9902018

Browse files
committed
Implementation for an Issue #2172
1 parent 56a918c commit 9902018

3 files changed

Lines changed: 41 additions & 7 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.revision import getRevisionNumber
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.0.9.19"
22+
VERSION = "1.0.9.20"
2323
REVISION = getRevisionNumber()
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}

lib/techniques/blind/inference.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

txt/checksum.md5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ e60456db5380840a586654344003d4e6 lib/core/readlineng.py
4545
5ef56abb8671c2ca6ceecb208258e360 lib/core/replication.py
4646
99a2b496b9d5b546b335653ca801153f lib/core/revision.py
4747
7c15dd2777af4dac2c89cab6df17462e lib/core/session.py
48-
b160ccb31688ecf1c91d62ed0de26a9f lib/core/settings.py
48+
95276012feeed6d7d2dc6f22724c70cc lib/core/settings.py
4949
7af83e4f18cab6dff5e67840eb65be80 lib/core/shell.py
5050
23657cd7d924e3c6d225719865855827 lib/core/subprocessng.py
5151
0bc2fae1dec18cdd11954b22358293f2 lib/core/target.py
@@ -87,7 +87,7 @@ cc9c82cfffd8ee9b25ba3af6284f057e lib/takeover/__init__.py
8787
7d6cd7bdfc8f4bc4e8aed60c84cdf87f lib/takeover/udf.py
8888
f6e3084abd506925a8be3d1c0a6d058c lib/takeover/web.py
8989
9af83a62de360184f1c14e69b8a95cfe lib/takeover/xp_cmdshell.py
90-
927092550c89f8c3c5caad2b14af0830 lib/techniques/blind/inference.py
90+
f9fccc94cb9d5c15f84b5feb579ab0de lib/techniques/blind/inference.py
9191
cc9c82cfffd8ee9b25ba3af6284f057e lib/techniques/blind/__init__.py
9292
cc9c82cfffd8ee9b25ba3af6284f057e lib/techniques/brute/__init__.py
9393
d36effffe64e63ef9b3be490f850e2cc lib/techniques/brute/use.py

0 commit comments

Comments
 (0)