From bf3edcfc1c4856b87833e1a2a889204077ad6c81 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 20 Mar 2019 11:33:10 +0100 Subject: [PATCH] Fixes #3542 --- lib/controller/checks.py | 13 +++++++++---- lib/core/settings.py | 2 +- lib/request/connect.py | 25 ++++++++++++++----------- txt/checksum.md5 | 6 +++--- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 39312a5c6..821b10821 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -1337,6 +1337,9 @@ def checkWaf(): if any((conf.string, conf.notString, conf.regexp, conf.dummy, conf.offline, conf.skipWaf)): return None + if kb.originalCode == httplib.NOT_FOUND: + return None + _ = hashDBRetrieve(HASHDB_KEYS.CHECK_WAF_RESULT, True) if _ is not None: if _: @@ -1544,6 +1547,8 @@ def checkNullConnection(): return kb.nullConnection is not None def checkConnection(suppressOutput=False): + threadData = getCurrentThreadData() + if not re.search(r"\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\Z", conf.hostname): if not any((conf.proxy, conf.tor, conf.dummy, conf.offline)): try: @@ -1568,8 +1573,7 @@ def checkConnection(suppressOutput=False): try: kb.originalPageTime = time.time() - page, headers, _ = Request.queryPage(content=True, noteResponseTime=False) - kb.originalPage = kb.pageTemplate = page + Request.queryPage(content=True, noteResponseTime=False) kb.errorIsNone = False @@ -1592,8 +1596,6 @@ def checkConnection(suppressOutput=False): else: kb.errorIsNone = True - threadData = getCurrentThreadData() - if kb.redirectChoice == REDIRECTION.YES and threadData.lastRedirectURL and threadData.lastRedirectURL[0] == threadData.lastRequestUID: if (threadData.lastRedirectURL[1] or "").startswith("https://") and unicodeencode(conf.hostname) in threadData.lastRedirectURL[1]: conf.url = re.sub(r"https?://", "https://", conf.url) @@ -1624,6 +1626,9 @@ def checkConnection(suppressOutput=False): kb.ignoreNotFound = True else: raise + finally: + kb.originalPage = kb.pageTemplate = threadData.lastPage + kb.originalCode = threadData.lastCode return True diff --git a/lib/core/settings.py b/lib/core/settings.py index 494b4ef42..e99ec3cb6 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.3.36" +VERSION = "1.3.3.37" 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/request/connect.py b/lib/request/connect.py index b25ad4df4..c07b1bd02 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -753,15 +753,19 @@ class Connect(object): page = unicode(page, errors="ignore") else: page = getUnicode(page) - socket.setdefaulttimeout(conf.timeout) - for function in kb.preprocessFunctions: - try: - page, responseHeaders, code = function(page, responseHeaders, code) - except Exception as ex: - errMsg = "error occurred while running preprocess " - errMsg += "function '%s' ('%s')" % (function.func_name, getSafeExString(ex)) - raise SqlmapGenericException(errMsg) + for function in kb.preprocessFunctions: + try: + page, responseHeaders, code = function(page, responseHeaders, code) + except Exception as ex: + errMsg = "error occurred while running preprocess " + errMsg += "function '%s' ('%s')" % (function.func_name, getSafeExString(ex)) + raise SqlmapGenericException(errMsg) + + threadData.lastPage = page + threadData.lastCode = code + + socket.setdefaulttimeout(conf.timeout) processResponse(page, responseHeaders, status) @@ -1309,10 +1313,9 @@ class Connect(object): page, headers, code = Connect.getPage(url=_(kb.secondReq[0]), post=_(kb.secondReq[2]), method=kb.secondReq[1], cookie=kb.secondReq[3], silent=silent, auxHeaders=dict(auxHeaders, **dict(kb.secondReq[4])), response=response, raise404=False, ignoreTimeout=timeBasedCompare, refreshing=True) threadData.lastQueryDuration = calculateDeltaSeconds(start) - threadData.lastPage = page - threadData.lastCode = code - kb.originalCode = kb.originalCode or code + kb.originalCode = code if kb.originalCode is None else kb.originalCode + kb.originalPage = page if kb.originalPage is None else kb.originalPage if kb.testMode: kb.testQueryCount += 1 diff --git a/txt/checksum.md5 b/txt/checksum.md5 index b1da12764..779a136bc 100644 --- a/txt/checksum.md5 +++ b/txt/checksum.md5 @@ -24,7 +24,7 @@ fb6be55d21a70765e35549af2484f762 extra/sqlharvest/__init__.py fb6be55d21a70765e35549af2484f762 extra/wafdetectify/__init__.py 4dc5e7c5400204159baaf10a0a9124f0 extra/wafdetectify/wafdetectify.py e6909a3b32fc09c0373101eb58c76538 lib/controller/action.py -0fce185e63b1b743b3ef0a3dbe640366 lib/controller/checks.py +e51ec20c402d53c3cbcae0b6bd71bd5d lib/controller/checks.py 8581acf56b8fb0def50af3707490a834 lib/controller/controller.py c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py @@ -50,7 +50,7 @@ d5ef43fe3cdd6c2602d7db45651f9ceb lib/core/readlineng.py 7d8a22c582ad201f65b73225e4456170 lib/core/replication.py 3179d34f371e0295dd4604568fb30bcd lib/core/revision.py d6269c55789f78cf707e09a0f5b45443 lib/core/session.py -94a1fd458bf3c9ced052707b8b5e447d lib/core/settings.py +63db6d32f98705fc0240aaeeff88ef0d lib/core/settings.py 4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py 10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py 10d7e4f7ba2502cce5cf69223c52eddc lib/core/target.py @@ -73,7 +73,7 @@ e4ea70bcd461f5176867dcd89d372386 lib/request/basicauthhandler.py bd4b654767eab19cd4dcd4520a68eed5 lib/request/basic.py caa52d249fbcf1705cd9208b84d93387 lib/request/chunkedhandler.py fc25d951217077fe655ed2a3a81552ae lib/request/comparison.py -ea6610ed5557f263cb7a6075732461ce lib/request/connect.py +ff54b009d9aaa8199888615dacaf0c43 lib/request/connect.py 43005bd6a78e9cf0f3ed2283a1cb122e lib/request/direct.py 2b7509ba38a667c61cefff036ec4ca6f lib/request/dns.py ceac6b3bf1f726f8ff43c6814e9d7281 lib/request/httpshandler.py