Skip to content

Commit fffda32

Browse files
committed
fix for Bug sqlmapproject#167
1 parent f6adb43 commit fffda32

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/techniques/blind/inference.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
9595
showEta = conf.eta and isinstance(length, int)
9696
numThreads = min(conf.threads, length)
9797
threads = []
98+
totalWidth = 54
9899

99100
if showEta:
100101
progress = ProgressBar(maxValue=length)
@@ -105,7 +106,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
105106
infoMsg = "starting %d threads" % numThreads
106107
logger.info(infoMsg)
107108

108-
dataToStdout("[%s] [INFO] retrieved: %s" % (time.strftime("%X"), "_" * length))
109+
dataToStdout("[%s] [INFO] retrieved: %s" % (time.strftime("%X"), "_" * min(length, totalWidth)))
109110
dataToStdout("\r[%s] [INFO] retrieved: " % time.strftime("%X"))
110111
else:
111112
dataToStdout("[%s] [INFO] retrieved: " % time.strftime("%X"))
@@ -184,9 +185,27 @@ def downloadThread():
184185
if showEta:
185186
etaProgressUpdate(time.time() - charStart, index[0])
186187
elif conf.verbose >= 1:
187-
s = "".join([c or "_" for c in value])
188+
startCharIndex = 0
189+
endCharIndex = 0
190+
for i in xrange(length):
191+
if value[i] is not None:
192+
endCharIndex = max(endCharIndex, i)
193+
output = ''
194+
if endCharIndex > totalWidth:
195+
startCharIndex = endCharIndex - totalWidth
196+
count = 0
197+
for i in xrange(startCharIndex, endCharIndex):
198+
output += '_' if value[i] is None else value[i]
199+
for i in xrange(length):
200+
count += 1 if value[i] is not None else 0
201+
if startCharIndex > 0:
202+
output = '...' + output[3:]
203+
if endCharIndex - startCharIndex == totalWidth:
204+
output = output[:-3] + '...'
205+
status = ' %d/%d' % (count, length)
206+
output += status if count != length else " "*len(status)
188207
iolock.acquire()
189-
dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), s))
208+
dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), output))
190209
iolock.release()
191210

192211
except (sqlmapConnectionException, sqlmapValueException), errMsg:

0 commit comments

Comments
 (0)