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

Skip to content

Commit f89b25f

Browse files
committed
Merge branch 'master' of github.com:sqlmapproject/sqlmap
2 parents adf97e6 + 9ce2395 commit f89b25f

4 files changed

Lines changed: 24 additions & 16 deletions

File tree

lib/core/common.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ def findMultipartPostBoundary(post):
19841984

19851985
return retVal
19861986

1987-
def urldecode(value, encoding=None, unsafe="%%&=;+%s" % CUSTOM_INJECTION_MARK_CHAR, convall=False):
1987+
def urldecode(value, encoding=None, unsafe="%%&=;+%s" % CUSTOM_INJECTION_MARK_CHAR, convall=False, plusspace=True):
19881988
result = value
19891989

19901990
if value:
@@ -2002,14 +2002,16 @@ def _(match):
20022002
char = chr(ord(match.group(1).decode("hex")))
20032003
return char if char in charset else match.group(0)
20042004
result = re.sub("%([0-9a-fA-F]{2})", _, value)
2005-
result = result.replace("+", " ") # plus sign has a special meaning in url encoded data (hence the usage of urllib.unquote_plus in convall case)
2005+
2006+
if plusspace:
2007+
result = result.replace("+", " ") # plus sign has a special meaning in url encoded data (hence the usage of urllib.unquote_plus in convall case)
20062008

20072009
if isinstance(result, str):
20082010
result = unicode(result, encoding or UNICODE_ENCODING, "replace")
20092011

20102012
return result
20112013

2012-
def urlencode(value, safe="%&=", convall=False, limit=False):
2014+
def urlencode(value, safe="%&=", convall=False, limit=False, spaceplus=False):
20132015
if conf.direct:
20142016
return value
20152017

@@ -2041,6 +2043,9 @@ def urlencode(value, safe="%&=", convall=False, limit=False):
20412043
else:
20422044
break
20432045

2046+
if spaceplus:
2047+
result = result.replace(urllib.quote(' '), '+')
2048+
20442049
return result
20452050

20462051
def runningAsAdmin():
@@ -3021,7 +3026,7 @@ def geturl(self):
30213026
url = urldecode(request.get_full_url(), kb.pageEncoding)
30223027
method = request.get_method()
30233028
data = request.get_data() if request.has_data() else None
3024-
data = urldecode(data, kb.pageEncoding) if data and urlencode(DEFAULT_GET_POST_DELIMITER, None) not in data else data
3029+
data = urldecode(data, kb.pageEncoding, plusspace=False)
30253030

30263031
if not data and method and method.upper() == HTTPMETHOD.POST:
30273032
debugMsg = "invalid POST form with blank data detected"

lib/core/option.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def _parseBurpLog(content):
304304
# Avoid to add a static content length header to
305305
# conf.httpHeaders and consider the following lines as
306306
# POSTed data
307-
if key == HTTPHEADER.CONTENT_LENGTH:
307+
if key.upper() == HTTPHEADER.CONTENT_LENGTH.upper():
308308
params = True
309309

310310
# Avoid proxy and connection type related headers
@@ -328,7 +328,7 @@ def _parseBurpLog(content):
328328

329329
if not(conf.scope and not re.search(conf.scope, url, re.I)):
330330
if not kb.targets or url not in addedTargetUrls:
331-
kb.targets.add((url, method, urldecode(data) if data and urlencode(DEFAULT_GET_POST_DELIMITER, None) not in data else data, cookie))
331+
kb.targets.add((url, method, data, cookie))
332332
addedTargetUrls.add(url)
333333

334334
fp = openFile(reqFile, "rb")
@@ -1361,15 +1361,6 @@ def _cleanupOptions():
13611361
if conf.data:
13621362
conf.data = re.sub(INJECT_HERE_MARK.replace(" ", r"[^A-Za-z]*"), CUSTOM_INJECTION_MARK_CHAR, conf.data, re.I)
13631363

1364-
if re.search(r'%[0-9a-f]{2}', conf.data, re.I):
1365-
class _(unicode):
1366-
pass
1367-
original = conf.data
1368-
conf.data = _(urldecode(conf.data))
1369-
setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original)
1370-
else:
1371-
conf.data = urldecode(conf.data)
1372-
13731364
if conf.url:
13741365
conf.url = re.sub(INJECT_HERE_MARK.replace(" ", r"[^A-Za-z]*"), CUSTOM_INJECTION_MARK_CHAR, conf.url, re.I)
13751366

@@ -1591,6 +1582,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
15911582
kb.safeCharEncode = False
15921583
kb.singleLogFlags = set()
15931584
kb.skipOthersDbms = None
1585+
kb.postSpaceToPlus = False
15941586
kb.stickyDBMS = False
15951587
kb.stickyLevel = None
15961588
kb.suppressResumeInfo = False

lib/core/target.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from lib.core.settings import RESULTS_FILE_FORMAT
4848
from lib.core.settings import SOAP_RECOGNITION_REGEX
4949
from lib.core.settings import SUPPORTED_DBMS
50+
from lib.core.settings import UNENCODED_ORIGINAL_VALUE
5051
from lib.core.settings import UNICODE_ENCODING
5152
from lib.core.settings import UNKNOWN_DBMS_VERSION
5253
from lib.core.settings import URI_INJECTABLE_REGEX
@@ -504,6 +505,16 @@ def initTargetEnv():
504505
_restoreCmdLineOptions()
505506
_setDBMS()
506507

508+
if conf.data:
509+
class _(unicode):
510+
pass
511+
512+
original = conf.data
513+
conf.data = _(urldecode(conf.data))
514+
setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original)
515+
516+
kb.postSpaceToPlus = '+' in original
517+
507518
def setupTargetEnv():
508519
_createTargetDirs()
509520
_setRequestParams()

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def _randomizeParameter(paramString, randomParameter):
745745
if place not in (PLACE.POST, PLACE.CUSTOM_POST) and hasattr(post, UNENCODED_ORIGINAL_VALUE):
746746
post = getattr(post, UNENCODED_ORIGINAL_VALUE)
747747
elif not skipUrlEncode and kb.postHint not in POST_HINT_CONTENT_TYPES.keys():
748-
post = urlencode(post)
748+
post = urlencode(post, spaceplus=kb.postSpaceToPlus)
749749

750750
if timeBasedCompare:
751751
if len(kb.responseTimes) < MIN_TIME_RESPONSES:

0 commit comments

Comments
 (0)