GeezerVison is showing github.com — Ahead with enhancements on comparison algorithm: implemented content-… · bookjoy/sqlmap@68354be
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/controller/checks.py +11-6Lines changed: 11 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -320,15 +320,16 @@ def checkStability(): |
320 | 320 | contentLengths.append(int(clHeader.group(1))) |
321 | 321 |
|
322 | 322 | if contentLengths: |
323 | | - clSum = 0 |
| 323 | + conf.contentLengths = ( min(contentLengths), max(contentLengths) ) |
324 | 324 |
|
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) |
327 | 329 |
|
328 | | - clAverage = clSum / len(contentLengths) |
| 330 | + kb.defaultResult = True |
329 | 331 |
|
330 | | - # TODO: go ahead here with the technique to compare True/False |
331 | | - # based upon clAverage discard (conf.contentLengths) |
| 332 | + return True |
332 | 333 |
|
333 | 334 | # Prepare for the comparison algorithm based on page content's |
334 | 335 | # stable lines subset |
@@ -356,6 +357,10 @@ def checkStability(): |
356 | 357 |
|
357 | 358 | return True |
358 | 359 |
|
| 360 | + if condition == True: |
| 361 | + logMsg = "url is stable" |
| 362 | + logger.info(logMsg) |
| 363 | + |
359 | 364 | return condition |
360 | 365 |
|
361 | 366 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: lib/controller/controller.py +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -175,10 +175,7 @@ def start(): |
175 | 175 |
|
176 | 176 | if not kb.injPlace or not kb.injParameter or not kb.injType: |
177 | 177 | 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(): |
182 | 179 | errMsg = "url is not stable, try with --string or " |
183 | 180 | errMsg += "--regexp options, refer to the user's manual " |
184 | 181 | errMsg += "paragraph 'Page comparison' for details" |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/request/comparison.py +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -75,7 +75,11 @@ def comparison(page, headers=None, content=False): |
75 | 75 |
|
76 | 76 | # Comparison algorithm based on Content-Length header value |
77 | 77 | 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 |
79 | 83 |
|
80 | 84 | # Comparison algorithm based on page content's stable lines subset |
81 | 85 | elif conf.equalLines: |
|