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

Skip to content

Commit 9ef79df

Browse files
committed
Cleaning up cases with Set-Cookie (conf.cj is handling it automatically; also, default redirector needed to be patched)
1 parent aa59266 commit 9ef79df

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

lib/core/option.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,6 @@ def _setKnowledgeBaseAttributes(flushAll=True):
16201620
kb.proxyAuthHeader = None
16211621
kb.queryCounter = 0
16221622
kb.redirectChoice = None
1623-
kb.redirectSetCookie = None
16241623
kb.reflectiveMechanism = True
16251624
kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0}
16261625
kb.requestCounter = 0

lib/request/basic.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ def forgeHeaders(items=None):
8282
if kb.testMode:
8383
resetCookieJar(conf.cj)
8484

85-
if kb.redirectSetCookie and not conf.dropSetCookie:
86-
if HTTPHEADER.COOKIE in headers:
87-
headers[HTTPHEADER.COOKIE] += "%s %s" % (DEFAULT_COOKIE_DELIMITER, kb.redirectSetCookie)
88-
else:
89-
headers[HTTPHEADER.COOKIE] = kb.redirectSetCookie
90-
9185
return headers
9286

9387
def parseResponse(page, headers):

lib/request/redirecthandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from lib.core.enums import HTTPMETHOD
2020
from lib.core.enums import REDIRECTION
2121
from lib.core.exception import SqlmapConnectionException
22+
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
2223
from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE
2324
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
2425
from lib.core.settings import MAX_SINGLE_URL_REDIRECTIONS
@@ -110,13 +111,12 @@ def http_error_302(self, req, fp, code, msg, headers):
110111

111112
if redurl and kb.redirectChoice == REDIRECTION.YES:
112113
req.headers[HTTPHEADER.HOST] = getHostHeader(redurl)
114+
if headers and HTTPHEADER.SET_COOKIE in headers:
115+
req.headers[HTTPHEADER.COOKIE] = headers[HTTPHEADER.SET_COOKIE].split(DEFAULT_COOKIE_DELIMITER)[0]
113116
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
114117
else:
115118
result = fp
116119

117-
if HTTPHEADER.SET_COOKIE in headers:
118-
kb.redirectSetCookie = headers.get(HTTPHEADER.SET_COOKIE).split("; path")[0]
119-
120120
result.redcode = code
121121
result.redurl = redurl
122122

0 commit comments

Comments
 (0)