diff --git a/lib/core/settings.py b/lib/core/settings.py index 72882e733..b91609851 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.10.11.67" +VERSION = "1.10.11.68" 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 30088b480..2cbdb7982 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -745,11 +745,26 @@ class Connect(object): except ValueError: raise SqlmapMissingDependence("native HTTP/2 client does not support SOCKS proxies (omit '--http2' or use an HTTP proxy)") + # Note: cookie jar handling (i.e. Set-Cookie), as urllib's HTTPCookieProcessor is bypassed + if conf.cj is not None and HTTP_HEADER.COOKIE not in headers: + try: + conf.cj.add_cookie_header(req) + if req.get_header(HTTP_HEADER.COOKIE): + headers[HTTP_HEADER.COOKIE] = req.get_header(HTTP_HEADER.COOKIE) + except Exception as ex: + logger.debug("problem occurred while adding HTTP/2 cookies ('%s')" % getSafeExString(ex)) + try: conn = http2OpenUrl(url, method or (HTTPMETHOD.POST if post is not None else HTTPMETHOD.GET), headers, post, timeout, follow_redirects=kb.choices.redirect != REDIRECTION.NO and not conf.ignoreRedirects, proxy=h2proxy, sensitive_headers=tuple(kb.authRefreshHeaders) if conf.authRefresh else ()) except IOError as ex: raise _http_client.HTTPException(getSafeExString(ex)) else: + if conf.cj is not None: + try: + conf.cj.extract_cookies(conn, req) + except Exception as ex: + logger.debug("problem occurred while storing HTTP/2 cookies ('%s')" % getSafeExString(ex)) + if conn.code >= 400: raise _urllib.error.HTTPError(conn.geturl(), conn.code, conn.msg, conn.info(), io.BytesIO(conn.read())) diff --git a/lib/request/http2.py b/lib/request/http2.py index fc8ba0fd7..491809a46 100644 --- a/lib/request/http2.py +++ b/lib/request/http2.py @@ -1496,6 +1496,7 @@ class H2Response(object): if not name.startswith(":"): self._info[name] = value self._info.headers = ["%s: %s\r\n" % item for item in self._info.items()] + self._info.getheaders = lambda name: self._info.get_all(name) or [] # Note: Python 2 cookielib's interface (e.g. for Set-Cookie) def info(self): return self._info