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

Skip to content

Commit 4f46a5a

Browse files
committed
minor usability enhancement regarding warning for --text-only switch
1 parent ff030e4 commit 4f46a5a

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

lib/controller/checks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def genCmpPayload():
502502

503503
def checkFalsePositives(injection):
504504
"""
505-
Checks for false positives
505+
Checks for false positives (only in single special cases)
506506
"""
507507

508508
retVal = injection
@@ -521,7 +521,8 @@ def checkFalsePositives(injection):
521521
while randInt1 == randInt2:
522522
randInt2 = int(randomInt(2)) + 1
523523

524-
# simple arithmetic operations like in Turing tests
524+
# simple arithmetic operations which should show basic
525+
# arithmetic ability of the backend if it's really injectable
525526
if not checkBooleanExpression("(%d+%d)=%d" % (randInt1, randInt2, randInt1 + randInt2)):
526527
retVal = None
527528
elif checkBooleanExpression("%d=%d" % (randInt1, randInt2)):

lib/controller/controller.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from lib.core.session import setInjection
4949
from lib.core.settings import EMPTY_FORM_FIELDS_REGEX
5050
from lib.core.settings import IGNORE_PARAMETERS
51+
from lib.core.settings import LOW_TEXT_PERCENT
5152
from lib.core.settings import REFERER_ALIASES
5253
from lib.core.settings import USER_AGENT_ALIASES
5354
from lib.core.target import initTargetEnv
@@ -424,6 +425,8 @@ def start():
424425
logger.warn(warnMsg)
425426

426427
else:
428+
kb.foundDynamicParameter = True
429+
427430
infoMsg = "%s parameter '%s' is dynamic" % (place, parameter)
428431
logger.info(infoMsg)
429432

@@ -469,7 +472,7 @@ def start():
469472
errMsg += "(e.g. GET parameter 'id' in 'www.site.com/index.php?id=1')"
470473
raise sqlmapNoneDataException, errMsg
471474
elif not conf.realTest:
472-
errMsg = "all parameters are not injectable."
475+
errMsg = "all parameters appear to be not injectable."
473476

474477
if conf.level < 5 or conf.risk < 3:
475478
errMsg += " Try to increase --level/--risk values "
@@ -480,10 +483,19 @@ def start():
480483

481484
if not conf.textOnly and kb.originalPage:
482485
percent = (100.0 * len(getFilteredPageContent(kb.originalPage)) / len(kb.originalPage))
483-
errMsg += " Give it a go with the --text-only switch "
484-
errMsg += "if the target page has a low percentage of "
485-
errMsg += "textual content (~%.2f%% of " % percent
486-
errMsg += "page content is text)."
486+
487+
if kb.dynamicParameters:
488+
errMsg += " Give it a go with the --text-only switch "
489+
errMsg += "if the target page has a low percentage of "
490+
errMsg += "textual content (~%.2f%% of " % percent
491+
errMsg += "page content is text)."
492+
elif percent < LOW_TEXT_PERCENT:
493+
errMsg = " Please retry with the --text-only switch "
494+
errMsg += "as this case looks like a perfect candidate "
495+
errMsg += "(low textual content along with inability "
496+
errMsg += "of comparison engine to detect at least "
497+
errMsg += "one dynamic parameter)."
498+
raise sqlmapNoneDataException, errMsg
487499

488500
if not conf.string and not conf.regexp:
489501
errMsg += " Rerun by providing either a valid --string "

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
13411341
kb.dep = None
13421342
kb.docRoot = None
13431343
kb.dynamicMarkings = []
1344+
kb.dynamicParameters = False
13441345
kb.endDetection = False
13451346
kb.httpErrorCodes = {}
13461347
kb.errorIsNone = True

lib/core/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,6 @@
339339

340340
# Default ports used in Tor proxy bundles
341341
DEFAULT_TOR_PORTS = (8118, 8123)
342+
343+
# Percentage below which comparison engine could have problems
344+
LOW_TEXT_PERCENT = 20

0 commit comments

Comments
 (0)