mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-09 22:21:30 +00:00
refactoring, code clearing and removal of obsolete switch --longest-common
This commit is contained in:
@@ -1943,7 +1943,20 @@ def initTechnique(technique=None):
|
||||
|
||||
if data:
|
||||
kb.pageTemplate, kb.errorIsNone = getPageTemplate(data.templatePayload, kb.injection.place)
|
||||
kb.matchRatio = data.matchRatio
|
||||
|
||||
kb.matchRatio = data.conf.matchRatio
|
||||
if data.conf.textOnly:
|
||||
conf.textOnly = True
|
||||
debugMsg = "restoring switch --text-only"
|
||||
logger.debug(debugMsg)
|
||||
if data.conf.string:
|
||||
conf.string = data.conf.string
|
||||
debugMsg = "restoring option --string '%s'" % data.conf.string
|
||||
logger.debug(debugMsg)
|
||||
if data.conf.regexp:
|
||||
conf.regexp = data.conf.regexp
|
||||
debugMsg = "restoring option --regexp '%s'" % data.conf.regexp
|
||||
logger.debug(debugMsg)
|
||||
else:
|
||||
warnMsg = "there is no injection data available for technique "
|
||||
warnMsg += "'%s'" % enumValueToNameLookup(PAYLOAD.TECHNIQUE, technique)
|
||||
|
||||
@@ -80,3 +80,4 @@ class injectionDict(advancedDict):
|
||||
self.dbms = None
|
||||
self.dbms_version = None
|
||||
self.os = None
|
||||
|
||||
|
||||
@@ -1045,7 +1045,7 @@ def __cleanupOptions():
|
||||
if conf.optimize:
|
||||
#conf.predictOutput = True
|
||||
conf.keepAlive = True
|
||||
conf.nullConnection = not (conf.textOnly or conf.longestCommon)
|
||||
conf.nullConnection = not conf.textOnly
|
||||
conf.threads = 4 if conf.threads < 2 else conf.threads
|
||||
|
||||
if conf.realTest:
|
||||
@@ -1320,10 +1320,6 @@ def __basicOptionValidation():
|
||||
errMsg = "switch --text-only is incompatible with switch --null-connection"
|
||||
raise sqlmapSyntaxException, errMsg
|
||||
|
||||
if conf.longestCommon and conf.nullConnection:
|
||||
errMsg = "switch --longest-common is incompatible with switch --null-connection"
|
||||
raise sqlmapSyntaxException, errMsg
|
||||
|
||||
if conf.data and conf.nullConnection:
|
||||
errMsg = "switch --data is incompatible with switch --null-connection"
|
||||
raise sqlmapSyntaxException, errMsg
|
||||
|
||||
@@ -70,8 +70,7 @@ optDict = {
|
||||
"eString": "string",
|
||||
"eRegexp": "string",
|
||||
"thold": "float",
|
||||
"textOnly": "boolean",
|
||||
"longestCommon": "boolean"
|
||||
"textOnly": "boolean"
|
||||
},
|
||||
|
||||
"Techniques": {
|
||||
|
||||
@@ -42,48 +42,6 @@ def unSafeFormatString(value):
|
||||
retVal = retVal.replace("__LEFT_SQUARE_BRACKET__", "[").replace("__RIGHT_SQUARE_BRACKET__", "]")
|
||||
return retVal
|
||||
|
||||
def setTextOnly():
|
||||
"""
|
||||
Save text only option to session file.
|
||||
"""
|
||||
|
||||
condition = (
|
||||
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
|
||||
not kb.resumedQueries[conf.url].has_key("Text only") )
|
||||
)
|
||||
|
||||
if condition:
|
||||
dataToSessionFile("[%s][None][None][Text only][True]\n" % conf.url)
|
||||
|
||||
kb.originalPage = getFilteredPageContent(kb.originalPage)
|
||||
kb.pageTemplates.clear()
|
||||
|
||||
def setString():
|
||||
"""
|
||||
Save string to match in session file.
|
||||
"""
|
||||
|
||||
condition = (
|
||||
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
|
||||
not kb.resumedQueries[conf.url].has_key("String") )
|
||||
)
|
||||
|
||||
if condition:
|
||||
dataToSessionFile("[%s][None][None][String][%s]\n" % (conf.url, safeFormatString(conf.string)))
|
||||
|
||||
def setRegexp():
|
||||
"""
|
||||
Save regular expression to match in session file.
|
||||
"""
|
||||
|
||||
condition = (
|
||||
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
|
||||
not kb.resumedQueries[conf.url].has_key("Regular expression") )
|
||||
)
|
||||
|
||||
if condition:
|
||||
dataToSessionFile("[%s][None][None][Regular expression][%s]\n" % (conf.url, safeFormatString(conf.regexp)))
|
||||
|
||||
def setInjection(inj):
|
||||
"""
|
||||
Save information retrieved about injection place and parameter in the
|
||||
@@ -202,23 +160,7 @@ def setRemoteTempPath():
|
||||
dataToSessionFile("[%s][%s][%s][Remote temp path][%s]\n" % (conf.url, kb.injection.place, safeFormatString(conf.parameters[kb.injection.place]), safeFormatString(conf.tmpPath)))
|
||||
|
||||
def resumeConfKb(expression, url, value):
|
||||
if expression == "Text only" and url == conf.url:
|
||||
value = unSafeFormatString(value[:-1])
|
||||
|
||||
logMsg = "resuming text only option '%s' from session file" % value
|
||||
logger.info(logMsg)
|
||||
|
||||
if value and not conf.textOnly:
|
||||
message = "you did not turned on --text-only switch this time "
|
||||
message += "which could potentially lead to different "
|
||||
message += "and/or unstable results. "
|
||||
message += "Do you want to turn it on? [Y/n] "
|
||||
test = readInput(message, default="Y")
|
||||
|
||||
if not test or test[0] in ("y", "Y"):
|
||||
conf.textOnly = value
|
||||
|
||||
elif expression == "String" and url == conf.url:
|
||||
if expression == "String" and url == conf.url:
|
||||
string = unSafeFormatString(value[:-1])
|
||||
|
||||
logMsg = "resuming string match '%s' from session file" % string
|
||||
|
||||
@@ -30,7 +30,6 @@ from lib.core.exception import sqlmapSyntaxException
|
||||
from lib.core.option import __setDBMS
|
||||
from lib.core.option import __setKnowledgeBaseAttributes
|
||||
from lib.core.session import resumeConfKb
|
||||
from lib.core.session import setTextOnly
|
||||
from lib.core.xmldump import dumper as xmldumper
|
||||
from lib.request.connect import Connect as Request
|
||||
|
||||
@@ -265,13 +264,6 @@ def __createTargetDirs():
|
||||
__createFilesDir()
|
||||
__configureDumper()
|
||||
|
||||
def __saveSwitches():
|
||||
"""
|
||||
Store critical switches to the session file.
|
||||
"""
|
||||
if conf.textOnly:
|
||||
setTextOnly()
|
||||
|
||||
def __restoreCmdLineOptions():
|
||||
"""
|
||||
Restore command line options that could be possibly
|
||||
@@ -302,4 +294,3 @@ def setupTargetEnv():
|
||||
__createTargetDirs()
|
||||
__setRequestParams()
|
||||
__setOutputResume()
|
||||
__saveSwitches()
|
||||
|
||||
Reference in New Issue
Block a user