removing obsolete switches (--threshold, --excl-reg, --excl-str)

This commit is contained in:
Miroslav Stampar 2011-02-03 15:55:19 +00:00
parent 253a8d0679
commit b56a77e573
6 changed files with 4 additions and 58 deletions

View File

@ -286,7 +286,7 @@ def start():
if (len(kb.injections) == 0 or (len(kb.injections) == 1 and kb.injections[0].place is None)) \ if (len(kb.injections) == 0 or (len(kb.injections) == 1 and kb.injections[0].place is None)) \
and (kb.injection.place is None or kb.injection.parameter is None): and (kb.injection.place is None or kb.injection.parameter is None):
if not conf.string and not conf.regexp and not conf.eRegexp: if not conf.string and not conf.regexp:
# NOTE: this is not needed anymore, leaving only to display # NOTE: this is not needed anymore, leaving only to display
# a warning message to the user in case the page is not stable # a warning message to the user in case the page is not stable
checkStability() checkStability()

View File

@ -1384,10 +1384,6 @@ def __basicOptionValidation():
errMsg = "value for --cpu-throttle (cpuThrottle) option must be in range [0,100]" errMsg = "value for --cpu-throttle (cpuThrottle) option must be in range [0,100]"
raise sqlmapSyntaxException, errMsg raise sqlmapSyntaxException, errMsg
if conf.thold is not None and isinstance(conf.thold, float) and (conf.thold > 1 or conf.cpuThrottle < 0):
errMsg = "value for --threshold (thold) option must be in range [0,1]"
raise sqlmapSyntaxException, errMsg
if conf.textOnly and conf.nullConnection: if conf.textOnly and conf.nullConnection:
errMsg = "switch --text-only is incompatible with switch --null-connection" errMsg = "switch --text-only is incompatible with switch --null-connection"
raise sqlmapSyntaxException, errMsg raise sqlmapSyntaxException, errMsg

View File

@ -67,9 +67,6 @@ optDict = {
"risk": "integer", "risk": "integer",
"string": "string", "string": "string",
"regexp": "string", "regexp": "string",
"eString": "string",
"eRegexp": "string",
"thold": "float",
"textOnly": "boolean" "textOnly": "boolean"
}, },

View File

@ -201,17 +201,6 @@ def cmdLineParser():
help="Regexp to match in page when the " help="Regexp to match in page when the "
"query is valid") "query is valid")
detection.add_option("--excl-str", dest="eString",
help="String to be excluded before comparing "
"page contents")
detection.add_option("--excl-reg", dest="eRegexp",
help="Matches to be excluded before "
"comparing page contents")
detection.add_option("--threshold", dest="thold", type="float",
help="Page comparison threshold value (0.0-1.0)")
detection.add_option("--text-only", dest="textOnly", detection.add_option("--text-only", dest="textOnly",
action="store_true", default=False, action="store_true", default=False,
help="Compare pages based only on their textual content") help="Compare pages based only on their textual content")

View File

@ -34,26 +34,6 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
seqMatcher.set_seq1(kb.pageTemplate) seqMatcher.set_seq1(kb.pageTemplate)
if page: if page:
# String to be excluded before calculating page hash
if conf.eString and conf.eString in page:
index = page.index(conf.eString)
length = len(conf.eString)
pageWithoutString = page[:index]
pageWithoutString += page[index+length:]
page = pageWithoutString
# Regular expression matches to be excluded before calculating page hash
if conf.eRegexp:
regExpResults = re.findall(conf.eRegexp, page, re.I | re.M)
if regExpResults:
for regExpResult in regExpResults:
index = page.index(regExpResult)
length = len(regExpResult)
pageWithoutRegExp = page[:index]
pageWithoutRegExp += page[index+length:]
page = pageWithoutRegExp
# String to match in page when the query is valid # String to match in page when the query is valid
if conf.string: if conf.string:
return conf.string in page return conf.string in page
@ -77,7 +57,7 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
if conf.textOnly: if conf.textOnly:
(seqMatcher.a, page) = map(getFilteredPageContent, (seqMatcher.a, page)) (seqMatcher.a, page) = map(getFilteredPageContent, (seqMatcher.a, page))
if not conf.eRegexp and not conf.eString and kb.nullConnection and pageLength: if kb.nullConnection and pageLength:
ratio = 1. * pageLength / len(seqMatcher.a) ratio = 1. * pageLength / len(seqMatcher.a)
if ratio > 1.: if ratio > 1.:
@ -89,10 +69,7 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
# If the url is stable and we did not set yet the match ratio and the # If the url is stable and we did not set yet the match ratio and the
# current injected value changes the url page content # current injected value changes the url page content
if kb.matchRatio is None: if kb.matchRatio is None:
if conf.thold: if kb.pageStable and ratio >= LOWER_RATIO_BOUND and ratio <= UPPER_RATIO_BOUND:
kb.matchRatio = conf.thold
elif kb.pageStable and ratio >= LOWER_RATIO_BOUND and ratio <= UPPER_RATIO_BOUND:
kb.matchRatio = ratio kb.matchRatio = ratio
logger.debug("setting match ratio for current parameter to %.3f" % kb.matchRatio) logger.debug("setting match ratio for current parameter to %.3f" % kb.matchRatio)
@ -112,7 +89,7 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
return None return None
else: else:
if kb.matchRatio == CONSTANT_RATIO or conf.thold: if kb.matchRatio == CONSTANT_RATIO:
return ratio > kb.matchRatio return ratio > kb.matchRatio
else: else:
return (ratio - kb.matchRatio) > DIFF_TOLERANCE return (ratio - kb.matchRatio) > DIFF_TOLERANCE

View File

@ -220,19 +220,6 @@ string =
# (http://www.python.org/doc/2.5.2/lib/re-syntax.html) # (http://www.python.org/doc/2.5.2/lib/re-syntax.html)
regexp = regexp =
# String to be excluded by the page content before comparing to the original page
eString =
# Regular expression matches to be excluded by the page content before
# comparing to the original page
# Valid: regular expression with Python syntax
# (http://www.python.org/doc/2.5.2/lib/re-syntax.html)
eRegexp =
# Page comparison threshold value.
# Valid: 0.0-1.0
thold =
# Compare pages based only on their textual content # Compare pages based only on their textual content
# Valid: True or False # Valid: True or False
textOnly = False textOnly = False