From 76f79ece133db6eb9d79268b77a674f132447e47 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 21 Dec 2014 05:15:42 +0100 Subject: [PATCH] run like --threads=20! will skip the maximum number of threads check --- lib/core/option.py | 2 +- lib/core/threads.py | 19 ++++++++++++------- lib/parse/cmdline.py | 4 ++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index a27175c43..c04e6d3fe 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -2190,7 +2190,7 @@ def _basicOptionValidation(): errMsg = "switch '--predict-output' is incompatible with option '--threads' and switch '-o'" raise SqlmapSyntaxException(errMsg) - if conf.threads > MAX_NUMBER_OF_THREADS: + if conf.threads > MAX_NUMBER_OF_THREADS and not conf.get("skipThreadCheck"): errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS raise SqlmapSyntaxException(errMsg) diff --git a/lib/core/threads.py b/lib/core/threads.py index 2b4ce4eb4..0d4e36e05 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -110,13 +110,18 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio while True: message = "please enter number of threads? [Enter for %d (current)] " % numThreads choice = readInput(message, default=str(numThreads)) - if choice and choice.isdigit(): - if int(choice) > MAX_NUMBER_OF_THREADS: - errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS - logger.critical(errMsg) - else: - conf.threads = numThreads = int(choice) - break + if choice: + skipThreadCheck = False + if choice.endswith('!'): + choice = choice[:-1] + skipThreadCheck = True + if choice.isdigit(): + if int(choice) > MAX_NUMBER_OF_THREADS and not skipThreadCheck: + errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS + logger.critical(errMsg) + else: + conf.threads = numThreads = int(choice) + break if numThreads == 1: warnMsg = "running in a single-thread mode. This could take a while" diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index f63909544..826314c70 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -6,6 +6,7 @@ See the file 'doc/COPYING' for copying permission """ import os +import re import shlex import sys @@ -850,6 +851,9 @@ def cmdLineParser(): for i in xrange(len(argv)): if argv[i] == "-hh": argv[i] = "-h" + elif re.match(r"\A\d+!\Z", argv[i]) and argv[max(0, i - 1)] == "--threads" or re.match(r"\A--threads.+\d+!\Z", argv[i]): + argv[i] = argv[i][:-1] + conf.skipThreadCheck = True elif argv[i] == "--version": print VERSION_STRING.split('/')[-1] raise SystemExit