diff --git a/lib/core/common.py b/lib/core/common.py index 8b6e0f52f..780b8328e 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -4692,7 +4692,7 @@ def getRequestHeader(request, name): if request and request.headers and name: _ = name.upper() - retVal = max(value if _ == key.upper() else "" for key, value in request.header_items()) or None + retVal = max(value if _ == key.upper() else type(value)() for key, value in request.header_items()) or None return retVal diff --git a/lib/core/settings.py b/lib/core/settings.py index 248e72eb3..bc868de22 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.3.5.43" +VERSION = "1.3.5.44" 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/thirdparty/keepalive/keepalive.py b/thirdparty/keepalive/keepalive.py index 784925523..25eda69b1 100644 --- a/thirdparty/keepalive/keepalive.py +++ b/thirdparty/keepalive/keepalive.py @@ -135,7 +135,7 @@ class ConnectionManager: def add(self, host, connection, ready): self._lock.acquire() try: - if not self._hostmap.has_key(host): self._hostmap[host] = [] + if host not in self._hostmap: self._hostmap[host] = [] self._hostmap[host].append(connection) self._connmap[connection] = host self._readymap[connection] = ready @@ -165,7 +165,7 @@ class ConnectionManager: conn = None self._lock.acquire() try: - if self._hostmap.has_key(host): + if host in self._hostmap: for c in self._hostmap[host]: if self._readymap[c]: self._readymap[c] = 0 @@ -312,16 +312,16 @@ class KeepAliveHandler: def _start_transaction(self, h, req): try: - if req.has_data(): + if req.data: data = req.data if hasattr(req, 'selector'): h.putrequest(req.get_method() or 'POST', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) else: h.putrequest(req.get_method() or 'POST', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) - if not req.headers.has_key('Content-type'): + if 'Content-type' not in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') - if not req.headers.has_key('Content-length'): + if 'Content-length' not in req.headers: h.putheader('Content-length', '%d' % len(data)) else: if hasattr(req, 'selector'): @@ -331,16 +331,16 @@ class KeepAliveHandler: except (socket.error, _http_client.HTTPException) as err: raise _urllib.error.URLError(err) - if not req.headers.has_key('Connection'): + if 'Connection' not in req.headers: req.headers['Connection'] = 'keep-alive' for args in self.parent.addheaders: - if not req.headers.has_key(args[0]): + if args[0] not in req.headers: h.putheader(*args) for k, v in req.headers.items(): h.putheader(k, v) h.endheaders() - if req.has_data(): + if req.data: h.send(data) def _get_connection(self, host): @@ -419,6 +419,10 @@ class HTTPResponse(_http_client.HTTPResponse): self._handler._request_closed(self, self._host, self._connection) + # Note: Patch for Python3 (otherwise, connections won't be reusable) + def _close_conn(self): + self.close() + def close_connection(self): self._handler._remove_connection(self._host, self._connection, close=1) self.close()