From 9ef79df23d3940b72f603854adbe5442c9e5443c Mon Sep 17 00:00:00 2001 From: stamparm Date: Thu, 28 Feb 2013 13:51:08 +0100 Subject: [PATCH] Cleaning up cases with Set-Cookie (conf.cj is handling it automatically; also, default redirector needed to be patched) --- lib/core/option.py | 1 - lib/request/basic.py | 6 ------ lib/request/redirecthandler.py | 6 +++--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index a24d5a8a7..08a561550 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1620,7 +1620,6 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.proxyAuthHeader = None kb.queryCounter = 0 kb.redirectChoice = None - kb.redirectSetCookie = None kb.reflectiveMechanism = True kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0} kb.requestCounter = 0 diff --git a/lib/request/basic.py b/lib/request/basic.py index f9e94857d..6eb3dbc31 100644 --- a/lib/request/basic.py +++ b/lib/request/basic.py @@ -82,12 +82,6 @@ def forgeHeaders(items=None): if kb.testMode: resetCookieJar(conf.cj) - if kb.redirectSetCookie and not conf.dropSetCookie: - if HTTPHEADER.COOKIE in headers: - headers[HTTPHEADER.COOKIE] += "%s %s" % (DEFAULT_COOKIE_DELIMITER, kb.redirectSetCookie) - else: - headers[HTTPHEADER.COOKIE] = kb.redirectSetCookie - return headers def parseResponse(page, headers): diff --git a/lib/request/redirecthandler.py b/lib/request/redirecthandler.py index 9ef6f9ffc..c6a382138 100644 --- a/lib/request/redirecthandler.py +++ b/lib/request/redirecthandler.py @@ -19,6 +19,7 @@ from lib.core.enums import HTTPHEADER from lib.core.enums import HTTPMETHOD from lib.core.enums import REDIRECTION from lib.core.exception import SqlmapConnectionException +from lib.core.settings import DEFAULT_COOKIE_DELIMITER from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE from lib.core.settings import MAX_SINGLE_URL_REDIRECTIONS @@ -110,13 +111,12 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): if redurl and kb.redirectChoice == REDIRECTION.YES: req.headers[HTTPHEADER.HOST] = getHostHeader(redurl) + if headers and HTTPHEADER.SET_COOKIE in headers: + req.headers[HTTPHEADER.COOKIE] = headers[HTTPHEADER.SET_COOKIE].split(DEFAULT_COOKIE_DELIMITER)[0] result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers) else: result = fp - if HTTPHEADER.SET_COOKIE in headers: - kb.redirectSetCookie = headers.get(HTTPHEADER.SET_COOKIE).split("; path")[0] - result.redcode = code result.redurl = redurl