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

Skip to content

Commit 025361c

Browse files
committed
Higher precedence to union query sql inj than error-based
1 parent 56d2b2f commit 025361c

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

lib/request/inject.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,13 @@ def getValue(expression, blind=True, inband=True, error=True, fromUser=False, ex
347347

348348
if conf.direct:
349349
value = direct(expression)
350-
elif kb.booleanTest or kb.errorTest or kb.unionTest:
350+
elif kb.booleanTest is not None or kb.errorTest is not None or kb.unionTest is not None:
351351
expression = cleanQuery(expression)
352352
expression = expandAsteriskForColumns(expression)
353353
value = None
354-
355354
expression = expression.replace("DISTINCT ", "")
356355

357-
if error and kb.errorTest:
358-
value = goError(expression)
359-
360-
if not value:
361-
warnMsg = "for some reason(s) it was not possible to retrieve "
362-
warnMsg += "the query output through error SQL injection "
363-
warnMsg += "technique, sqlmap is going %s" % ("inband" if inband and kb.unionPosition is not None else "blind")
364-
logger.warn(warnMsg)
365-
366-
if inband and kb.unionPosition is not None and not value:
356+
if inband and kb.unionTest is not None:
367357
value = __goInband(expression, expected, sort, resumeValue, unpack, dump)
368358

369359
if not value:
@@ -377,6 +367,15 @@ def getValue(expression, blind=True, inband=True, error=True, fromUser=False, ex
377367
kb.unionFalseCond = False
378368
kb.unionNegative = False
379369

370+
if error and kb.errorTest and not value:
371+
value = goError(expression)
372+
373+
if not value:
374+
warnMsg = "for some reason(s) it was not possible to retrieve "
375+
warnMsg += "the query output through error SQL injection "
376+
warnMsg += "technique, sqlmap is going %s" % ("inband" if inband and kb.unionPosition is not None else "blind")
377+
logger.warn(warnMsg)
378+
380379
if blind and kb.booleanTest and not value:
381380
value = __goInferenceProxy(expression, fromUser, expected, batch, resumeValue, unpack, charsetType, firstChar, lastChar)
382381

0 commit comments

Comments
 (0)