Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38541b0

Browse files
committed
Implementing hidden switch '--force-threads' on request (to force multi-threading in time-based SQLi)
1 parent b688910 commit 38541b0

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ def cmdLineParser(argv=None):
763763
parser.add_option("--force-dns", dest="forceDns", action="store_true",
764764
help=SUPPRESS_HELP)
765765

766+
parser.add_option("--force-threads", dest="forceThreads", action="store_true",
767+
help=SUPPRESS_HELP)
768+
766769
parser.add_option("--smoke-test", dest="smokeTest", action="store_true",
767770
help=SUPPRESS_HELP)
768771

lib/request/inject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _goInference(payload, expression, charsetType=None, firstChar=None, lastChar
7878
timeBasedCompare = (kb.technique in (PAYLOAD.TECHNIQUE.TIME, PAYLOAD.TECHNIQUE.STACKED))
7979

8080
if not (timeBasedCompare and kb.dnsTest):
81-
if (conf.eta or conf.threads > 1) and Backend.getIdentifiedDbms() and not re.search("(COUNT|LTRIM)\(", expression, re.I) and not timeBasedCompare:
81+
if (conf.eta or conf.threads > 1) and Backend.getIdentifiedDbms() and not re.search("(COUNT|LTRIM)\(", expression, re.I) and not (timeBasedCompare and not conf.forceThreads):
8282

8383
if field and re.search("\ASELECT\s+DISTINCT\((.+?)\)\s+FROM", expression, re.I):
8484
expression = "SELECT %s FROM (%s)" % (field, expression)

lib/techniques/blind/inference.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
146146
if showEta:
147147
progress = ProgressBar(maxValue=length)
148148

149-
if timeBasedCompare and conf.threads > 1:
149+
if timeBasedCompare and conf.threads > 1 and not conf.forceThreads:
150150
warnMsg = "multi-threading is considered unsafe in time-based data retrieval. Going to switch it off automatically"
151151
singleTimeWarnMessage(warnMsg)
152152

153153
if numThreads > 1:
154-
if not timeBasedCompare:
154+
if not timeBasedCompare or conf.forceThreads:
155155
debugMsg = "starting %d thread%s" % (numThreads, ("s" if numThreads > 1 else ""))
156156
logger.debug(debugMsg)
157157
else:
@@ -597,8 +597,9 @@ def queryOutputLength(expression, payload):
597597
infoMsg = "retrieving the length of query output"
598598
logger.info(infoMsg)
599599

600-
lengthExprUnescaped = agent.forgeQueryOutputLength(expression)
601600
start = time.time()
601+
602+
lengthExprUnescaped = agent.forgeQueryOutputLength(expression)
602603
count, length = bisection(payload, lengthExprUnescaped, charsetType=CHARSET_TYPE.DIGITS)
603604

604605
debugMsg = "performed %d queries in %.2f seconds" % (count, calculateDeltaSeconds(start))

0 commit comments

Comments
 (0)