From fccad15cfa763940ce7c16913752994a5f4ad449 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 7 Dec 2012 12:14:33 +0100 Subject: [PATCH] Minor update for an Issue #288 --- lib/request/redirecthandler.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/request/redirecthandler.py b/lib/request/redirecthandler.py index 16142c7c2..b40a168b1 100644 --- a/lib/request/redirecthandler.py +++ b/lib/request/redirecthandler.py @@ -18,6 +18,7 @@ from lib.core.enums import CUSTOM_LOGGING from lib.core.enums import HTTPHEADER from lib.core.enums import REDIRECTION from lib.core.exception import SqlmapConnectionException +from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE from lib.core.settings import MAX_SINGLE_URL_REDIRECTIONS from lib.core.settings import MAX_TOTAL_REDIRECTIONS from lib.core.threads import getCurrentThreadData @@ -75,6 +76,13 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): content = None redurl = self._get_header_redirect(headers) + try: + content = fp.read() + except Exception, msg: + dbgMsg = "there was a problem while retrieving " + dbgMsg += "redirect response content (%s)" % msg + logger.debug(dbgMsg) + threadData = getCurrentThreadData() redirectMsg = "HTTP redirect " redirectMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, getUnicode(msg)) @@ -84,7 +92,9 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): else: logHeaders = "" - redirectMsg += getUnicode(logHeaders) + redirectMsg += "%s\n" % logHeaders + if content: + redirectMsg += "\n%s" % content[:MAX_CONNECTION_CHUNK_SIZE] logger.log(CUSTOM_LOGGING.TRAFFIC_IN, redirectMsg) @@ -95,13 +105,6 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): self._infinite_loop_check(req) self._ask_redirect_choice(code, redurl) - try: - content = fp.read() - except Exception, msg: - dbgMsg = "there was a problem while retrieving " - dbgMsg += "redirect response content (%s)" % msg - logger.debug(dbgMsg) - if redurl and kb.redirectChoice == REDIRECTION.YES: req.headers[HTTPHEADER.HOST] = getHostHeader(redurl) result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)