From 8cdc66fdf7eed978d0dec957e5b9f442a332e0df Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sat, 9 Nov 2019 01:01:19 +0100 Subject: [PATCH] Bug fix (multiple Ctrl-C in crawling mode) --- lib/core/option.py | 1 + lib/core/settings.py | 2 +- lib/core/threads.py | 6 ++++++ sqlmap.py | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/core/option.py b/lib/core/option.py index c6b010269..f8abca785 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1909,6 +1909,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.injections = [] kb.laggingChecked = False kb.lastParserStatus = None + kb.lastCtrlCTime = None kb.locks = AttribDict() for _ in ("cache", "connError", "count", "handlers", "hint", "index", "io", "limit", "log", "socket", "redirect", "request", "value"): diff --git a/lib/core/settings.py b/lib/core/settings.py index 43fc75d3b..c770beae8 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.3.11.24" +VERSION = "1.3.11.25" 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/threads.py b/lib/core/threads.py index 8f163a637..4e65c8a4e 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -185,6 +185,12 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio kb.threadContinue = False kb.threadException = True + if kb.lastCtrlCTime and (time.time() - kb.lastCtrlCTime < 1): + kb.multipleCtrlC = True + raise SqlmapUserQuitException("user aborted (Ctrl+C was pressed multiple times)") + + kb.lastCtrlCTime = time.time() + if numThreads > 1: logger.info("waiting for threads to finish%s" % (" (Ctrl+C was pressed)" if isinstance(ex, KeyboardInterrupt) else "")) try: diff --git a/sqlmap.py b/sqlmap.py index ebce1e1af..e232d4fb8 100755 --- a/sqlmap.py +++ b/sqlmap.py @@ -200,6 +200,8 @@ def main(): if not isinstance(ex, SqlmapUserQuitException): errMsg = "problem occurred while crawling '%s' ('%s')" % (target, getSafeExString(ex)) logger.error(errMsg) + else: + raise else: if kb.targets: start()