mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 17:46:37 +03:00
code refactoring
This commit is contained in:
parent
252ef7626f
commit
5f9b6b2254
|
@ -8,7 +8,7 @@ See the file 'doc/COPYING' for copying permission
|
|||
"""
|
||||
|
||||
from lib.controller.handler import setHandler
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import dataToStdout
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
|
@ -32,7 +32,7 @@ def action():
|
|||
setHandler()
|
||||
|
||||
if not kb.dbmsDetected or not conf.dbmsHandler:
|
||||
htmlParsed = getHtmlErrorFp()
|
||||
htmlParsed = getErrorParsedDBMSesFormatted()
|
||||
|
||||
errMsg = "sqlmap was not able to fingerprint the "
|
||||
errMsg += "back-end database management system"
|
||||
|
|
|
@ -16,7 +16,8 @@ from lib.core.common import beep
|
|||
from lib.core.common import extractRegexResult
|
||||
from lib.core.common import findDynamicContent
|
||||
from lib.core.common import getCompiledRegex
|
||||
from lib.core.common import getErrorParsedDBMS
|
||||
from lib.core.common import getErrorParsedDBMSes
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import getInjectionTests
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import popValue
|
||||
|
@ -140,9 +141,9 @@ def checkSqlInjection(place, parameter, value):
|
|||
|
||||
continue
|
||||
|
||||
if getErrorParsedDBMS() and getErrorParsedDBMS() != dbms\
|
||||
if getErrorParsedDBMSes() and dbms not in getErrorParsedDBMSes()\
|
||||
and kb.skipTests is None:
|
||||
message = "parsed error message(s) showed that the back-end DBMS could be '%s'." % getErrorParsedDBMS()
|
||||
message = "parsed error message(s) showed that the back-end DBMS could be '%s'." % getErrorParsedDBMSesFormatted()
|
||||
message += " do you want to skip test payloads specific for other DBMSes? [Y/n]"
|
||||
kb.skipTests = conf.realTest or readInput(message, default="Y") not in ("n", "N")
|
||||
|
||||
|
@ -150,7 +151,7 @@ def checkSqlInjection(place, parameter, value):
|
|||
debugMsg = "skipping test '%s' because " % title
|
||||
debugMsg += "the parsed error message(s) showed "
|
||||
debugMsg += "that the back-end DBMS could be "
|
||||
debugMsg += "%s" % getErrorParsedDBMS()
|
||||
debugMsg += "%s" % getErrorParsedDBMSesFormatted()
|
||||
logger.debug(debugMsg)
|
||||
|
||||
continue
|
||||
|
@ -473,7 +474,7 @@ def heuristicCheckSqlInjection(place, parameter, value):
|
|||
infoMsg += "parameter '%s' might " % parameter
|
||||
|
||||
if result:
|
||||
infoMsg += "be injectable (possible DBMS: %s)" % (getErrorParsedDBMS() or 'Unknown')
|
||||
infoMsg += "be injectable (possible DBMS: %s)" % (getErrorParsedDBMSesFormatted() or 'Unknown')
|
||||
logger.info(infoMsg)
|
||||
else:
|
||||
infoMsg += "not be injectable"
|
||||
|
|
|
@ -7,7 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
|
|||
See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
from lib.core.common import getErrorParsedDBMS
|
||||
from lib.core.common import getErrorParsedDBMSes
|
||||
from lib.core.common import popValue
|
||||
from lib.core.common import pushValue
|
||||
from lib.core.data import conf
|
||||
|
@ -63,7 +63,7 @@ def setHandler():
|
|||
( SYBASE_ALIASES, SybaseMap, SybaseConn ),
|
||||
]
|
||||
|
||||
inferencedDbms = getErrorParsedDBMS() or kb.dbms
|
||||
inferencedDbms = (getErrorParsedDBMSes()[0] if getErrorParsedDBMSes() else '') or kb.dbms
|
||||
|
||||
for injection in kb.injections:
|
||||
if hasattr(injection, "dbms") and injection.dbms:
|
||||
|
|
|
@ -282,7 +282,7 @@ def formatFingerprint(target, info):
|
|||
|
||||
return infoStr
|
||||
|
||||
def getHtmlErrorFp():
|
||||
def getErrorParsedDBMSesFormatted():
|
||||
"""
|
||||
This function parses the knowledge base htmlFp list and return its
|
||||
values formatted as a human readable string.
|
||||
|
@ -1919,11 +1919,10 @@ def getInjectionTests():
|
|||
detected DBMS from error messages
|
||||
"""
|
||||
retVal = conf.tests
|
||||
if getErrorParsedDBMS():
|
||||
dbms = getErrorParsedDBMS()
|
||||
if getErrorParsedDBMSes():
|
||||
retVal = sorted(retVal, key=lambda test: False\
|
||||
if 'details' in test and 'dbms' in test.details\
|
||||
and test.details.dbms == dbms else True)
|
||||
and test.details.dbms in getErrorParsedDBMSes() else True)
|
||||
|
||||
return retVal
|
||||
|
||||
|
@ -1954,8 +1953,8 @@ def unicodeToSafeHTMLValue(value):
|
|||
retVal = retVal.replace(char, "&#%d;" % ord(char))
|
||||
return retVal
|
||||
|
||||
def getErrorParsedDBMS():
|
||||
return kb.htmlFp[0] if kb.htmlFp else None
|
||||
def getErrorParsedDBMSes():
|
||||
return kb.htmlFp
|
||||
|
||||
def showHttpErrorCodes():
|
||||
if kb.httpErrorCodes:
|
||||
|
|
|
@ -13,7 +13,7 @@ from lib.core.agent import agent
|
|||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getCurrentThreadData
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import randomStr
|
||||
from lib.core.common import wasLastRequestDBMSError
|
||||
|
@ -138,7 +138,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -12,7 +12,7 @@ import re
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import randomRange
|
||||
|
@ -64,7 +64,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -12,7 +12,7 @@ import re
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import randomRange
|
||||
|
@ -93,7 +93,7 @@ class Fingerprint(GenericFingerprint):
|
|||
if kb.bannerFp:
|
||||
value += "\n%sbanner parsing fingerprint: -" % blank
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -10,7 +10,7 @@ See the file 'doc/COPYING' for copying permission
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
|
@ -64,7 +64,7 @@ class Fingerprint(GenericFingerprint):
|
|||
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -12,7 +12,7 @@ import re
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
|
@ -133,7 +133,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -12,7 +12,7 @@ import re
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
|
@ -56,7 +56,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -12,7 +12,7 @@ import re
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
|
@ -59,7 +59,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -10,7 +10,7 @@ See the file 'doc/COPYING' for copying permission
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
|
@ -55,7 +55,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
|
@ -10,7 +10,7 @@ See the file 'doc/COPYING' for copying permission
|
|||
from lib.core.agent import agent
|
||||
from lib.core.common import formatDBMSfp
|
||||
from lib.core.common import formatFingerprint
|
||||
from lib.core.common import getHtmlErrorFp
|
||||
from lib.core.common import getErrorParsedDBMSesFormatted
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
|
@ -55,7 +55,7 @@ class Fingerprint(GenericFingerprint):
|
|||
banVer = formatDBMSfp([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = getHtmlErrorFp()
|
||||
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
|
|
Loading…
Reference in New Issue
Block a user