From 43c79de330aa376134cfbd095b320921fe35ff78 Mon Sep 17 00:00:00 2001 From: "Gauvain \"GovanifY\" Roussel-Tarbouriech" Date: Wed, 9 Oct 2019 18:27:35 +0200 Subject: [PATCH] options: added a new option to detect errors when reported with normal status code and custom error strings --- lib/parse/cmdline.py | 3 +++ lib/parse/html.py | 7 ++++++- sqlmap.conf | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 72d204cb2..4f55f3893 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -370,6 +370,9 @@ def cmdLineParser(argv=None): detection.add_argument("--code", dest="code", type=int, help="HTTP code to match when query is evaluated to True") + detection.add_argument("--error-string", dest="errorString", + help="String to match when the database encountered an error") + detection.add_argument("--smart", dest="smart", action="store_true", help="Perform thorough tests only if positive heuristic(s)") diff --git a/lib/parse/html.py b/lib/parse/html.py index 3ec61d52f..6a7888bea 100644 --- a/lib/parse/html.py +++ b/lib/parse/html.py @@ -14,6 +14,7 @@ from lib.core.common import parseXmlFile from lib.core.data import kb from lib.core.data import paths from lib.core.threads import getCurrentThreadData +from lib.core.data import conf class HTMLHandler(ContentHandler): """ @@ -80,7 +81,11 @@ def htmlParser(page): kb.cache.parsedDbms[key] = handler.dbms # generic SQL warning/error messages - if re.search(r"SQL (warning|error|syntax)", page, re.I): + if conf.errorString: + error=conf.errorString + else: + error=r"SQL (warning|error|syntax)" + if re.search(error, page, re.I): handler._markAsErrorPage() return handler.dbms diff --git a/sqlmap.conf b/sqlmap.conf index 96f9c6799..e6e56dbf6 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -350,6 +350,10 @@ regexp = # code) # code = +# String to match within the raw response when the query returns a database error +# Refer to the user's manual for further details. +errorString = + # Conduct thorough tests only if positive heuristic(s). # Valid: True or False smart = False