Skip to content

Commit 68354be

Browse files
committed
Ahead with enhancements on comparison algorithm: implemented content-length technique
1 parent afbd66f commit 68354be

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/controller/checks.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,16 @@ def checkStability():
320320
contentLengths.append(int(clHeader.group(1)))
321321

322322
if contentLengths:
323-
clSum = 0
323+
conf.contentLengths = ( min(contentLengths), max(contentLengths) )
324324

325-
for cl in contentLengths:
326-
clSum += cl
325+
warnMsg = "url is not stable, sqlmap inspected the headers "
326+
warnMsg += "and identified that Content-Length can be used "
327+
warnMsg += "in the comparison algorithm"
328+
logger.warn(warnMsg)
327329

328-
clAverage = clSum / len(contentLengths)
330+
kb.defaultResult = True
329331

330-
# TODO: go ahead here with the technique to compare True/False
331-
# based upon clAverage discard (conf.contentLengths)
332+
return True
332333

333334
# Prepare for the comparison algorithm based on page content's
334335
# stable lines subset
@@ -356,6 +357,10 @@ def checkStability():
356357

357358
return True
358359

360+
if condition == True:
361+
logMsg = "url is stable"
362+
logger.info(logMsg)
363+
359364
return condition
360365

361366

lib/controller/controller.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ def start():
175175

176176
if not kb.injPlace or not kb.injParameter or not kb.injType:
177177
if not conf.string and not conf.regexp and not conf.eRegexp:
178-
if checkStability():
179-
logMsg = "url is stable"
180-
logger.info(logMsg)
181-
else:
178+
if not checkStability():
182179
errMsg = "url is not stable, try with --string or "
183180
errMsg += "--regexp options, refer to the user's manual "
184181
errMsg += "paragraph 'Page comparison' for details"

lib/request/comparison.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ def comparison(page, headers=None, content=False):
7575

7676
# Comparison algorithm based on Content-Length header value
7777
elif conf.contentLengths:
78-
pass
78+
minValue = conf.contentLengths[0] - 10
79+
maxValue = conf.contentLengths[1] + 10
80+
81+
if len(page) >= minValue and len(page) <= maxValue:
82+
return True
7983

8084
# Comparison algorithm based on page content's stable lines subset
8185
elif conf.equalLines:

0 commit comments

Comments
 (0)