Skip to content

Commit 121f037

Browse files
committed
Implementation for sqlmapproject#2351
1 parent dfc6846 commit 121f037

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

lib/core/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class HTTP_HEADER:
176176
PROXY_CONNECTION = "Proxy-Connection"
177177
RANGE = "Range"
178178
REFERER = "Referer"
179+
REFRESH = "Refresh" # Reference: http://stackoverflow.com/a/283794
179180
SERVER = "Server"
180181
SET_COOKIE = "Set-Cookie"
181182
TRANSFER_ENCODING = "Transfer-Encoding"

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.1.1.8"
22+
VERSION = "1.1.1.9"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/request/connect.py

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ class _(dict):
475475
return conn, None, None
476476

477477
# Get HTTP response
478-
if hasattr(conn, 'redurl'):
478+
if hasattr(conn, "redurl"):
479479
page = (threadData.lastRedirectMsg[1] if kb.redirectChoice == REDIRECTION.NO\
480480
else Connect._connReadProxy(conn)) if not skipRead else None
481481
skipLogTraffic = kb.redirectChoice == REDIRECTION.NO
@@ -491,37 +491,41 @@ class _(dict):
491491

492492
kb.connErrorCounter = 0
493493

494-
if extractRegexResult(META_REFRESH_REGEX, page) and not refreshing:
495-
refresh = extractRegexResult(META_REFRESH_REGEX, page)
494+
if not refreshing:
495+
refresh = headers.get(HTTP_HEADER.REFRESH)
496496

497-
debugMsg = "got HTML meta refresh header"
498-
logger.debug(debugMsg)
499-
500-
if kb.alwaysRefresh is None:
501-
msg = "sqlmap got a refresh request "
502-
msg += "(redirect like response common to login pages). "
503-
msg += "Do you want to apply the refresh "
504-
msg += "from now on (or stay on the original page)? [Y/n]"
505-
choice = readInput(msg, default="Y")
497+
if extractRegexResult(META_REFRESH_REGEX, page):
498+
refresh = extractRegexResult(META_REFRESH_REGEX, page)
506499

507-
kb.alwaysRefresh = choice not in ("n", "N")
500+
debugMsg = "got HTML meta refresh header"
501+
logger.debug(debugMsg)
508502

509-
if kb.alwaysRefresh:
510-
if re.search(r"\Ahttps?://", refresh, re.I):
511-
url = refresh
512-
else:
513-
url = urlparse.urljoin(url, refresh)
503+
if refresh:
504+
if kb.alwaysRefresh is None:
505+
msg = "sqlmap got a refresh request "
506+
msg += "(redirect like response common to login pages). "
507+
msg += "Do you want to apply the refresh "
508+
msg += "from now on (or stay on the original page)? [Y/n]"
509+
choice = readInput(msg, default="Y")
514510

515-
threadData.lastRedirectMsg = (threadData.lastRequestUID, page)
516-
kwargs['refreshing'] = True
517-
kwargs['url'] = url
518-
kwargs['get'] = None
519-
kwargs['post'] = None
511+
kb.alwaysRefresh = choice not in ("n", "N")
520512

521-
try:
522-
return Connect._getPageProxy(**kwargs)
523-
except SqlmapSyntaxException:
524-
pass
513+
if kb.alwaysRefresh:
514+
if re.search(r"\Ahttps?://", refresh, re.I):
515+
url = refresh
516+
else:
517+
url = urlparse.urljoin(url, refresh)
518+
519+
threadData.lastRedirectMsg = (threadData.lastRequestUID, page)
520+
kwargs["refreshing"] = True
521+
kwargs["url"] = url
522+
kwargs["get"] = None
523+
kwargs["post"] = None
524+
525+
try:
526+
return Connect._getPageProxy(**kwargs)
527+
except SqlmapSyntaxException:
528+
pass
525529

526530
# Explicit closing of connection object
527531
if conn and not conf.keepAlive:

txt/checksum.md5

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ a8143dab9d3a27490f7d49b6b29ea530 lib/core/data.py
3434
47eecd5499eaa15e931793e1d1ac3566 lib/core/defaults.py
3535
4029f6869b36eb5f796c2bcc948f4fae lib/core/dicts.py
3636
77edcfd3d7c5522bb64baf59ac23a047 lib/core/dump.py
37-
0c0f18761e9bb61d289bfa884dcd7dbd lib/core/enums.py
37+
18554d2eafd721a2b92dcfd202b9a0ab lib/core/enums.py
3838
9381a0c7e8bc19986299e84f4edda1a0 lib/core/exception.py
3939
310efc965c862cfbd7b0da5150a5ad36 lib/core/__init__.py
4040
9ba39bf66e9ecd469446bdbbeda906c3 lib/core/log.py
@@ -45,7 +45,7 @@ e544108e2238d756c94a240e8a1ce061 lib/core/optiondict.py
4545
d8e9250f3775119df07e9070eddccd16 lib/core/replication.py
4646
785f86e3f963fa3798f84286a4e83ff2 lib/core/revision.py
4747
40c80b28b3a5819b737a5a17d4565ae9 lib/core/session.py
48-
28f22f49a65ab96922496c2bdd36ee8f lib/core/settings.py
48+
d943f8318b1adbd51c7859d04d0b6eda lib/core/settings.py
4949
d91291997d2bd2f6028aaf371bf1d3b6 lib/core/shell.py
5050
2ad85c130cc5f2b3701ea85c2f6bbf20 lib/core/subprocessng.py
5151
afd0636d2e93c23f4f0a5c9b6023ea17 lib/core/target.py
@@ -67,7 +67,7 @@ a0444cc351cd6d29015ad16d9eb46ff4 lib/parse/sitemap.py
6767
403d873f1d2fd0c7f73d83f104e41850 lib/request/basicauthhandler.py
6868
6d04ee525e75bf0082e9f1f6d8506546 lib/request/basic.py
6969
4e89d0e13de2eb3576f5412b21e9b648 lib/request/comparison.py
70-
30d7b0df341762c5aa7aab537878ce05 lib/request/connect.py
70+
745fb024ccea7d13c36e83aecedf28a9 lib/request/connect.py
7171
fb6b788d0016ab4ec5e5f661f0f702ad lib/request/direct.py
7272
cc1163d38e9b7ee5db2adac6784c02bb lib/request/dns.py
7373
5dcdb37823a0b5eff65cd1018bcf09e4 lib/request/httpshandler.py

0 commit comments

Comments
 (0)