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

Skip to content

Commit b42b62a

Browse files
committed
Major improvement in Base64 handling (late-binding)
1 parent a7f20c1 commit b42b62a

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

lib/core/agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from lib.core.enums import PLACE
4343
from lib.core.enums import POST_HINT
4444
from lib.core.exception import SqlmapNoneDataException
45+
from lib.core.settings import BOUNDED_BASE64_MARKER
4546
from lib.core.settings import BOUNDARY_BACKSLASH_MARKER
4647
from lib.core.settings import BOUNDED_INJECTION_MARKER
4748
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
@@ -183,7 +184,7 @@ def payload(self, place=None, parameter=None, value=None, newValue=None, where=N
183184
newValue = self.adjustLateValues(newValue)
184185

185186
# TODO: support for POST_HINT
186-
newValue = encodeBase64(newValue, binary=False, encoding=conf.encoding or UNICODE_ENCODING, safe=conf.base64Safe)
187+
newValue = "%s%s%s" % (BOUNDED_BASE64_MARKER, newValue, BOUNDED_BASE64_MARKER)
187188

188189
if parameter in kb.base64Originals:
189190
origValue = kb.base64Originals[parameter]
@@ -397,6 +398,10 @@ def adjustLateValues(self, payload):
397398
"""
398399

399400
if payload:
401+
for match in re.finditer(r"%s(.*?)%s" % (BOUNDED_BASE64_MARKER, BOUNDED_BASE64_MARKER), payload):
402+
_ = encodeBase64(match.group(1), binary=False, encoding=conf.encoding or UNICODE_ENCODING, safe=conf.base64Safe)
403+
payload = payload.replace(match.group(0), _)
404+
400405
payload = payload.replace(SLEEP_TIME_MARKER, str(conf.timeSec))
401406
payload = payload.replace(SINGLE_QUOTE_MARKER, "'")
402407

lib/core/settings.py

Lines changed: 2 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.4.9.2"
21+
VERSION = "1.4.9.3"
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)
@@ -66,6 +66,7 @@
6666
URI_QUESTION_MARKER = "__QUESTION_MARK__"
6767
ASTERISK_MARKER = "__ASTERISK_MARK__"
6868
REPLACEMENT_MARKER = "__REPLACEMENT_MARK__"
69+
BOUNDED_BASE64_MARKER = "__BOUNDED_BASE64_MARK__"
6970
BOUNDED_INJECTION_MARKER = "__BOUNDED_INJECTION_MARK__"
7071
SAFE_VARIABLE_MARKER = "__SAFE__"
7172
SAFE_HEX_MARKER = "__SAFE_HEX__"

lib/core/testing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def vulnTest():
3939

4040
TESTS = (
4141
("-h", ("to see full list of options run with '-hh'",)),
42-
("-u <base64> -p id --base64=id -v 6 --data='base64=true' --flush-session --banner --technique=BEU", ("banner: '3.",)),
4342
("--dependencies", ("sqlmap requires", "third-party library")),
4443
("-u <url> --flush-session --wizard", ("Please choose:", "back-end DBMS: SQLite", "current user is DBA: True", "banner: '3.")),
4544
(u"-c <config> --flush-session --roles --statements --hostname --privileges --sql-query=\"SELECT '\u0161u\u0107uraj'\" --technique=U", (u": '\u0161u\u0107uraj'", "on SQLite it is not possible")),
@@ -49,6 +48,8 @@ def vulnTest():
4948
("-r <request> --flush-session -v 5 --test-skip='heavy' --save=<tmp>", ("CloudFlare", "possible DBMS: 'SQLite'", "User-agent: foobar", "~Type: time-based blind")),
5049
("-l <log> --flush-session --keep-alive --skip-waf -v 5 --technique=U --union-from=users --banner --parse-errors", ("banner: '3.", "ORDER BY term out of range", "~xp_cmdshell", "Connection: keep-alive")),
5150
("-l <log> --offline --banner -v 5", ("banner: '3.", "~[TRAFFIC OUT]")),
51+
("-u <base64> -p id --base64=id --data='base64=true' --flush-session --banner --technique=B", ("banner: '3.",)),
52+
("-u <base64> -p id --base64=id --data='base64=true' --flush-session --tables --technique=U", (" users ",)),
5253
("-u <url> --flush-session --banner --technique=B --not-string 'no results'", ("banner: '3.",)),
5354
("-u <url> --flush-session --banner --technique=B --first=1 --last=2", ("banner: '3.'",)),
5455
("-u <url> --flush-session --encoding=ascii --forms --crawl=2 --threads=2 --banner", ("total of 2 targets", "might be injectable", "Type: UNION query", "banner: '3.")),

0 commit comments

Comments
 (0)