Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d37df6

Browse files
committed
Ugly code to set the cookies when got them from a 302 redirect too
1 parent 9d55c4d commit 5d37df6

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ def __setKnowledgeBaseAttributes():
11841184
kb.unionFalseCond = False
11851185
kb.userAgents = None
11861186
kb.valueStack = []
1187+
kb.redirectSetCookie = None
11871188

11881189
def __saveCmdline():
11891190
"""

lib/request/basic.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def forgeHeaders(cookie, ua):
4040
else:
4141
headers[header] = value
4242

43+
if kb.redirectSetCookie:
44+
if "Cookie" in headers:
45+
headers["Cookie"] = "%s; %s" % (headers["Cookie"], kb.redirectSetCookie)
46+
else:
47+
headers["Cookie"] = kb.redirectSetCookie
48+
4349
return headers
4450

4551
def parseResponse(page, headers):

lib/request/connect.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ def getPage(**kwargs):
187187
if not kb.proxyAuthHeader and req.has_header("Proxy-authorization"):
188188
kb.proxyAuthHeader = req.get_header("Proxy-authorization")
189189

190+
if hasattr(conn, "setcookie"):
191+
kb.redirectSetCookie = conn.setcookie
192+
190193
if hasattr(conn, "redurl") and hasattr(conn, "redcode") and not conf.redirectHandled:
191194
msg = "sqlmap got a %d redirect to " % conn.redcode
192195
msg += "%s - What target address do you " % conn.redurl

lib/request/redirecthandler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def common_http_redirect(self, result, headers, code):
2626
elif "uri" in headers:
2727
result.redurl = headers.getheaders("uri")[0].split("?")[0]
2828

29+
if "set-cookie" in headers:
30+
result.setcookie = headers["set-cookie"].split("; path")[0]
31+
2932
result.redcode = code
3033

3134
return result

0 commit comments

Comments
 (0)