From 5c857779c1ae7c20bfcf768a48c83f6275a73c83 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 17 Jan 2011 10:15:19 +0000 Subject: [PATCH] important fix for unicode based character inference --- lib/core/settings.py | 3 +++ lib/techniques/blind/inference.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/core/settings.py b/lib/core/settings.py index 9a8af364c..4ee65e0ab 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -76,6 +76,9 @@ MIN_TIME_RESPONSES = 15 # after these number of blanks at the end inference should stop (just in case) INFERENCE_BLANK_BREAK = 10 +# use this replacement character for cases when inference is not able to retrieve the proper character value +INFERENCE_UNKNOWN_CHAR = '?' + # string used for representation of unknown dbms version UNKNOWN_DBMS_VERSION = "Unknown" diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index 77c2aeec6..f43408043 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -37,6 +37,7 @@ from lib.core.exception import unhandledException from lib.core.progress import ProgressBar from lib.core.settings import CHAR_INFERENCE_MARK from lib.core.settings import INFERENCE_BLANK_BREAK +from lib.core.settings import INFERENCE_UNKNOWN_CHAR from lib.core.unescaper import unescaper from lib.request.connect import Connect as Request @@ -216,6 +217,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None # list if expand and shiftTable: charTbl = xrange(maxChar + 1, (maxChar + 1) << shiftTable.pop()) + originalTbl = list(charTbl) maxChar = maxValue = charTbl[-1] minChar = minValue = charTbl[0] else: @@ -282,7 +284,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None charStart = time.time() val = getChar(curidx) if val is None: - val = '?' + val = INFERENCE_UNKNOWN_CHAR else: break @@ -496,6 +498,9 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None if len(finalValue) > INFERENCE_BLANK_BREAK and finalValue[-INFERENCE_BLANK_BREAK:].isspace(): break + if finalValue: + finalValue = finalValue.rstrip(INFERENCE_UNKNOWN_CHAR) + if conf.verbose in (1, 2) or showEta: dataToStdout("\n")