From a7f20c1d677b37ec64262c79ff9730039025233a Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 4 Sep 2020 12:45:33 +0200 Subject: [PATCH] Minor update (base64 stuff) --- extra/vulnserver/vulnserver.py | 6 +++++- lib/core/common.py | 1 + lib/core/settings.py | 2 +- lib/core/testing.py | 6 +++++- lib/parse/cmdline.py | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/extra/vulnserver/vulnserver.py b/extra/vulnserver/vulnserver.py index 3106eafeb..5f33ee975 100644 --- a/extra/vulnserver/vulnserver.py +++ b/extra/vulnserver/vulnserver.py @@ -9,6 +9,7 @@ See the file 'LICENSE' for copying permission from __future__ import print_function +import base64 import json import re import sqlite3 @@ -146,7 +147,10 @@ class ReqHandler(BaseHTTPRequestHandler): if "query" in self.params: _cursor.execute(self.params["query"]) elif "id" in self.params: - _cursor.execute("SELECT * FROM users WHERE id=%s LIMIT 0, 1" % self.params["id"]) + if "base64" in self.params: + _cursor.execute("SELECT * FROM users WHERE id=%s LIMIT 0, 1" % base64.b64decode("%s===" % self.params["id"], altchars=self.params.get("altchars")).decode()) + else: + _cursor.execute("SELECT * FROM users WHERE id=%s LIMIT 0, 1" % self.params["id"]) results = _cursor.fetchall() output += "SQL results:
\n" diff --git a/lib/core/common.py b/lib/core/common.py index 3c419e5b3..9a6da74e2 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -632,6 +632,7 @@ def paramToDict(place, parameters=None): if parameter in (conf.base64Parameter or []): try: kb.base64Originals[parameter] = oldValue = value + value = urldecode(value, convall=True) value = decodeBase64(value, binary=False, encoding=conf.encoding or UNICODE_ENCODING) parameters = re.sub(r"\b%s(\b|\Z)" % re.escape(oldValue), value, parameters) except: diff --git a/lib/core/settings.py b/lib/core/settings.py index 39bf055c3..fdad3128e 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.9.1" +VERSION = "1.4.9.2" 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) diff --git a/lib/core/testing.py b/lib/core/testing.py index cb9fe70d9..0704a2da5 100644 --- a/lib/core/testing.py +++ b/lib/core/testing.py @@ -39,6 +39,7 @@ def vulnTest(): TESTS = ( ("-h", ("to see full list of options run with '-hh'",)), + ("-u -p id --base64=id -v 6 --data='base64=true' --flush-session --banner --technique=BEU", ("banner: '3.",)), ("--dependencies", ("sqlmap requires", "third-party library")), ("-u --flush-session --wizard", ("Please choose:", "back-end DBMS: SQLite", "current user is DBA: True", "banner: '3.")), (u"-c --flush-session --roles --statements --hostname --privileges --sql-query=\"SELECT '\u0161u\u0107uraj'\" --technique=U", (u": '\u0161u\u0107uraj'", "on SQLite it is not possible")), @@ -125,7 +126,10 @@ def vulnTest(): status = '%d/%d (%d%%) ' % (count, len(TESTS), round(100.0 * count / len(TESTS))) dataToStdout("\r[%s] [INFO] complete: %s" % (time.strftime("%X"), status)) - cmd = "%s %s %s --batch --non-interactive" % (sys.executable, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.py")), options.replace("", url).replace("", direct).replace("", request).replace("", log).replace("", config)) + for tag, value in (("", url), ("", direct), ("", request), ("", log), ("", config), ("", url.replace("id=1", "id=MZ=%3d"))): + options = options.replace(tag, value) + + cmd = "%s %s %s --batch --non-interactive" % (sys.executable, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.py")), options) if "" in cmd: handle, tmp = tempfile.mkstemp() diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 68c0887dc..8fcd0df71 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -623,7 +623,7 @@ def cmdLineParser(argv=None): help="Parameter(s) containing Base64 encoded data") general.add_argument("--base64-safe", dest="base64Safe", action="store_true", - help="Use URL and filename safe Base64 alphabet") + help="Use URL and filename safe Base64 alphabet (RFC 4648)") general.add_argument("--batch", dest="batch", action="store_true", help="Never ask for user input, use the default behavior")