mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-26 03:23:48 +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.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.common import dataToStdout
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
|
@ -32,7 +32,7 @@ def action():
|
||||||
setHandler()
|
setHandler()
|
||||||
|
|
||||||
if not kb.dbmsDetected or not conf.dbmsHandler:
|
if not kb.dbmsDetected or not conf.dbmsHandler:
|
||||||
htmlParsed = getHtmlErrorFp()
|
htmlParsed = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
errMsg = "sqlmap was not able to fingerprint the "
|
errMsg = "sqlmap was not able to fingerprint the "
|
||||||
errMsg += "back-end database management system"
|
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 extractRegexResult
|
||||||
from lib.core.common import findDynamicContent
|
from lib.core.common import findDynamicContent
|
||||||
from lib.core.common import getCompiledRegex
|
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 getInjectionTests
|
||||||
from lib.core.common import getUnicode
|
from lib.core.common import getUnicode
|
||||||
from lib.core.common import popValue
|
from lib.core.common import popValue
|
||||||
|
@ -140,9 +141,9 @@ def checkSqlInjection(place, parameter, value):
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if getErrorParsedDBMS() and getErrorParsedDBMS() != dbms\
|
if getErrorParsedDBMSes() and dbms not in getErrorParsedDBMSes()\
|
||||||
and kb.skipTests is None:
|
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]"
|
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")
|
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 = "skipping test '%s' because " % title
|
||||||
debugMsg += "the parsed error message(s) showed "
|
debugMsg += "the parsed error message(s) showed "
|
||||||
debugMsg += "that the back-end DBMS could be "
|
debugMsg += "that the back-end DBMS could be "
|
||||||
debugMsg += "%s" % getErrorParsedDBMS()
|
debugMsg += "%s" % getErrorParsedDBMSesFormatted()
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
@ -473,7 +474,7 @@ def heuristicCheckSqlInjection(place, parameter, value):
|
||||||
infoMsg += "parameter '%s' might " % parameter
|
infoMsg += "parameter '%s' might " % parameter
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
infoMsg += "be injectable (possible DBMS: %s)" % (getErrorParsedDBMS() or 'Unknown')
|
infoMsg += "be injectable (possible DBMS: %s)" % (getErrorParsedDBMSesFormatted() or 'Unknown')
|
||||||
logger.info(infoMsg)
|
logger.info(infoMsg)
|
||||||
else:
|
else:
|
||||||
infoMsg += "not be injectable"
|
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
|
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 popValue
|
||||||
from lib.core.common import pushValue
|
from lib.core.common import pushValue
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
|
@ -63,7 +63,7 @@ def setHandler():
|
||||||
( SYBASE_ALIASES, SybaseMap, SybaseConn ),
|
( SYBASE_ALIASES, SybaseMap, SybaseConn ),
|
||||||
]
|
]
|
||||||
|
|
||||||
inferencedDbms = getErrorParsedDBMS() or kb.dbms
|
inferencedDbms = (getErrorParsedDBMSes()[0] if getErrorParsedDBMSes() else '') or kb.dbms
|
||||||
|
|
||||||
for injection in kb.injections:
|
for injection in kb.injections:
|
||||||
if hasattr(injection, "dbms") and injection.dbms:
|
if hasattr(injection, "dbms") and injection.dbms:
|
||||||
|
|
|
@ -282,7 +282,7 @@ def formatFingerprint(target, info):
|
||||||
|
|
||||||
return infoStr
|
return infoStr
|
||||||
|
|
||||||
def getHtmlErrorFp():
|
def getErrorParsedDBMSesFormatted():
|
||||||
"""
|
"""
|
||||||
This function parses the knowledge base htmlFp list and return its
|
This function parses the knowledge base htmlFp list and return its
|
||||||
values formatted as a human readable string.
|
values formatted as a human readable string.
|
||||||
|
@ -1919,11 +1919,10 @@ def getInjectionTests():
|
||||||
detected DBMS from error messages
|
detected DBMS from error messages
|
||||||
"""
|
"""
|
||||||
retVal = conf.tests
|
retVal = conf.tests
|
||||||
if getErrorParsedDBMS():
|
if getErrorParsedDBMSes():
|
||||||
dbms = getErrorParsedDBMS()
|
|
||||||
retVal = sorted(retVal, key=lambda test: False\
|
retVal = sorted(retVal, key=lambda test: False\
|
||||||
if 'details' in test and 'dbms' in test.details\
|
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
|
return retVal
|
||||||
|
|
||||||
|
@ -1954,8 +1953,8 @@ def unicodeToSafeHTMLValue(value):
|
||||||
retVal = retVal.replace(char, "&#%d;" % ord(char))
|
retVal = retVal.replace(char, "&#%d;" % ord(char))
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def getErrorParsedDBMS():
|
def getErrorParsedDBMSes():
|
||||||
return kb.htmlFp[0] if kb.htmlFp else None
|
return kb.htmlFp
|
||||||
|
|
||||||
def showHttpErrorCodes():
|
def showHttpErrorCodes():
|
||||||
if kb.httpErrorCodes:
|
if kb.httpErrorCodes:
|
||||||
|
|
|
@ -13,7 +13,7 @@ from lib.core.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
from lib.core.common import formatFingerprint
|
||||||
from lib.core.common import getCurrentThreadData
|
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 randomInt
|
||||||
from lib.core.common import randomStr
|
from lib.core.common import randomStr
|
||||||
from lib.core.common import wasLastRequestDBMSError
|
from lib.core.common import wasLastRequestDBMSError
|
||||||
|
@ -138,7 +138,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 getUnicode
|
||||||
from lib.core.common import randomInt
|
from lib.core.common import randomInt
|
||||||
from lib.core.common import randomRange
|
from lib.core.common import randomRange
|
||||||
|
@ -64,7 +64,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 getUnicode
|
||||||
from lib.core.common import randomInt
|
from lib.core.common import randomInt
|
||||||
from lib.core.common import randomRange
|
from lib.core.common import randomRange
|
||||||
|
@ -93,7 +93,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
if kb.bannerFp:
|
if kb.bannerFp:
|
||||||
value += "\n%sbanner parsing fingerprint: -" % blank
|
value += "\n%sbanner parsing fingerprint: -" % blank
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 getUnicode
|
||||||
from lib.core.common import randomInt
|
from lib.core.common import randomInt
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
|
@ -64,7 +64,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
|
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 getUnicode
|
||||||
from lib.core.common import randomInt
|
from lib.core.common import randomInt
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
|
@ -133,7 +133,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
|
@ -56,7 +56,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 getUnicode
|
||||||
from lib.core.common import randomInt
|
from lib.core.common import randomInt
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
|
@ -59,7 +59,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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 conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
|
@ -55,7 +55,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, 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.agent import agent
|
||||||
from lib.core.common import formatDBMSfp
|
from lib.core.common import formatDBMSfp
|
||||||
from lib.core.common import formatFingerprint
|
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.common import randomInt
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
|
@ -55,7 +55,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
banVer = formatDBMSfp([banVer])
|
banVer = formatDBMSfp([banVer])
|
||||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||||
|
|
||||||
htmlErrorFp = getHtmlErrorFp()
|
htmlErrorFp = getErrorParsedDBMSesFormatted()
|
||||||
|
|
||||||
if htmlErrorFp:
|
if htmlErrorFp:
|
||||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user