Skip to content

Commit dd450b5

Browse files
committed
Less requests in case of non-injectable parameters
1 parent 0302a78 commit dd450b5

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

lib/controller/checks.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,16 @@ def checkSqlInjection(place, parameter, value):
345345
match = re.search(r"(\d+)-(\d+)", test.request.columns)
346346
if match and not injection.data:
347347
_ = test.request.columns.split('-')[-1]
348-
if conf.uCols is None and _.isdigit() and int(_) > 10:
348+
if conf.uCols is None and _.isdigit():
349349
if kb.futileUnion is None:
350-
msg = "it is not recommended to perform "
351-
msg += "extended UNION tests if there is not "
350+
msg = "it is recommended to perform "
351+
msg += "only basic UNION tests if there is not "
352352
msg += "at least one other (potential) "
353-
msg += "technique found. Do you want to skip? [Y/n] "
354-
kb.futileUnion = not readInput(msg, default='Y', boolean=True)
353+
msg += "technique found. Do you want to reduce "
354+
msg +="the number of requests? [Y/n] "
355+
kb.futileUnion = readInput(msg, default='Y', boolean=True)
355356

356-
if kb.futileUnion is False:
357+
if kb.futileUnion and int(_) > 10:
357358
debugMsg = "skipping test '%s'" % title
358359
logger.debug(debugMsg)
359360
continue
@@ -499,14 +500,31 @@ def genCmpPayload():
499500

500501
return cmpPayload
501502

502-
# Useful to set kb.matchRatio at first based on
503-
# the False response content
503+
# Useful to set kb.matchRatio at first based on False response content
504504
kb.matchRatio = None
505505
kb.negativeLogic = (where == PAYLOAD.WHERE.NEGATIVE)
506506
Request.queryPage(genCmpPayload(), place, raise404=False)
507507
falsePage, falseHeaders, falseCode = threadData.lastComparisonPage or "", threadData.lastComparisonHeaders, threadData.lastComparisonCode
508508
falseRawResponse = "%s%s" % (falseHeaders, falsePage)
509509

510+
# Checking if there is difference between current FALSE, original and heuristics page (i.e. not used parameter)
511+
if not kb.negativeLogic:
512+
try:
513+
ratio = 1.0
514+
seqMatcher = getCurrentThreadData().seqMatcher
515+
516+
for current in (kb.originalPage, kb.heuristicPage):
517+
seqMatcher.set_seq1(current)
518+
seqMatcher.set_seq2(falsePage)
519+
ratio *= seqMatcher.quick_ratio()
520+
521+
if ratio == 1.0:
522+
continue
523+
except MemoryError:
524+
pass
525+
526+
kb.prevFalsePage = falsePage
527+
510528
# Perform the test's True request
511529
trueResult = Request.queryPage(reqPayload, place, raise404=False)
512530
truePage, trueHeaders, trueCode = threadData.lastComparisonPage or "", threadData.lastComparisonHeaders, threadData.lastComparisonCode

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.117"
21+
VERSION = "1.3.5.118"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/techniques/union/test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ def _orderByTest(cols):
9191
kb.errorIsNone = False
9292
lowerCount, upperCount = conf.uColsStart, conf.uColsStop
9393

94-
if kb.orderByColumns is None and (lowerCount == 1 or conf.uCols): # ORDER BY is not bullet-proof
94+
if kb.orderByColumns is None and (lowerCount == 1 or conf.uCols): # Note: ORDER BY is not bullet-proof
9595
found = _orderByTechnique(lowerCount, upperCount) if conf.uCols else _orderByTechnique()
9696
if found:
9797
kb.orderByColumns = found
9898
infoMsg = "target URL appears to have %d column%s in query" % (found, 's' if found > 1 else "")
9999
singleTimeLogMessage(infoMsg)
100100
return found
101+
elif kb.futileUnion:
102+
return None
101103

102104
if abs(upperCount - lowerCount) < MIN_UNION_RESPONSES:
103105
upperCount = lowerCount + MIN_UNION_RESPONSES

0 commit comments

Comments
 (0)