mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 17:46:37 +03:00
some fixes here and there
This commit is contained in:
parent
3d9b1599d1
commit
3d39c6cb3b
|
@ -48,7 +48,7 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
|||
|
||||
kb.redirectChoice = choice
|
||||
|
||||
def _process_http_redirect(self, result, headers, code, content, msg):
|
||||
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()
|
||||
|
@ -68,47 +68,21 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
|||
|
||||
logger.log(7, responseMsg)
|
||||
|
||||
if self._get_header_redirect(headers):
|
||||
result.redurl = self._get_header_redirect(headers)
|
||||
|
||||
if not urlparse.urlsplit(result.redurl).netloc:
|
||||
result.redurl = urlparse.urljoin(conf.url, result.redurl)
|
||||
|
||||
if "set-cookie" in headers:
|
||||
kb.redirectSetCookie = headers["set-cookie"].split("; path")[0]
|
||||
|
||||
result.redcode = code
|
||||
result.redurl = redurl
|
||||
|
||||
return result
|
||||
|
||||
def http_error_301(self, req, fp, code, msg, headers):
|
||||
content = None, None
|
||||
redurl = self._get_header_redirect(headers)
|
||||
|
||||
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:
|
||||
req.headers[HTTPHEADER.HOST] = getHostHeader(redurl)
|
||||
|
||||
if kb.redirectChoice == REDIRECTION.FOLLOW:
|
||||
result = urllib2.HTTPRedirectHandler.http_error_301(self, req, fp, code, msg, headers)
|
||||
else:
|
||||
result = fp
|
||||
|
||||
return self._process_http_redirect(result, headers, code, content, msg)
|
||||
|
||||
def http_error_302(self, req, fp, code, msg, headers):
|
||||
content = None, None
|
||||
content = None
|
||||
redurl = self._get_header_redirect(headers)
|
||||
|
||||
if not urlparse.urlsplit(redurl).netloc:
|
||||
redurl = urlparse.urljoin(conf.url, redurl)
|
||||
|
||||
self._infinite_loop_check(req)
|
||||
self._ask_redirect_choice(code, redurl)
|
||||
|
||||
|
@ -119,15 +93,15 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
|
|||
dbgMsg += "redirect response content (%s)" % msg
|
||||
logger.debug(dbgMsg)
|
||||
|
||||
if redurl:
|
||||
req.headers[HTTPHEADER.HOST] = getHostHeader(redurl)
|
||||
|
||||
if kb.redirectChoice == REDIRECTION.FOLLOW:
|
||||
req.headers[HTTPHEADER.HOST] = getHostHeader(redurl)
|
||||
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
|
||||
else:
|
||||
result = fp
|
||||
|
||||
return self._process_http_redirect(result, headers, code, content, msg)
|
||||
return self._process_http_redirect(result, headers, code, content, msg, redurl)
|
||||
|
||||
http_error_301 = http_error_303 = http_error_307 = http_error_302
|
||||
|
||||
def _infinite_loop_check(self, req):
|
||||
if hasattr(req, 'redirect_dict') and (req.redirect_dict.get(req.get_full_url(), 0) >= MAX_SINGLE_URL_REDIRECTIONS or len(req.redirect_dict) >= MAX_TOTAL_REDIRECTIONS):
|
||||
|
|
Loading…
Reference in New Issue
Block a user