diff --git a/lib/controller/checks.py b/lib/controller/checks.py index ce2767988..0a923f71f 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -29,6 +29,7 @@ import time from difflib import SequenceMatcher from lib.core.agent import agent +from lib.core.common import getFilteredPageContent from lib.core.common import getUnicode from lib.core.common import preparePageForLineComparison from lib.core.common import randomInt @@ -376,7 +377,7 @@ def checkConnection(): try: page, _ = Request.getPage() - conf.seqMatcher.set_seq1(page) + conf.seqMatcher.set_seq1(page if not conf.textOnly else getFilteredPageContent(page)) except sqlmapConnectionException, errMsg: errMsg = getUnicode(errMsg) diff --git a/lib/controller/controller.py b/lib/controller/controller.py index 6e7ae9571..f9a827610 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -98,9 +98,6 @@ def start(): if not conf.start: return False - if conf.optimize: - conf.useCommonPrediction = conf.useNullConnection = conf.keepAlive = True - if conf.direct: initTargetEnv() setupTargetEnv() diff --git a/lib/core/option.py b/lib/core/option.py index da4d25978..547115143 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -938,6 +938,10 @@ def __cleanupOptions(): if conf.googleDork or conf.list: conf.multipleTargets = True + if conf.optimize: + conf.useCommonPrediction = conf.keepAlive = True + conf.useNullConnection = not conf.textOnly + def __setConfAttributes(): """ This function set some needed attributes into the configuration @@ -1162,6 +1166,10 @@ def __basicOptionValidation(): errMsg = "value for --ratio (matchRatio) option must be in range [0,1]" raise sqlmapSyntaxException, errMsg + if conf.textOnly and conf.useNullConnection: + errMsg = "switch --text-only is incompatible with switch --null-connection" + 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 bcf87f340..e241187aa 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -193,6 +193,10 @@ def cmdLineParser(): injection.add_option("--threshold", dest="thold", type="float", help="Page comparison threshold value (0.0-1.0)") + injection.add_option("--text-only", dest="textOnly", + action="store_true", default=False, + help="Compare pages based only on their textual content") + injection.add_option("--space", dest="space", help="Use defined string for space instead of standard ' '") diff --git a/lib/request/comparison.py b/lib/request/comparison.py index 47de1f7d2..19ddc0b43 100644 --- a/lib/request/comparison.py +++ b/lib/request/comparison.py @@ -24,6 +24,7 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import re +from lib.core.common import getFilteredPageContent from lib.core.common import preparePageForLineComparison from lib.core.data import conf from lib.core.data import kb @@ -84,7 +85,7 @@ def comparison(page, headers=None, getSeqMatcher=False, pageLength=None): if ratio > 1.: ratio = 1. / ratio else: - conf.seqMatcher.set_seq2(page) + conf.seqMatcher.set_seq2(page if not conf.textOnly else getFilteredPageContent(page)) ratio = round(conf.seqMatcher.ratio(), 3) if conf.seqLock: