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

Skip to content

Commit 360d89c

Browse files
committed
Critical bug patch for --crawl/--forms (introduced last week)
1 parent abe31c1 commit 360d89c

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

lib/core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.11.16"
21+
VERSION = "1.3.11.17"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -362,6 +362,9 @@
362362
# Regular expression used for parsing refresh info from meta html headers
363363
META_REFRESH_REGEX = r'(?si)<head>(?!.*?<noscript.*?</head).*?<meta http-equiv="?refresh"?[^>]+content="?[^">]+url=["\']?(?P<result>[^\'">]+).*</head>'
364364

365+
# Regular expression used for parsing Javascript redirect request
366+
JAVASCRIPT_HREF_REGEX = r'<script>\s*(\w+\.)?location\.href\s*=["\'](?P<result>[^"\']+)'
367+
365368
# Regular expression used for parsing empty fields in tested form data
366369
EMPTY_FORM_FIELDS_REGEX = r'(&|\A)(?P<result>[^=]+=(&|\Z))'
367370

lib/request/connect.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class WebSocketException(Exception):
9898
from lib.core.settings import HTTP_ACCEPT_HEADER_VALUE
9999
from lib.core.settings import IPS_WAF_CHECK_PAYLOAD
100100
from lib.core.settings import IS_WIN
101+
from lib.core.settings import JAVASCRIPT_HREF_REGEX
101102
from lib.core.settings import LARGE_READ_TRIM_MARKER
102103
from lib.core.settings import MAX_CONNECTION_READ_SIZE
103104
from lib.core.settings import MAX_CONNECTIONS_REGEX
@@ -563,10 +564,16 @@ class _(dict):
563564
debugMsg = "got HTML meta refresh header"
564565
logger.debug(debugMsg)
565566

567+
if not refresh:
568+
refresh = extractRegexResult(JAVASCRIPT_HREF_REGEX, page)
569+
570+
debugMsg = "got Javascript redirect request"
571+
logger.debug(debugMsg)
572+
566573
if refresh:
567574
if kb.alwaysRefresh is None:
568575
msg = "got a refresh request "
569-
msg += "(redirect like response common to login pages). "
576+
msg += "(redirect like response common to login pages) to '%s'. " % refresh
570577
msg += "Do you want to apply the refresh "
571578
msg += "from now on (or stay on the original page)? [Y/n]"
572579

lib/utils/crawler.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from lib.core.data import kb
2929
from lib.core.data import logger
3030
from lib.core.datatype import OrderedSet
31+
from lib.core.enums import HTTPMETHOD
3132
from lib.core.enums import MKSTEMP_PREFIX
3233
from lib.core.exception import SqlmapConnectionException
3334
from lib.core.exception import SqlmapSyntaxException
@@ -116,7 +117,7 @@ def crawlThread():
116117
if (extractRegexResult(r"\A[^?]+\.(?P<result>\w+)(\?|\Z)", url) or "").lower() not in CRAWL_EXCLUDE_EXTENSIONS:
117118
with kb.locks.value:
118119
threadData.shared.deeper.add(url)
119-
if re.search(r"(.*?)\?(.+)", url):
120+
if re.search(r"(.*?)\?(.+)", url) and not re.search(r"\?\d+\Z", url):
120121
threadData.shared.value.add(url)
121122
except UnicodeEncodeError: # for non-HTML files
122123
pass
@@ -211,12 +212,15 @@ def crawlThread():
211212
results = OrderedSet()
212213

213214
for target in kb.targets:
214-
match = re.search(r"/[^/?]*\?.*\Z", target[0])
215-
if match:
216-
key = re.sub(r"=[^=&]*", "=", match.group(0))
217-
if key not in seen:
218-
results.add(target)
219-
seen.add(key)
215+
if target[1] == HTTPMETHOD.GET:
216+
match = re.search(r"/[^/?]*\?.*\Z", target[0])
217+
if match:
218+
key = re.sub(r"=[^=&]*", "=", match.group(0))
219+
if key not in seen:
220+
results.add(target)
221+
seen.add(key)
222+
else:
223+
results.add(target)
220224

221225
kb.targets = results
222226

0 commit comments

Comments
 (0)