From b313a20a3f56ef98a4c4f63e9f2e4d9ed958ff81 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 7 Jan 2011 16:39:47 +0000 Subject: [PATCH] some fixes --- lib/core/common.py | 2 +- lib/core/option.py | 1 - lib/core/threads.py | 1 + lib/request/inject.py | 8 +++----- lib/utils/resume.py | 3 ++- plugins/generic/enumeration.py | 5 +++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index d2e89be1c..c01249f71 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -422,7 +422,7 @@ def filePathToString(filePath): def dataToStdout(data, forceOutput=False): if not ('threadException' in kb and kb.threadException): - if forceOutput or (conf.verbose > 0) and not ('disableStdOut' in kb and kb.disableStdOut): + if forceOutput or (conf.verbose > 0) and not getCurrentThreadData().disableStdOut: try: sys.stdout.write(data) sys.stdout.flush() diff --git a/lib/core/option.py b/lib/core/option.py index ae6f95d4e..f7314403c 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1140,7 +1140,6 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.commonOutputs = None kb.data = advancedDict() - kb.disableStdOut = False # Old style injection flag kb.unionTest = None diff --git a/lib/core/threads.py b/lib/core/threads.py index b3352171c..aa78a83fd 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -17,6 +17,7 @@ class ThreadData(): """ def __init__(self): + self.disableStdOut = False self.lastErrorPage = None self.lastHTTPError = None self.lastQueryDuration = 0 diff --git a/lib/request/inject.py b/lib/request/inject.py index a6d3fa58e..58cd272c8 100644 --- a/lib/request/inject.py +++ b/lib/request/inject.py @@ -14,7 +14,6 @@ from lib.core.agent import agent from lib.core.common import calculateDeltaSeconds from lib.core.common import cleanQuery from lib.core.common import dataToSessionFile -from lib.core.common import dataToStdout from lib.core.common import expandAsteriskForColumns from lib.core.common import getPublicTypeMembers from lib.core.common import initTechnique @@ -36,6 +35,7 @@ from lib.core.enums import PAYLOAD from lib.core.exception import sqlmapNotVulnerableException from lib.core.settings import MIN_TIME_RESPONSES from lib.core.settings import MAX_TECHNIQUES_PER_VALUE +from lib.core.threads import getCurrentThreadData from lib.core.unescaper import unescaper from lib.request.connect import Connect as Request from lib.request.direct import direct @@ -391,8 +391,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse (if selected). """ - if suppressOutput: - kb.disableStdOut = True + getCurrentThreadData().disableStdOut = suppressOutput try: if conf.direct: @@ -472,8 +471,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse raise sqlmapNotVulnerableException, errMsg finally: - if suppressOutput: - kb.disableStdOut = False + getCurrentThreadData().disableStdOut = False if value and expected == EXPECTED.BOOL: if isinstance(value, basestring): diff --git a/lib/utils/resume.py b/lib/utils/resume.py index 19a363cdb..a85adb771 100644 --- a/lib/utils/resume.py +++ b/lib/utils/resume.py @@ -12,6 +12,7 @@ import time from lib.core.common import calculateDeltaSeconds from lib.core.common import dataToSessionFile +from lib.core.common import dataToStdout from lib.core.common import safeStringFormat from lib.core.common import randomStr from lib.core.common import replaceNewlineTabs @@ -129,7 +130,7 @@ def resume(expression, payload): else: infoMsg += logValue - logger.info(infoMsg) + dataToStdout("[%s] [INFO] %s\n" % (time.strftime("%X"), infoMsg)) return resumedValue diff --git a/plugins/generic/enumeration.py b/plugins/generic/enumeration.py index d3037fdd5..8f77e276c 100644 --- a/plugins/generic/enumeration.py +++ b/plugins/generic/enumeration.py @@ -46,6 +46,7 @@ from lib.core.session import setOs from lib.core.settings import SQL_STATEMENTS from lib.core.shell import autoCompletion from lib.core.unescaper import unescaper +from lib.core.threads import getCurrentThreadData from lib.parse.banner import bannerParser from lib.request import inject from lib.request.connect import Connect as Request @@ -309,7 +310,7 @@ class Enumeration: break else: query = rootQuery.blind.query % user - kb.disableStdOut = True + getCurrentThreadData().disableStdOut = True elif kb.dbms == DBMS.MSSQL: if kb.dbmsVersion[0] in ( "2005", "2008" ): query = rootQuery.blind.query2 % (user, index, user) @@ -319,7 +320,7 @@ class Enumeration: query = rootQuery.blind.query % (user, index) password = inject.getValue(query, inband=False) if kb.dbms == DBMS.SYBASE: - kb.disableStdOut = False + getCurrentThreadData().disableStdOut = False password = "0x%s" % strToHex(password) infoMsg = "retrieved: %s" % password logger.info(infoMsg)