From d335ec0c345d47eb8e1ed90390a5e213958e9f5d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sat, 26 May 2012 07:00:26 +0000 Subject: [PATCH] turning back on time auto-adjustment mechanism (if turned off) after a threshold run of valid chars --- lib/core/option.py | 1 + lib/core/settings.py | 3 +++ lib/techniques/blind/inference.py | 11 ++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/core/option.py b/lib/core/option.py index 73490aeb2..94f24da98 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1512,6 +1512,7 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.testQueryCount = 0 kb.threadContinue = True kb.threadException = False + kb.timeValidCharsRun = 0 kb.uChar = NULL kb.xpCmdshellAvailable = False diff --git a/lib/core/settings.py b/lib/core/settings.py index f73c0ac25..1c27b716e 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -487,3 +487,6 @@ LARGE_CHUNK_TRIM_MARKER = "__TRIMMED_CONTENT__" # Generic SQL comment formation GENERIC_SQL_COMMENT = "-- " + +# Threshold value for turning back on time auto-adjustment mechanism +VALID_TIME_CHARS_RUN_THRESHOLD = 100 diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index 523fc5b0a..eff550a74 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -43,6 +43,7 @@ from lib.core.settings import INFERENCE_EQUALS_CHAR from lib.core.settings import INFERENCE_NOT_EQUALS_CHAR from lib.core.settings import MAX_TIME_REVALIDATION_STEPS from lib.core.settings import PARTIAL_VALUE_MARKER +from lib.core.settings import VALID_TIME_CHARS_RUN_THRESHOLD from lib.core.threads import getCurrentThreadData from lib.core.threads import runThreads from lib.core.unescaper import unescaper @@ -282,13 +283,14 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None errMsg = "invalid character detected. retrying.." logger.error(errMsg) + kb.timeValidCharsRun = 0 conf.timeSec += 1 warnMsg = "increasing time delay to %d second%s " % (conf.timeSec, 's' if conf.timeSec > 1 else '') logger.warn(warnMsg) if kb.adjustTimeDelay: - dbgMsg = "turning off auto-adjustment mechanism" + dbgMsg = "turning off time auto-adjustment mechanism" logger.debug(dbgMsg) kb.adjustTimeDelay = False @@ -299,6 +301,13 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None conf.timeSec = kb.originalTimeDelay return decodeIntToUnicode(retVal) else: + if timeBasedCompare: + kb.timeValidCharsRun += 1 + if not kb.adjustTimeDelay and kb.timeValidCharsRun > VALID_TIME_CHARS_RUN_THRESHOLD: + dbgMsg = "turning on time auto-adjustment mechanism" + logger.debug(dbgMsg) + kb.adjustTimeDelay = True + return decodeIntToUnicode(retVal) else: return None