From c8eea24ac42af9a20e0ab7aaf625f4e390d955d1 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 23 Jan 2023 16:40:41 +0100 Subject: [PATCH] Implements #5295 --- lib/core/optiondict.py | 1 + lib/core/settings.py | 2 +- lib/parse/cmdline.py | 3 +++ lib/request/inject.py | 13 +++++++++---- sqlmap.conf | 3 +++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index 48343a494..c28eca013 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -204,6 +204,7 @@ optDict = { "General": { "trafficFile": "string", + "abortOnEmpty": "boolean", "answers": "string", "batch": "boolean", "base64Parameter": "string", diff --git a/lib/core/settings.py b/lib/core/settings.py index 9c99f41a6..624caf33e 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from thirdparty import six from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.7.1.7" +VERSION = "1.7.1.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) diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index b6bb36fb4..383fba066 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -628,6 +628,9 @@ def cmdLineParser(argv=None): general.add_argument("-t", dest="trafficFile", help="Log all HTTP traffic into a textual file") + general.add_argument("--abort-on-empty", dest="abortOnEmpty", action="store_true", + help="Abort data retrieval on empty results") + general.add_argument("--answers", dest="answers", help="Set predefined answers (e.g. \"quit=N,follow=N\")") diff --git a/lib/request/inject.py b/lib/request/inject.py index a52878316..039ef1be3 100644 --- a/lib/request/inject.py +++ b/lib/request/inject.py @@ -501,10 +501,15 @@ def getValue(expression, blind=True, union=True, error=True, time=True, fromUser kb.safeCharEncode = False if not any((kb.testMode, conf.dummy, conf.offline, conf.noCast, conf.hexConvert)) and value is None and Backend.getDbms() and conf.dbmsHandler and kb.fingerprinted: - warnMsg = "in case of continuous data retrieval problems you are advised to try " - warnMsg += "a switch '--no-cast' " - warnMsg += "or switch '--hex'" if hasattr(queries[Backend.getIdentifiedDbms()], "hex") else "" - singleTimeWarnMessage(warnMsg) + if conf.abortOnEmpty: + errMsg = "aborting due to empty data retrieval" + logger.critical(errMsg) + raise SystemExit + else: + warnMsg = "in case of continuous data retrieval problems you are advised to try " + warnMsg += "a switch '--no-cast' " + warnMsg += "or switch '--hex'" if hasattr(queries[Backend.getIdentifiedDbms()], "hex") else "" + singleTimeWarnMessage(warnMsg) # Dirty patch (MSSQL --binary-fields with 0x31003200...) if Backend.isDbms(DBMS.MSSQL) and conf.binaryFields: diff --git a/sqlmap.conf b/sqlmap.conf index ecab1a5c5..71a12017c 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -702,6 +702,9 @@ sessionFile = # Log all HTTP traffic into a textual file. trafficFile = +# Abort data retrieval on empty results. +abortOnEmpty = False + # Set predefined answers (e.g. "quit=N,follow=N"). answers =