From a2fcab448c99ac5d79321e024810dce197c9238d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 7 Mar 2022 18:34:34 +0100 Subject: [PATCH] Fixes #5018 --- lib/core/compat.py | 19 +++++++++++++++++++ lib/core/settings.py | 2 +- lib/request/connect.py | 6 +++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/core/compat.py b/lib/core/compat.py index 8f2751f58..c1998109f 100644 --- a/lib/core/compat.py +++ b/lib/core/compat.py @@ -167,8 +167,27 @@ class WichmannHill(random.Random): def patchHeaders(headers): if headers is not None and not hasattr(headers, "headers"): + if isinstance(headers, dict): + class _(dict): + def __getitem__(self, key): + for key_ in self: + if key_.lower() == key.lower(): + return super(_, self).__getitem__(key_) + + raise KeyError(key) + + def get(self, key, default=None): + try: + return self[key] + except KeyError: + return default + + headers = _(headers) + headers.headers = ["%s: %s\r\n" % (header, headers[header]) for header in headers] + return headers + def cmp(a, b): """ >>> cmp("a", "b") diff --git a/lib/core/settings.py b/lib/core/settings.py index 7bb0d6438..488076d86 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from thirdparty import six from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.6.3.5" +VERSION = "1.6.3.6" 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 9b760d006..9f2a07f2f 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -642,7 +642,7 @@ class Connect(object): if hasattr(conn, "redurl"): responseHeaders[HTTP_HEADER.LOCATION] = conn.redurl - patchHeaders(responseHeaders) + responseHeaders = patchHeaders(responseHeaders) kb.serverHeader = responseHeaders.get(HTTP_HEADER.SERVER, kb.serverHeader) else: code = None @@ -724,7 +724,7 @@ class Connect(object): page = ex.read() if not skipRead else None responseHeaders = ex.info() responseHeaders[URI_HTTP_HEADER] = ex.geturl() - patchHeaders(responseHeaders) + responseHeaders = patchHeaders(responseHeaders) page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE), percentDecode=not crawling) except socket.timeout: warnMsg = "connection timed out while trying " @@ -1535,7 +1535,7 @@ class Connect(object): kb.permissionFlag = True singleTimeWarnMessage("potential permission problems detected ('%s')" % message) - patchHeaders(headers) + headers = patchHeaders(headers) if content or response: return page, headers, code