From fb7243c2377956d9945a387c60c419685adc6301 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 16 Jan 2013 16:04:00 +0100 Subject: [PATCH 1/2] Cleaning a mess where multi-threaded HTTP requests (in log) had sometimes same UIDs --- lib/core/option.py | 3 ++- lib/request/connect.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 5ef766eda..a8eda4da4 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1556,7 +1556,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.lastParserStatus = None kb.locks = AttribDict() - for _ in ("cache", "count", "index", "io", "limit", "log", "value"): + for _ in ("cache", "count", "index", "io", "limit", "log", "request", "value"): kb.locks[_] = threading.Lock() kb.matchRatio = None @@ -1595,6 +1595,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.redirectSetCookie = None kb.reflectiveMechanism = True kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0} + kb.requestCounter = 0 kb.responseTimes = [] kb.resumeValues = True kb.safeCharEncode = False diff --git a/lib/request/connect.py b/lib/request/connect.py index 080a7773f..a0919c63c 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -179,7 +179,9 @@ class Connect(object): cpuThrottle(conf.cpuThrottle) threadData = getCurrentThreadData() - threadData.lastRequestUID += 1 + with kb.locks.request: + kb.requestCounter += 1 + threadData.lastRequestUID = kb.requestCounter url = kwargs.get('url', conf.url) get = kwargs.get('get', None) From 053b7d12b433fc64a59d3a28c282cca951ee4e85 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 16 Jan 2013 16:07:12 +0100 Subject: [PATCH 2/2] Minor language update --- lib/core/option.py | 2 +- lib/core/threads.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index a8eda4da4..11f9aad1b 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -2008,7 +2008,7 @@ def _basicOptionValidation(): raise SqlmapSyntaxException(errMsg) if conf.threads > MAX_NUMBER_OF_THREADS: - errMsg = "maximum number of used threads is %d avoiding possible connection issues" % MAX_NUMBER_OF_THREADS + errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS raise SqlmapSyntaxException(errMsg) if conf.forms and not any((conf.url, conf.bulkFile)): diff --git a/lib/core/threads.py b/lib/core/threads.py index d9994b91f..18cfcb2f9 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -110,7 +110,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio choice = readInput(message, default=str(numThreads)) if choice and choice.isdigit(): if int(choice) > MAX_NUMBER_OF_THREADS: - errMsg = "maximum number of used threads is %d avoiding possible connection issues" % MAX_NUMBER_OF_THREADS + errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS logger.critical(errMsg) else: numThreads = int(choice)