From fcb2a6e111ba30e8f88dad88ec629a1d2a1987c6 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 16 Mar 2020 17:31:37 +0100 Subject: [PATCH] Patch related to the #4137 --- lib/core/agent.py | 14 ++++++++++++-- lib/core/settings.py | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index b1492ef1f..b5a86b1e8 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -110,6 +110,7 @@ class Agent(object): paramDict = conf.paramDict[place] origValue = getUnicode(paramDict[parameter]) newValue = getUnicode(newValue) if newValue else newValue + base64Encoding = re.sub(r" \(.+", "", parameter) in conf.base64Parameter if place == PLACE.URI or BOUNDED_INJECTION_MARKER in origValue: paramString = origValue @@ -173,7 +174,10 @@ class Agent(object): newValue = self.cleanupPayload(newValue, origValue) - if re.sub(r" \(.+", "", parameter) in conf.base64Parameter: + if base64Encoding: + _newValue = newValue + _origValue = origValue + # TODO: support for POST_HINT newValue = encodeBase64(newValue, binary=False, encoding=conf.encoding or UNICODE_ENCODING) origValue = encodeBase64(origValue, binary=False, encoding=conf.encoding or UNICODE_ENCODING) @@ -194,7 +198,13 @@ class Agent(object): retVal = retVal.replace(kb.customInjectionMark, "").replace(REPLACEMENT_MARKER, kb.customInjectionMark) elif BOUNDED_INJECTION_MARKER in paramDict[parameter]: - retVal = paramString.replace("%s%s" % (origValue, BOUNDED_INJECTION_MARKER), self.addPayloadDelimiters(newValue)) + if base64Encoding: + retVal = paramString.replace("%s%s" % (_origValue, BOUNDED_INJECTION_MARKER), _newValue) + match = re.search(r"(%s)=([^&]*)" % re.sub(r" \(.+", "", parameter), retVal) + if match: + retVal = retVal.replace(match.group(0), "%s=%s" % (match.group(1), encodeBase64(match.group(2), binary=False, encoding=conf.encoding or UNICODE_ENCODING))) + else: + retVal = paramString.replace("%s%s" % (origValue, BOUNDED_INJECTION_MARKER), self.addPayloadDelimiters(newValue)) elif place in (PLACE.USER_AGENT, PLACE.REFERER, PLACE.HOST): retVal = paramString.replace(origValue, self.addPayloadDelimiters(newValue)) else: diff --git a/lib/core/settings.py b/lib/core/settings.py index 628926f9f..83ae4eff2 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.4.3.7" +VERSION = "1.4.3.8" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)