mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-04 06:50:14 +00:00
Further improving Set-Cookie logic in redirections
This commit is contained in:
parent
249d2a6cbb
commit
195c4bec34
3 changed files with 10 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.6.29"
|
||||
VERSION = "1.10.6.30"
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class SmartRedirectHandler(_urllib.request.HTTPRedirectHandler):
|
|||
delimiter = conf.cookieDel or DEFAULT_COOKIE_DELIMITER
|
||||
last = None
|
||||
|
||||
for part in getUnicode(req.headers.get(HTTP_HEADER.COOKIE, "")).split(delimiter) + ([headers[HTTP_HEADER.SET_COOKIE].split(';')[0]] if HTTP_HEADER.SET_COOKIE in headers else []):
|
||||
for part in getUnicode(req.headers.get(HTTP_HEADER.COOKIE, "")).split(delimiter):
|
||||
if '=' in part:
|
||||
part = part.strip()
|
||||
key, value = part.split('=', 1)
|
||||
|
|
@ -145,6 +145,12 @@ class SmartRedirectHandler(_urllib.request.HTTPRedirectHandler):
|
|||
elif last:
|
||||
cookies[last] += "%s%s" % (delimiter, part)
|
||||
|
||||
if HTTP_HEADER.SET_COOKIE in headers:
|
||||
for match in re.finditer(r"(?:^|,\s*)([^=;,]+)=([^;,]+)", headers[HTTP_HEADER.SET_COOKIE]):
|
||||
key = match.group(1).strip()
|
||||
if key.lower() not in ("expires", "path", "domain", "max-age", "secure", "httponly", "samesite"):
|
||||
cookies[key] = match.group(2).strip()
|
||||
|
||||
req.headers[HTTP_HEADER.COOKIE] = delimiter.join("%s=%s" % (key, cookies[key]) for key in cookies)
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue