added --text-only switch

This commit is contained in:
Miroslav Stampar 2010-10-12 19:41:29 +00:00
parent 47022071cb
commit d2ec132469
5 changed files with 16 additions and 5 deletions

View File

@ -29,6 +29,7 @@ import time
from difflib import SequenceMatcher from difflib import SequenceMatcher
from lib.core.agent import agent from lib.core.agent import agent
from lib.core.common import getFilteredPageContent
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import preparePageForLineComparison from lib.core.common import preparePageForLineComparison
from lib.core.common import randomInt from lib.core.common import randomInt
@ -376,7 +377,7 @@ def checkConnection():
try: try:
page, _ = Request.getPage() page, _ = Request.getPage()
conf.seqMatcher.set_seq1(page) conf.seqMatcher.set_seq1(page if not conf.textOnly else getFilteredPageContent(page))
except sqlmapConnectionException, errMsg: except sqlmapConnectionException, errMsg:
errMsg = getUnicode(errMsg) errMsg = getUnicode(errMsg)

View File

@ -98,9 +98,6 @@ def start():
if not conf.start: if not conf.start:
return False return False
if conf.optimize:
conf.useCommonPrediction = conf.useNullConnection = conf.keepAlive = True
if conf.direct: if conf.direct:
initTargetEnv() initTargetEnv()
setupTargetEnv() setupTargetEnv()

View File

@ -938,6 +938,10 @@ def __cleanupOptions():
if conf.googleDork or conf.list: if conf.googleDork or conf.list:
conf.multipleTargets = True conf.multipleTargets = True
if conf.optimize:
conf.useCommonPrediction = conf.keepAlive = True
conf.useNullConnection = not conf.textOnly
def __setConfAttributes(): def __setConfAttributes():
""" """
This function set some needed attributes into the configuration 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]" errMsg = "value for --ratio (matchRatio) option must be in range [0,1]"
raise sqlmapSyntaxException, errMsg 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()): def init(inputOptions=advancedDict()):
""" """
Set attributes into both configuration and knowledge base singletons Set attributes into both configuration and knowledge base singletons

View File

@ -193,6 +193,10 @@ def cmdLineParser():
injection.add_option("--threshold", dest="thold", type="float", injection.add_option("--threshold", dest="thold", type="float",
help="Page comparison threshold value (0.0-1.0)") 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", injection.add_option("--space", dest="space",
help="Use defined string for space instead of standard ' '") help="Use defined string for space instead of standard ' '")

View File

@ -24,6 +24,7 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import re import re
from lib.core.common import getFilteredPageContent
from lib.core.common import preparePageForLineComparison from lib.core.common import preparePageForLineComparison
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
@ -84,7 +85,7 @@ def comparison(page, headers=None, getSeqMatcher=False, pageLength=None):
if ratio > 1.: if ratio > 1.:
ratio = 1. / ratio ratio = 1. / ratio
else: else:
conf.seqMatcher.set_seq2(page) conf.seqMatcher.set_seq2(page if not conf.textOnly else getFilteredPageContent(page))
ratio = round(conf.seqMatcher.ratio(), 3) ratio = round(conf.seqMatcher.ratio(), 3)
if conf.seqLock: if conf.seqLock: