diff --git a/lib/core/enums.py b/lib/core/enums.py index f0366b5a4..af155fe46 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -96,6 +96,7 @@ class HTTPHEADER: class WARNFLAGS: RANDOM_AGENT = 'randomAgent' DATA_TO_STDOUT = 'dataToStdout' + THREADS = 'threads' class EXPECTED: BOOL = "bool" diff --git a/lib/request/connect.py b/lib/request/connect.py index 085f73963..41951ba01 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -390,6 +390,10 @@ class Connect: warnMsg += "with the --random-agent switch turned on " warnMsg += "and/or try to use proxy switches (--ignore-proxy, --proxy,...)" singleTimeLogMessage(warnMsg, logging.WARN, WARNFLAGS.RANDOM_AGENT) + elif conf.threads > 1: + warnMsg = "if the problem persists please try to lower " + warnMsg += "the number of used threads (--threads)" + singleTimeLogMessage(warnMsg, logging.WARN, WARNFLAGS.THREADS) time.sleep(1) diff --git a/lib/techniques/brute/use.py b/lib/techniques/brute/use.py index b1168ebf5..89b872bb3 100644 --- a/lib/techniques/brute/use.py +++ b/lib/techniques/brute/use.py @@ -29,6 +29,7 @@ from lib.core.data import logger from lib.core.enums import DBMS from lib.core.exception import sqlmapMissingMandatoryOptionException from lib.core.exception import sqlmapThreadException +from lib.core.settings import MAX_NUMBER_OF_THREADS from lib.core.settings import METADB_SUFFIX from lib.core.session import safeFormatString from lib.request import inject @@ -100,10 +101,16 @@ def tableExists(tableFile, regex=None): infoMsg = "starting %d threads" % conf.threads logger.info(infoMsg) else: - message = "please enter number of threads? [Enter for %d (current)] " % conf.threads - choice = readInput(message, default=str(conf.threads)) - if choice and choice.isdigit(): - conf.threads = int(choice) + while True: + message = "please enter number of threads? [Enter for %d (current)] " % conf.threads + choice = readInput(message, default=str(conf.threads)) + if choice and choice.isdigit(): + if int(choice) > MAX_NUMBER_OF_THREADS: + errMsg = "maximum number of used threads is %d avoiding possible connection issues" % MAX_NUMBER_OF_THREADS + logger.critical(errMsg) + else: + conf.threads = int(choice) + break if conf.threads == 1: warnMsg = "running in a single-thread mode. This could take a while." @@ -218,10 +225,16 @@ def columnExists(columnFile, regex=None): infoMsg = "starting %d threads" % conf.threads logger.info(infoMsg) else: - message = "please enter number of threads? [Enter for %d (current)] " % conf.threads - choice = readInput(message, default=str(conf.threads)) - if choice and choice.isdigit(): - conf.threads = int(choice) + while True: + message = "please enter number of threads? [Enter for %d (current)] " % conf.threads + choice = readInput(message, default=str(conf.threads)) + if choice and choice.isdigit(): + if int(choice) > MAX_NUMBER_OF_THREADS: + errMsg = "maximum number of used threads is %d avoiding possible connection issues" % MAX_NUMBER_OF_THREADS + logger.critical(errMsg) + else: + conf.threads = int(choice) + break if conf.threads == 1: warnMsg = "running in a single-thread mode. This could take a while."