From 057ec8a6b2ba6d59d2635ede3920cec6a9309321 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 10 Aug 2010 19:53:29 +0000 Subject: [PATCH] added --ratio option for direct manipulation of conf.matchRatio parameter --- lib/core/option.py | 6 +++++- lib/parse/cmdline.py | 3 +++ lib/request/comparison.py | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 3da56adea..c3f4746d9 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -943,7 +943,6 @@ def __setConfAttributes(): conf.httpHeaders = [] conf.hostname = None conf.loggedToOut = None - conf.matchRatio = None conf.md5hash = None conf.multipleTargets = False conf.outputPath = None @@ -1136,6 +1135,11 @@ def __basicOptionValidation(): errMsg = "value for --cpu-throttle (cpuThrottle) option must be in range [0,100]" raise sqlmapSyntaxException, errMsg + if conf.matchRatio is not None and isinstance(conf.matchRatio, float) and (conf.matchRatio > 1 or\ + conf.cpuThrottle < 0): + errMsg = "value for --ratio (matchRatio) option must be in range [0,1]" + raise sqlmapSyntaxException, errMsg + def init(inputOptions=advancedDict()): """ Set attributes into both configuration and knowledge base singletons diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 8bcfe6b54..78ded3629 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -187,6 +187,9 @@ def cmdLineParser(): help="Matches to be excluded before " "comparing page contents") + injection.add_option("--ratio", dest="matchRatio", type="float", + help="Page comparison treshold value") + injection.add_option("--use-between", dest="useBetween", action="store_true", help="Use operator BETWEEN instead of default '>'") diff --git a/lib/request/comparison.py b/lib/request/comparison.py index ef02ef690..99dfda594 100644 --- a/lib/request/comparison.py +++ b/lib/request/comparison.py @@ -79,8 +79,8 @@ def comparison(page, headers=None, getSeqMatcher=False): logger.debug("setting match ratio to default value 0.900") conf.matchRatio = 0.900 - if conf.matchRatio is not None: - setMatchRatio() + if conf.matchRatio is not None: + setMatchRatio() # If it has been requested to return the ratio and not a comparison # response