diff --git a/lib/core/common.py b/lib/core/common.py index e435f847c..f9fa6add2 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -913,7 +913,8 @@ def dataToStdout(data, forceOutput=False, bold=False, content_type=None, status= if not kb.get("threadException"): if forceOutput or not (getCurrentThreadData().disableStdOut or kb.get("wizardMode")): - if kb.get("multiThreadMode"): + multiThreadMode = isMultiThreadMode() + if multiThreadMode: logging._acquireLock() if isinstance(data, unicode): @@ -931,7 +932,7 @@ def dataToStdout(data, forceOutput=False, bold=False, content_type=None, status= except IOError: pass - if kb.get("multiThreadMode"): + if multiThreadMode: logging._releaseLock() kb.prependFlag = isinstance(data, basestring) and (len(data) == 1 and data not in ('\n', '\r') or len(data) > 2 and data[0] == '\r' and data[-1] != '\n') @@ -1982,6 +1983,13 @@ def isHexEncodedString(subject): return re.match(r"\A[0-9a-fA-Fx]+\Z", subject) is not None +def isMultiThreadMode(): + """ + Checks if running in multi-thread(ing) mode + """ + + return threading.activeCount() > 1 + @cachedmethod def getConsoleWidth(default=80): """ diff --git a/lib/core/dump.py b/lib/core/dump.py index 2ef7e2407..ddbf3209e 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -20,6 +20,7 @@ from lib.core.common import dataToStdout from lib.core.common import getSafeExString from lib.core.common import getUnicode from lib.core.common import isListLike +from lib.core.common import isMultiThreadMode from lib.core.common import normalizeUnicode from lib.core.common import openFile from lib.core.common import prioritySortColumns @@ -74,7 +75,8 @@ class Dump(object): if console: dataToStdout(text) - if kb.get("multiThreadMode"): + multiThreadMode = isMultiThreadMode() + if multiThreadMode: self._lock.acquire() try: @@ -83,7 +85,7 @@ class Dump(object): errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex) raise SqlmapGenericException(errMsg) - if kb.get("multiThreadMode"): + if multiThreadMode: self._lock.release() kb.dataOutputFlag = True diff --git a/lib/core/option.py b/lib/core/option.py index 80865360e..eabf65a1c 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1829,7 +1829,6 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.matchRatio = None kb.maxConnectionsFlag = False kb.mergeCookies = None - kb.multiThreadMode = False kb.negativeLogic = False kb.nullConnection = None kb.oldMsf = None diff --git a/lib/core/settings.py b/lib/core/settings.py index e9bffd776..59c7df703 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import OS # sqlmap version (...) -VERSION = "1.3.1.70" +VERSION = "1.3.1.71" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/lib/core/threads.py b/lib/core/threads.py index a9e4a4c96..f6f6bb65d 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -110,7 +110,6 @@ def setDaemon(thread): def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardException=True, threadChoice=False, startThreadMsg=True): threads = [] - kb.multiThreadMode = True kb.threadContinue = True kb.threadException = False @@ -204,7 +203,6 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio traceback.print_exc() finally: - kb.multiThreadMode = False kb.bruteMode = False kb.threadContinue = True kb.threadException = False diff --git a/lib/request/connect.py b/lib/request/connect.py index 8ea22e11a..b179fa7e3 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -44,6 +44,7 @@ from lib.core.common import getHostHeader from lib.core.common import getRequestHeader from lib.core.common import getSafeExString from lib.core.common import getUnicode +from lib.core.common import isMultiThreadMode from lib.core.common import logHTTPTraffic from lib.core.common import pushValue from lib.core.common import popValue @@ -731,7 +732,7 @@ class Connect(object): else: logger.debug(warnMsg) return Connect._retryProxy(**kwargs) - elif kb.testMode or kb.multiThreadMode: + elif kb.testMode or isMultiThreadMode(): logger.critical(warnMsg) return None, None, None else: diff --git a/txt/checksum.md5 b/txt/checksum.md5 index 0e37883c1..8bc457541 100644 --- a/txt/checksum.md5 +++ b/txt/checksum.md5 @@ -29,32 +29,32 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py -2cb5d057cbb1f333dfd42b8c7262d404 lib/core/common.py +d6961903f261635b2eb3fe7e9c35e8ce lib/core/common.py de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py db60c6ebb63b72ed119e304b359fc1a6 lib/core/datatype.py b7c912e2af7a3354f6d7c04f556a80b2 lib/core/decorators.py 5f4680b769ae07f22157bd832c97cf8f lib/core/defaults.py 9dfc69ba47209a4ceca494dde9ee8183 lib/core/dicts.py -fd5403505f76eee6829c06b9342e269c lib/core/dump.py +4782353a3072e4d17c4e314daf918d8a lib/core/dump.py 5c91145204092b995ed1ac641e9e291d lib/core/enums.py 84ef8f32e4582fcc294dc14e1997131d lib/core/exception.py fb6be55d21a70765e35549af2484f762 lib/core/__init__.py 18c896b157b03af716542e5fe9233ef9 lib/core/log.py fa9f24e88c81a6cef52da3dd5e637010 lib/core/optiondict.py -bdb5a0e1f40d9c4d43593e25c8c58ec6 lib/core/option.py +b56df9d9426027f3450432c2b6428485 lib/core/option.py fe370021c6bc99daf44b2bfc0d1effb3 lib/core/patch.py 4cfda3735871cd59b213470a0bbc8c3a lib/core/profiling.py 5e2c16a8e2daee22dd545df13386e7a3 lib/core/readlineng.py 7d8a22c582ad201f65b73225e4456170 lib/core/replication.py 3179d34f371e0295dd4604568fb30bcd lib/core/revision.py d6269c55789f78cf707e09a0f5b45443 lib/core/session.py -6e47f6340889c0241c3055581fd9dd5c lib/core/settings.py +77e8b3de0d19deb37e87cf34bdf18a1a lib/core/settings.py 4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py 10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py 9c7b5c6397fb3da33e7a4d7876d159c6 lib/core/target.py 7857b24b7865ccb4a05283faa596974d lib/core/testing.py -203d2082929b4ac5454605c8c7c800a9 lib/core/threads.py +e9788d2992f842cf91ab67389bf4372a lib/core/threads.py 2c263c8610667fdc593c50a35ab20f57 lib/core/unescaper.py ff45c74515fecc95277f7b9ad945f17c lib/core/update.py 5b3f08208be0579356f78ce5805d37b2 lib/core/wordlist.py @@ -71,7 +71,7 @@ adcecd2d6a8667b22872a563eb83eac0 lib/parse/payloads.py e4ea70bcd461f5176867dcd89d372386 lib/request/basicauthhandler.py 97b7577fdfe3d8537fe9ea3a070d0507 lib/request/basic.py fc25d951217077fe655ed2a3a81552ae lib/request/comparison.py -5a1226fc294dd7507be089b5622564d1 lib/request/connect.py +27927a37edfa9c2dfb6e5de9e859d10f lib/request/connect.py 7cba86090b02558f04c6692cef66e772 lib/request/direct.py 2b7509ba38a667c61cefff036ec4ca6f lib/request/dns.py ceac6b3bf1f726f8ff43c6814e9d7281 lib/request/httpshandler.py