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

Skip to content

Commit fccad15

Browse files
committed
Minor update for an Issue #288
1 parent 75e6d77 commit fccad15

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

lib/request/redirecthandler.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from lib.core.enums import HTTPHEADER
1919
from lib.core.enums import REDIRECTION
2020
from lib.core.exception import SqlmapConnectionException
21+
from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE
2122
from lib.core.settings import MAX_SINGLE_URL_REDIRECTIONS
2223
from lib.core.settings import MAX_TOTAL_REDIRECTIONS
2324
from lib.core.threads import getCurrentThreadData
@@ -75,6 +76,13 @@ def http_error_302(self, req, fp, code, msg, headers):
7576
content = None
7677
redurl = self._get_header_redirect(headers)
7778

79+
try:
80+
content = fp.read()
81+
except Exception, msg:
82+
dbgMsg = "there was a problem while retrieving "
83+
dbgMsg += "redirect response content (%s)" % msg
84+
logger.debug(dbgMsg)
85+
7886
threadData = getCurrentThreadData()
7987
redirectMsg = "HTTP redirect "
8088
redirectMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, getUnicode(msg))
@@ -84,7 +92,9 @@ def http_error_302(self, req, fp, code, msg, headers):
8492
else:
8593
logHeaders = ""
8694

87-
redirectMsg += getUnicode(logHeaders)
95+
redirectMsg += "%s\n" % logHeaders
96+
if content:
97+
redirectMsg += "\n%s" % content[:MAX_CONNECTION_CHUNK_SIZE]
8898

8999
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, redirectMsg)
90100

@@ -95,13 +105,6 @@ def http_error_302(self, req, fp, code, msg, headers):
95105
self._infinite_loop_check(req)
96106
self._ask_redirect_choice(code, redurl)
97107

98-
try:
99-
content = fp.read()
100-
except Exception, msg:
101-
dbgMsg = "there was a problem while retrieving "
102-
dbgMsg += "redirect response content (%s)" % msg
103-
logger.debug(dbgMsg)
104-
105108
if redurl and kb.redirectChoice == REDIRECTION.YES:
106109
req.headers[HTTPHEADER.HOST] = getHostHeader(redurl)
107110
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)

0 commit comments

Comments
 (0)