diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 55b00bd74..ae1b9f423 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -1114,6 +1114,9 @@ def checkNullConnection(): infoMsg = "testing NULL connection to the target URL" logger.info(infoMsg) + pushValue(kb.pageCompress) + kb.pageCompress = False + try: page, headers, _ = Request.getPage(method=HTTPMETHOD.HEAD) @@ -1144,6 +1147,8 @@ def checkNullConnection(): errMsg = getUnicode(errMsg) raise SqlmapConnectionException(errMsg) + kb.pageCompress = popValue() + return kb.nullConnection is not None def checkConnection(suppressOutput=False): diff --git a/lib/request/connect.py b/lib/request/connect.py index 5cb77ebfa..f8a4efe85 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -30,6 +30,8 @@ from lib.core.common import getHostHeader from lib.core.common import getRequestHeader from lib.core.common import getUnicode from lib.core.common import logHTTPTraffic +from lib.core.common import pushValue +from lib.core.common import popValue from lib.core.common import randomizeParameterValue from lib.core.common import randomInt from lib.core.common import randomStr @@ -311,7 +313,7 @@ class Connect(object): headers[HTTP_HEADER.PROXY_AUTHORIZATION] = kb.proxyAuthHeader headers[HTTP_HEADER.ACCEPT] = HTTP_ACCEPT_HEADER_VALUE - headers[HTTP_HEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if method != HTTPMETHOD.HEAD and kb.pageCompress else "identity" + headers[HTTP_HEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if kb.pageCompress else "identity" headers[HTTP_HEADER.HOST] = host or getHostHeader(url) if post is not None and HTTP_HEADER.CONTENT_TYPE not in headers: @@ -813,6 +815,9 @@ class Connect(object): if kb.nullConnection and not content and not response and not timeBasedCompare: noteResponseTime = False + pushValue(kb.pageCompress) + kb.pageCompress = False + if kb.nullConnection == NULLCONNECTION.HEAD: method = HTTPMETHOD.HEAD elif kb.nullConnection == NULLCONNECTION.RANGE: @@ -829,6 +834,8 @@ class Connect(object): elif kb.nullConnection == NULLCONNECTION.RANGE and HTTP_HEADER.CONTENT_RANGE in headers: pageLength = int(headers[HTTP_HEADER.CONTENT_RANGE][headers[HTTP_HEADER.CONTENT_RANGE].find('/') + 1:]) + kb.pageCompress = popValue() + if not pageLength: try: page, headers, code = Connect.getPage(url=uri, get=get, post=post, cookie=cookie, ua=ua, referer=referer, host=host, silent=silent, method=method, auxHeaders=auxHeaders, response=response, raise404=raise404, ignoreTimeout=timeBasedCompare)