This commit is contained in:
Miroslav Stampar 2022-03-07 18:34:34 +01:00
parent 0b775b6d1d
commit a2fcab448c
3 changed files with 23 additions and 4 deletions

View File

@ -167,8 +167,27 @@ class WichmannHill(random.Random):
def patchHeaders(headers): def patchHeaders(headers):
if headers is not None and not hasattr(headers, "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] headers.headers = ["%s: %s\r\n" % (header, headers[header]) for header in headers]
return headers
def cmp(a, b): def cmp(a, b):
""" """
>>> cmp("a", "b") >>> cmp("a", "b")

View File

@ -20,7 +20,7 @@ from thirdparty import six
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.6.3.5" VERSION = "1.6.3.6"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -642,7 +642,7 @@ class Connect(object):
if hasattr(conn, "redurl"): if hasattr(conn, "redurl"):
responseHeaders[HTTP_HEADER.LOCATION] = conn.redurl responseHeaders[HTTP_HEADER.LOCATION] = conn.redurl
patchHeaders(responseHeaders) responseHeaders = patchHeaders(responseHeaders)
kb.serverHeader = responseHeaders.get(HTTP_HEADER.SERVER, kb.serverHeader) kb.serverHeader = responseHeaders.get(HTTP_HEADER.SERVER, kb.serverHeader)
else: else:
code = None code = None
@ -724,7 +724,7 @@ class Connect(object):
page = ex.read() if not skipRead else None page = ex.read() if not skipRead else None
responseHeaders = ex.info() responseHeaders = ex.info()
responseHeaders[URI_HTTP_HEADER] = ex.geturl() 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) page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE), percentDecode=not crawling)
except socket.timeout: except socket.timeout:
warnMsg = "connection timed out while trying " warnMsg = "connection timed out while trying "
@ -1535,7 +1535,7 @@ class Connect(object):
kb.permissionFlag = True kb.permissionFlag = True
singleTimeWarnMessage("potential permission problems detected ('%s')" % message) singleTimeWarnMessage("potential permission problems detected ('%s')" % message)
patchHeaders(headers) headers = patchHeaders(headers)
if content or response: if content or response:
return page, headers, code return page, headers, code