diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index e765f706b..9337a53eb 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -95,6 +95,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None showEta = conf.eta and isinstance(length, int) numThreads = min(conf.threads, length) threads = [] + totalWidth = 54 if showEta: progress = ProgressBar(maxValue=length) @@ -105,7 +106,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None infoMsg = "starting %d threads" % numThreads logger.info(infoMsg) - dataToStdout("[%s] [INFO] retrieved: %s" % (time.strftime("%X"), "_" * length)) + dataToStdout("[%s] [INFO] retrieved: %s" % (time.strftime("%X"), "_" * min(length, totalWidth))) dataToStdout("\r[%s] [INFO] retrieved: " % time.strftime("%X")) else: dataToStdout("[%s] [INFO] retrieved: " % time.strftime("%X")) @@ -184,9 +185,27 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None if showEta: etaProgressUpdate(time.time() - charStart, index[0]) elif conf.verbose >= 1: - s = "".join([c or "_" for c in value]) + startCharIndex = 0 + endCharIndex = 0 + for i in xrange(length): + if value[i] is not None: + endCharIndex = max(endCharIndex, i) + output = '' + if endCharIndex > totalWidth: + startCharIndex = endCharIndex - totalWidth + count = 0 + for i in xrange(startCharIndex, endCharIndex): + output += '_' if value[i] is None else value[i] + for i in xrange(length): + count += 1 if value[i] is not None else 0 + if startCharIndex > 0: + output = '...' + output[3:] + if endCharIndex - startCharIndex == totalWidth: + output = output[:-3] + '...' + status = ' %d/%d' % (count, length) + output += status if count != length else " "*len(status) iolock.acquire() - dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), s)) + dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), output)) iolock.release() except (sqlmapConnectionException, sqlmapValueException), errMsg: