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

Skip to content

Commit 1061c06

Browse files
committed
improvement of redirecting code
1 parent e183437 commit 1061c06

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

lib/request/connect.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def getPage(**kwargs):
153153
# url splitted with space char while urlencoding it in the later phase
154154
url = url.replace(" ", "%20")
155155

156-
page = ""
156+
page = None
157157
cookieStr = ""
158158
requestMsg = "HTTP request [#%d]:\n%s " % (threadData.lastRequestUID, method or (HTTPMETHOD.POST if post else HTTPMETHOD.GET))
159159
requestMsg += "%s" % urlparse.urlsplit(url)[2] or "/"
@@ -304,21 +304,25 @@ def getPage(**kwargs):
304304
if kb.alwaysRedirect is None:
305305
msg = "sqlmap got a %d redirect to " % conn.redcode
306306
msg += "'%s'. Do you want to follow redirects " % conn.redurl
307-
msg += "from now on (or stay on the original page)? [Y/n]"
307+
msg += "from now on (or stay on the original page otherwise)? [Y/n]"
308308
choice = readInput(msg, default="Y")
309309

310310
kb.alwaysRedirect = choice not in ("n", "N")
311311

312-
kwargs['url'] = conn.redurl if kb.alwaysRedirect else conf.url
313-
kwargs['redirecting'] = conn.redcode
314-
return Connect.__getPageProxy(**kwargs)
312+
if kb.alwaysRedirect:
313+
kwargs['url'] = conn.redurl
314+
kwargs['redirecting'] = conn.redcode
315+
return Connect.__getPageProxy(**kwargs)
316+
else:
317+
redirecting = conn.redcode
318+
page = threadData.lastRedirectMsg[1]
315319

316320
# Return response object
317321
if response:
318322
return conn, None, None
319323

320324
# Get HTTP response
321-
page = conn.read()
325+
page = conn.read() if page is None else page
322326
code = redirecting or conn.code
323327
responseHeaders = conn.info()
324328
responseHeaders[URI_HTTP_HEADER] = conn.geturl()

0 commit comments

Comments
 (0)