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

Skip to content

Commit f382443

Browse files
committed
Minor patch for crawling
1 parent e58d68c commit f382443

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,7 @@ def findMultipartPostBoundary(post):
27622762

27632763
return retVal
27642764

2765-
def urldecode(value, encoding=None, unsafe="%%&=;+%s" % CUSTOM_INJECTION_MARK_CHAR, convall=False, spaceplus=True):
2765+
def urldecode(value, encoding=None, unsafe="%%?&=;+%s" % CUSTOM_INJECTION_MARK_CHAR, convall=False, spaceplus=True):
27662766
"""
27672767
URL decodes given value
27682768

lib/core/settings.py

Lines changed: 1 addition & 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.32"
21+
VERSION = "1.3.11.33"
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)

lib/request/basic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def getHeuristicCharEncoding(page):
267267

268268
return retVal
269269

270-
def decodePage(page, contentEncoding, contentType):
270+
def decodePage(page, contentEncoding, contentType, percentDecode=True):
271271
"""
272272
Decode compressed/charset HTTP response
273273
@@ -340,8 +340,9 @@ def decodePage(page, contentEncoding, contentType):
340340
page = re.sub(b"&#(\\d{1,3});", lambda _: six.int2byte(int(_.group(1))) if int(_.group(1)) < 256 else _.group(0), page)
341341

342342
# e.g. %20%28%29
343-
if b"%" in page:
344-
page = re.sub(b"%([0-9a-fA-F]{2})", lambda _: decodeHex(_.group(1)), page)
343+
if percentDecode:
344+
if b"%" in page:
345+
page = re.sub(b"%([0-9a-fA-F]{2})", lambda _: decodeHex(_.group(1)), page)
345346

346347
# e.g. &amp;
347348
page = re.sub(b"&([^;]+);", lambda _: six.int2byte(HTML_ENTITIES[getText(_.group(1))]) if HTML_ENTITIES.get(getText(_.group(1)), 256) < 256 else _.group(0), page)

lib/request/connect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ class _(dict):
550550
code = None
551551
responseHeaders = {}
552552

553-
page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE))
553+
page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE), percentDecode=not crawling)
554554
status = getUnicode(conn.msg) if conn and getattr(conn, "msg", None) else None
555555

556556
kb.connErrorCounter = 0
@@ -628,7 +628,7 @@ class _(dict):
628628
responseHeaders = ex.info()
629629
responseHeaders[URI_HTTP_HEADER] = ex.geturl()
630630
patchHeaders(responseHeaders)
631-
page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE))
631+
page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE), percentDecode=not crawling)
632632
except socket.timeout:
633633
warnMsg = "connection timed out while trying "
634634
warnMsg += "to get error page information (%d)" % ex.code

0 commit comments

Comments
 (0)