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

Skip to content

Commit 0fc4288

Browse files
committed
modifying redirection code for only two choices
1 parent c03d0e2 commit 0fc4288

5 files changed

Lines changed: 14 additions & 18 deletions

File tree

lib/controller/checks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def checkDynamicContent(firstPage, secondPage):
720720

721721
if count > conf.retries:
722722
warnMsg = "target url is too dynamic. "
723-
warnMsg += "switching to '--text-only' "
723+
warnMsg += "Switching to '--text-only' "
724724
logger.warn(warnMsg)
725725

726726
conf.textOnly = True
@@ -744,16 +744,16 @@ def checkStability():
744744
like for instance string matching (--string).
745745
"""
746746

747-
if kb.redirectChoice:
748-
return None
749-
750747
infoMsg = "testing if the url is stable, wait a few seconds"
751748
logger.info(infoMsg)
752749

753750
firstPage = kb.originalPage # set inside checkConnection()
754751
time.sleep(1)
755752
secondPage, _ = Request.queryPage(content=True, raise404=False)
756753

754+
if kb.redirectChoice:
755+
return None
756+
757757
kb.pageStable = (firstPage == secondPage)
758758

759759
if kb.pageStable:

lib/core/enums.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ class HASHDB_KEYS:
152152
KB_DYNAMIC_MARKINGS = "KB_DYNAMIC_MARKINGS"
153153

154154
class REDIRECTION:
155-
FOLLOW = "1"
156-
ORIGINAL = "2"
157-
IGNORE = "3"
155+
YES = "Y"
156+
NO = "N"
158157

159158
class PAYLOAD:
160159
SQLINJECTION = {

lib/request/comparison.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from lib.core.threads import getCurrentThreadData
3030

3131
def comparison(page, headers, code=None, getRatioValue=False, pageLength=None):
32+
print "AA: ", page[:100]
3233
if page is None and pageLength is None:
3334
return None
3435

lib/request/connect.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,10 @@ def getPage(**kwargs):
305305

306306
# Get HTTP response
307307
if hasattr(conn, 'redurl'):
308-
page = threadData.lastRedirectMsg[1] if kb.redirectChoice == REDIRECTION.IGNORE\
309-
else kb.pageTemplate if kb.redirectChoice == REDIRECTION.ORIGINAL\
308+
page = threadData.lastRedirectMsg[1] if kb.redirectChoice == REDIRECTION.NO\
310309
else conn.read()
311-
skipLogTraffic = kb.redirectChoice != REDIRECTION.FOLLOW
312-
code = conn.redcode if kb.redirectChoice != REDIRECTION.ORIGINAL else kb.originalCode
310+
skipLogTraffic = kb.redirectChoice == REDIRECTION.NO
311+
code = conn.redcode
313312
else:
314313
page = conn.read()
315314

lib/request/redirecthandler.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ def _get_header_redirect(self, headers):
4040
def _ask_redirect_choice(self, redcode, redurl):
4141
if kb.redirectChoice is None and kb.originalPage:
4242
msg = "sqlmap got a %d redirect to " % redcode
43-
msg += "'%s'. What do you want to do? " % redurl
44-
msg += "\n[1] Follow the redirection (default)"
45-
msg += "\n[2] Stay on the original page"
46-
msg += "\n[3] Ignore"
47-
choice = readInput(msg, default="1")
43+
msg += "'%s'. Do you want to follow? [Y/n] " % redurl
44+
choice = readInput(msg, default="Y")
4845

49-
kb.redirectChoice = choice
46+
kb.redirectChoice = choice.upper()
5047

5148
def _process_http_redirect(self, result, headers, code, content, msg, redurl):
5249
content = decodePage(content, headers.get(HTTPHEADER.CONTENT_ENCODING), headers.get(HTTPHEADER.CONTENT_TYPE))
@@ -93,7 +90,7 @@ def http_error_302(self, req, fp, code, msg, headers):
9390
dbgMsg += "redirect response content (%s)" % msg
9491
logger.debug(dbgMsg)
9592

96-
if kb.redirectChoice == REDIRECTION.FOLLOW or kb.originalPage is None:
93+
if kb.redirectChoice == REDIRECTION.YES or kb.originalPage is None:
9794
req.headers[HTTPHEADER.HOST] = getHostHeader(redurl)
9895
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
9996
else:

0 commit comments

Comments
 (0)