mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-03 05:04:11 +03:00
Removing redundant code in redirect handler (related to an Issue #288)
This commit is contained in:
parent
fccad15cfa
commit
e129a30e6b
|
@ -44,34 +44,6 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
||||||
|
|
||||||
kb.redirectChoice = choice.upper()
|
kb.redirectChoice = choice.upper()
|
||||||
|
|
||||||
def _process_http_redirect(self, result, headers, code, content, msg, redurl):
|
|
||||||
content = decodePage(content, headers.get(HTTPHEADER.CONTENT_ENCODING), headers.get(HTTPHEADER.CONTENT_TYPE))
|
|
||||||
|
|
||||||
threadData = getCurrentThreadData()
|
|
||||||
threadData.lastRedirectMsg = (threadData.lastRequestUID, content)
|
|
||||||
|
|
||||||
responseMsg = "HTTP response "
|
|
||||||
responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, getUnicode(msg))
|
|
||||||
|
|
||||||
if headers:
|
|
||||||
logHeaders = "\n".join("%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in headers.items())
|
|
||||||
else:
|
|
||||||
logHeaders = ""
|
|
||||||
|
|
||||||
logHTTPTraffic(threadData.lastRequestMsg, "%s%s" % (responseMsg, logHeaders))
|
|
||||||
|
|
||||||
responseMsg += getUnicode(logHeaders)
|
|
||||||
|
|
||||||
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
|
|
||||||
|
|
||||||
if "set-cookie" in headers:
|
|
||||||
kb.redirectSetCookie = headers["set-cookie"].split("; path")[0]
|
|
||||||
|
|
||||||
result.redcode = code
|
|
||||||
result.redurl = redurl
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def http_error_302(self, req, fp, code, msg, headers):
|
def http_error_302(self, req, fp, code, msg, headers):
|
||||||
content = None
|
content = None
|
||||||
redurl = self._get_header_redirect(headers)
|
redurl = self._get_header_redirect(headers)
|
||||||
|
@ -83,7 +55,11 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
||||||
dbgMsg += "redirect response content (%s)" % msg
|
dbgMsg += "redirect response content (%s)" % msg
|
||||||
logger.debug(dbgMsg)
|
logger.debug(dbgMsg)
|
||||||
|
|
||||||
|
content = decodePage(content, headers.get(HTTPHEADER.CONTENT_ENCODING), headers.get(HTTPHEADER.CONTENT_TYPE))
|
||||||
|
|
||||||
threadData = getCurrentThreadData()
|
threadData = getCurrentThreadData()
|
||||||
|
threadData.lastRedirectMsg = (threadData.lastRequestUID, content)
|
||||||
|
|
||||||
redirectMsg = "HTTP redirect "
|
redirectMsg = "HTTP redirect "
|
||||||
redirectMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, getUnicode(msg))
|
redirectMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, getUnicode(msg))
|
||||||
|
|
||||||
|
@ -92,10 +68,11 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
||||||
else:
|
else:
|
||||||
logHeaders = ""
|
logHeaders = ""
|
||||||
|
|
||||||
redirectMsg += "%s\n" % logHeaders
|
redirectMsg += logHeaders
|
||||||
if content:
|
if content:
|
||||||
redirectMsg += "\n%s" % content[:MAX_CONNECTION_CHUNK_SIZE]
|
redirectMsg += "\n\n%s" % content[:MAX_CONNECTION_CHUNK_SIZE]
|
||||||
|
|
||||||
|
logHTTPTraffic(threadData.lastRequestMsg, redirectMsg)
|
||||||
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, redirectMsg)
|
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, redirectMsg)
|
||||||
|
|
||||||
if redurl:
|
if redurl:
|
||||||
|
@ -111,7 +88,13 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
||||||
else:
|
else:
|
||||||
result = fp
|
result = fp
|
||||||
|
|
||||||
return self._process_http_redirect(result, headers, code, content, msg, redurl)
|
if HTTPHEADER.SET_COOKIE in headers:
|
||||||
|
kb.redirectSetCookie = headers.get(HTTPHEADER.SET_COOKIE).split("; path")[0]
|
||||||
|
|
||||||
|
result.redcode = code
|
||||||
|
result.redurl = redurl
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
http_error_301 = http_error_303 = http_error_307 = http_error_302
|
http_error_301 = http_error_303 = http_error_307 = http_error_302
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user