From 228cc6874703c29cc25765177e950a819c94ec74 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 8 Apr 2011 11:02:21 +0000 Subject: [PATCH] fix for those ugly DEBUG messages in brute mode --- lib/core/option.py | 5 ++--- lib/request/inject.py | 5 +++-- lib/techniques/brute/use.py | 4 ++++ lib/techniques/error/use.py | 5 +++-- lib/techniques/inband/union/use.py | 5 +++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 3e36991db..5b3505b8b 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1234,9 +1234,8 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.authHeader = None kb.bannerFp = advancedDict() - kb.brute = advancedDict() - kb.brute.tables = [] - kb.brute.columns = [] + kb.brute = advancedDict({'tables':[], 'columns':[]}) + kb.bruteMode = False kb.cache = advancedDict() kb.cache.content = {} diff --git a/lib/request/inject.py b/lib/request/inject.py index 3578d2597..5ca1ee1c7 100644 --- a/lib/request/inject.py +++ b/lib/request/inject.py @@ -63,8 +63,9 @@ def __goInference(payload, expression, charsetType=None, firstChar=None, lastCha count, value = bisection(payload, expression, length, charsetType, firstChar, lastChar, dump) - debugMsg = "performed %d queries in %d seconds" % (count, calculateDeltaSeconds(start)) - logger.debug(debugMsg) + if not kb.bruteMode: + debugMsg = "performed %d queries in %d seconds" % (count, calculateDeltaSeconds(start)) + logger.debug(debugMsg) return value diff --git a/lib/techniques/brute/use.py b/lib/techniques/brute/use.py index 8fccbe678..08c9cc5c8 100644 --- a/lib/techniques/brute/use.py +++ b/lib/techniques/brute/use.py @@ -57,6 +57,7 @@ def tableExists(tableFile, regex=None): tbllock = threading.Lock() iolock = threading.Lock() kb.threadContinue = True + kb.bruteMode = True def tableExistsThread(): while count[0] < length and kb.threadContinue: @@ -140,6 +141,7 @@ def tableExists(tableFile, regex=None): except KeyboardInterrupt: raise sqlmapThreadException, "user aborted" finally: + kb.bruteMode = False kb.threadContinue = True kb.threadException = False @@ -182,6 +184,7 @@ def columnExists(columnFile, regex=None): collock = threading.Lock() iolock = threading.Lock() kb.threadContinue = True + kb.bruteMode = True def columnExistsThread(): while count[0] < length and kb.threadContinue: @@ -256,6 +259,7 @@ def columnExists(columnFile, regex=None): except KeyboardInterrupt: raise sqlmapThreadException, "user aborted" finally: + kb.bruteMode = False kb.threadContinue = True kb.threadException = False diff --git a/lib/techniques/error/use.py b/lib/techniques/error/use.py index c3df29e57..70135ce21 100644 --- a/lib/techniques/error/use.py +++ b/lib/techniques/error/use.py @@ -307,7 +307,8 @@ def errorUse(expression, expected=None, resumeValue=True, dump=False): duration = calculateDeltaSeconds(start) - debugMsg = "performed %d queries in %d seconds" % (reqCount, duration) - logger.debug(debugMsg) + if not kb.bruteMode: + debugMsg = "performed %d queries in %d seconds" % (reqCount, duration) + logger.debug(debugMsg) return outputs diff --git a/lib/techniques/inband/union/use.py b/lib/techniques/inband/union/use.py index 4de88f599..194beff6c 100644 --- a/lib/techniques/inband/union/use.py +++ b/lib/techniques/inband/union/use.py @@ -269,7 +269,8 @@ def unionUse(expression, unpack=True, dump=False): duration = calculateDeltaSeconds(start) - debugMsg = "performed %d queries in %d seconds" % (reqCount, duration) - logger.debug(debugMsg) + if not kb.bruteMode: + debugMsg = "performed %d queries in %d seconds" % (reqCount, duration) + logger.debug(debugMsg) return value