mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-20 14:39:02 +00:00
refactoring (class names should always be Capital cased)
This commit is contained in:
@@ -10,8 +10,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import getCurrentThreadData
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import randomStr
|
||||
@@ -38,9 +38,9 @@ class Fingerprint(GenericFingerprint):
|
||||
retVal = None
|
||||
table = None
|
||||
|
||||
if backend.isVersionWithin(("97", "2000")):
|
||||
if Backend.isVersionWithin(("97", "2000")):
|
||||
table = "MSysAccessObjects"
|
||||
elif backend.isVersionWithin(("2002-2003", "2007")):
|
||||
elif Backend.isVersionWithin(("2002-2003", "2007")):
|
||||
table = "MSysAccessStorage"
|
||||
|
||||
if table is not None:
|
||||
@@ -115,13 +115,13 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
@@ -132,7 +132,7 @@ class Fingerprint(GenericFingerprint):
|
||||
value += DBMS.ACCESS
|
||||
return value
|
||||
|
||||
actVer = format.getDbms() + " (%s)" % (self.__sandBoxCheck())
|
||||
actVer = Format.getDbms() + " (%s)" % (self.__sandBoxCheck())
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
@@ -142,10 +142,10 @@ class Fingerprint(GenericFingerprint):
|
||||
if re.search("-log$", kb.data.banner):
|
||||
banVer += ", logging enabled"
|
||||
|
||||
banVer = format.getDbms([banVer])
|
||||
banVer = Format.getDbms([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -155,7 +155,7 @@ class Fingerprint(GenericFingerprint):
|
||||
return value
|
||||
|
||||
def checkDbms(self):
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(ACCESS_ALIASES) or conf.dbms in ACCESS_ALIASES):
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(ACCESS_ALIASES) or conf.dbms in ACCESS_ALIASES):
|
||||
setDbms(DBMS.ACCESS)
|
||||
|
||||
return True
|
||||
@@ -187,7 +187,7 @@ class Fingerprint(GenericFingerprint):
|
||||
version = self.__sysTablesCheck()
|
||||
|
||||
if version is not None:
|
||||
backend.setVersion(version)
|
||||
Backend.setVersion(version)
|
||||
|
||||
return True
|
||||
else:
|
||||
|
||||
@@ -10,8 +10,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import randomRange
|
||||
@@ -34,25 +34,25 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
|
||||
value += "back-end DBMS: "
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
|
||||
if not conf.extensiveFp:
|
||||
value += actVer
|
||||
return value
|
||||
|
||||
actVer = format.getDbms() + " (%s)" % (self.__dialectCheck())
|
||||
actVer = Format.getDbms() + " (%s)" % (self.__dialectCheck())
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
@@ -62,10 +62,10 @@ class Fingerprint(GenericFingerprint):
|
||||
if re.search("-log$", kb.data.banner):
|
||||
banVer += ", logging enabled"
|
||||
|
||||
banVer = format.getDbms([banVer])
|
||||
banVer = Format.getDbms([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -101,23 +101,23 @@ class Fingerprint(GenericFingerprint):
|
||||
def __dialectCheck(self):
|
||||
retVal = None
|
||||
|
||||
if backend.getIdentifiedDbms():
|
||||
if Backend.getIdentifiedDbms():
|
||||
result = inject.checkBooleanExpression("EXISTS(SELECT CURRENT_DATE FROM RDB$DATABASE)")
|
||||
retVal = "dialect 3" if result else "dialect 1"
|
||||
|
||||
return retVal
|
||||
|
||||
def checkDbms(self):
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(FIREBIRD_ALIASES) \
|
||||
or conf.dbms in FIREBIRD_ALIASES) and backend.getVersion() and \
|
||||
backend.getVersion() != UNKNOWN_DBMS_VERSION:
|
||||
v = backend.getVersion().replace(">", "")
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(FIREBIRD_ALIASES) \
|
||||
or conf.dbms in FIREBIRD_ALIASES) and Backend.getVersion() and \
|
||||
Backend.getVersion() != UNKNOWN_DBMS_VERSION:
|
||||
v = Backend.getVersion().replace(">", "")
|
||||
v = v.replace("=", "")
|
||||
v = v.replace(" ", "")
|
||||
|
||||
backend.setVersion(v)
|
||||
Backend.setVersion(v)
|
||||
|
||||
setDbms("%s %s" % (DBMS.FIREBIRD, backend.getVersion()))
|
||||
setDbms("%s %s" % (DBMS.FIREBIRD, Backend.getVersion()))
|
||||
|
||||
self.getBanner()
|
||||
|
||||
@@ -149,7 +149,7 @@ class Fingerprint(GenericFingerprint):
|
||||
version = self.__sysTablesCheck()
|
||||
|
||||
if version is not None:
|
||||
backend.setVersion(version)
|
||||
Backend.setVersion(version)
|
||||
setDbms("%s %s" % (DBMS.FIREBIRD, version))
|
||||
|
||||
self.getBanner()
|
||||
|
||||
@@ -10,8 +10,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import randomRange
|
||||
from lib.core.data import conf
|
||||
@@ -66,13 +66,13 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
@@ -84,14 +84,14 @@ class Fingerprint(GenericFingerprint):
|
||||
value += DBMS.MAXDB
|
||||
return value
|
||||
|
||||
actVer = format.getDbms() + " (%s)" % self.__versionCheck()
|
||||
actVer = Format.getDbms() + " (%s)" % self.__versionCheck()
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
if kb.bannerFp:
|
||||
value += "\n%sbanner parsing fingerprint: -" % blank
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -99,7 +99,7 @@ class Fingerprint(GenericFingerprint):
|
||||
return value
|
||||
|
||||
def checkDbms(self):
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(MAXDB_ALIASES) or conf.dbms in MAXDB_ALIASES):
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(MAXDB_ALIASES) or conf.dbms in MAXDB_ALIASES):
|
||||
setDbms(DBMS.MAXDB)
|
||||
|
||||
self.getBanner()
|
||||
|
||||
@@ -9,7 +9,7 @@ See the file 'doc/COPYING' for copying permission
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import arrayizeValue
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import getRange
|
||||
from lib.core.common import isNumPosStrValue
|
||||
from lib.core.common import isTechniqueAvailable
|
||||
@@ -41,7 +41,7 @@ class Enumeration(GenericEnumeration):
|
||||
infoMsg += " for database '%s'" % conf.db
|
||||
logger.info(infoMsg)
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].tables
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].tables
|
||||
|
||||
if not conf.db:
|
||||
if not len(kb.data.cachedDbs):
|
||||
@@ -111,7 +111,7 @@ class Enumeration(GenericEnumeration):
|
||||
return kb.data.cachedTables
|
||||
|
||||
def searchTable(self):
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].search_table
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].search_table
|
||||
foundTbls = {}
|
||||
tblList = conf.tbl.split(",")
|
||||
tblCond = rootQuery.inband.condition
|
||||
@@ -198,7 +198,7 @@ class Enumeration(GenericEnumeration):
|
||||
return foundTbls
|
||||
|
||||
def searchColumn(self):
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].search_column
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].search_column
|
||||
foundCols = {}
|
||||
dbs = {}
|
||||
colList = conf.col.split(",")
|
||||
|
||||
@@ -8,8 +8,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
@@ -30,19 +30,19 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
|
||||
value += "back-end DBMS: "
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
|
||||
if not conf.extensiveFp:
|
||||
value += actVer
|
||||
@@ -63,7 +63,7 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -71,10 +71,10 @@ class Fingerprint(GenericFingerprint):
|
||||
return value
|
||||
|
||||
def checkDbms(self):
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(MSSQL_ALIASES) \
|
||||
or conf.dbms in MSSQL_ALIASES) and backend.getVersion() and \
|
||||
backend.getVersion().isdigit():
|
||||
setDbms("%s %s" % (DBMS.MSSQL, backend.getVersion()))
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(MSSQL_ALIASES) \
|
||||
or conf.dbms in MSSQL_ALIASES) and Backend.getVersion() and \
|
||||
Backend.getVersion().isdigit():
|
||||
setDbms("%s %s" % (DBMS.MSSQL, Backend.getVersion()))
|
||||
|
||||
self.getBanner()
|
||||
|
||||
@@ -103,10 +103,10 @@ class Fingerprint(GenericFingerprint):
|
||||
result = inject.checkBooleanExpression(check)
|
||||
|
||||
if result:
|
||||
backend.setVersion(version)
|
||||
Backend.setVersion(version)
|
||||
|
||||
if backend.getVersion():
|
||||
setDbms("%s %s" % (DBMS.MSSQL, backend.getVersion()))
|
||||
if Backend.getVersion():
|
||||
setDbms("%s %s" % (DBMS.MSSQL, Backend.getVersion()))
|
||||
else:
|
||||
setDbms(DBMS.MSSQL)
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
@@ -97,19 +97,19 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
|
||||
value += "back-end DBMS: "
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
|
||||
if not conf.extensiveFp:
|
||||
value += actVer
|
||||
@@ -120,7 +120,7 @@ class Fingerprint(GenericFingerprint):
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
if comVer:
|
||||
comVer = format.getDbms([comVer])
|
||||
comVer = Format.getDbms([comVer])
|
||||
value += "\n%scomment injection fingerprint: %s" % (blank, comVer)
|
||||
|
||||
if kb.bannerFp:
|
||||
@@ -129,10 +129,10 @@ class Fingerprint(GenericFingerprint):
|
||||
if re.search("-log$", kb.data.banner):
|
||||
banVer += ", logging enabled"
|
||||
|
||||
banVer = format.getDbms([banVer] if banVer else None)
|
||||
banVer = Format.getDbms([banVer] if banVer else None)
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -150,18 +150,18 @@ class Fingerprint(GenericFingerprint):
|
||||
* http://dev.mysql.com/doc/refman/6.0/en/news-6-0-x.html (manual has been withdrawn)
|
||||
"""
|
||||
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(MYSQL_ALIASES) \
|
||||
or conf.dbms in MYSQL_ALIASES) and backend.getVersion() and \
|
||||
backend.getVersion() != UNKNOWN_DBMS_VERSION:
|
||||
v = backend.getVersion().replace(">", "")
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(MYSQL_ALIASES) \
|
||||
or conf.dbms in MYSQL_ALIASES) and Backend.getVersion() and \
|
||||
Backend.getVersion() != UNKNOWN_DBMS_VERSION:
|
||||
v = Backend.getVersion().replace(">", "")
|
||||
v = v.replace("=", "")
|
||||
v = v.replace(" ", "")
|
||||
|
||||
backend.setVersion(v)
|
||||
Backend.setVersion(v)
|
||||
|
||||
setDbms("%s %s" % (DBMS.MYSQL, backend.getVersion()))
|
||||
setDbms("%s %s" % (DBMS.MYSQL, Backend.getVersion()))
|
||||
|
||||
if backend.isVersionGreaterOrEqualThan("5"):
|
||||
if Backend.isVersionGreaterOrEqualThan("5"):
|
||||
kb.data.has_information_schema = True
|
||||
|
||||
self.getBanner()
|
||||
@@ -190,7 +190,7 @@ class Fingerprint(GenericFingerprint):
|
||||
#if inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.TABLES LIMIT 0, 1)" % (randInt, randInt)):
|
||||
if inject.checkBooleanExpression("EXISTS(SELECT %s FROM information_schema.TABLES)" % randInt):
|
||||
kb.data.has_information_schema = True
|
||||
backend.setVersion(">= 5.0.0")
|
||||
Backend.setVersion(">= 5.0.0")
|
||||
setDbms("%s 5" % DBMS.MYSQL)
|
||||
self.getBanner()
|
||||
|
||||
@@ -202,43 +202,43 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
# Check if it is MySQL >= 5.5.0
|
||||
if inject.checkBooleanExpression("TO_SECONDS(950501)>0"):
|
||||
backend.setVersion(">= 5.5.0")
|
||||
Backend.setVersion(">= 5.5.0")
|
||||
|
||||
# Check if it is MySQL >= 5.1.2 and < 5.5.0
|
||||
elif inject.checkBooleanExpression("@@table_open_cache=@@table_open_cache"):
|
||||
if inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.GLOBAL_STATUS LIMIT 0, 1)" % (randInt, randInt)):
|
||||
backend.setVersionList([">= 5.1.12", "< 5.5.0"])
|
||||
Backend.setVersionList([">= 5.1.12", "< 5.5.0"])
|
||||
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PROCESSLIST LIMIT 0, 1)" % (randInt,randInt)):
|
||||
backend.setVersionList([">= 5.1.7", "< 5.1.12"])
|
||||
Backend.setVersionList([">= 5.1.7", "< 5.1.12"])
|
||||
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PARTITIONS LIMIT 0, 1)" % (randInt, randInt)):
|
||||
backend.setVersion("= 5.1.6")
|
||||
Backend.setVersion("= 5.1.6")
|
||||
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PLUGINS LIMIT 0, 1)" % (randInt, randInt)):
|
||||
backend.setVersionList([">= 5.1.5", "< 5.1.6"])
|
||||
Backend.setVersionList([">= 5.1.5", "< 5.1.6"])
|
||||
else:
|
||||
backend.setVersionList([">= 5.1.2", "< 5.1.5"])
|
||||
Backend.setVersionList([">= 5.1.2", "< 5.1.5"])
|
||||
|
||||
# Check if it is MySQL >= 5.0.0 and < 5.1.2
|
||||
elif inject.checkBooleanExpression("@@hostname=@@hostname"):
|
||||
backend.setVersionList([">= 5.0.38", "< 5.1.2"])
|
||||
Backend.setVersionList([">= 5.0.38", "< 5.1.2"])
|
||||
elif inject.checkBooleanExpression("@@character_set_filesystem=@@character_set_filesystem"):
|
||||
backend.setVersionList([">= 5.0.19", "< 5.0.38"])
|
||||
Backend.setVersionList([">= 5.0.19", "< 5.0.38"])
|
||||
elif not inject.checkBooleanExpression("%s=(SELECT %s FROM DUAL WHERE %s!=%s)" % (randInt, randInt, randInt, randInt)):
|
||||
backend.setVersionList([">= 5.0.11", "< 5.0.19"])
|
||||
Backend.setVersionList([">= 5.0.11", "< 5.0.19"])
|
||||
elif inject.checkBooleanExpression("@@div_precision_increment=@@div_precision_increment"):
|
||||
backend.setVersionList([">= 5.0.6", "< 5.0.11"])
|
||||
Backend.setVersionList([">= 5.0.6", "< 5.0.11"])
|
||||
elif inject.checkBooleanExpression("@@automatic_sp_privileges=@@automatic_sp_privileges"):
|
||||
backend.setVersionList([">= 5.0.3", "< 5.0.6"])
|
||||
Backend.setVersionList([">= 5.0.3", "< 5.0.6"])
|
||||
else:
|
||||
backend.setVersionList([">= 5.0.0", "< 5.0.3"])
|
||||
Backend.setVersionList([">= 5.0.0", "< 5.0.3"])
|
||||
|
||||
# For cases when information_schema is missing
|
||||
elif inject.checkBooleanExpression("DATABASE() LIKE SCHEMA()"):
|
||||
backend.setVersion(">= 5.0.2")
|
||||
Backend.setVersion(">= 5.0.2")
|
||||
setDbms("%s 5" % DBMS.MYSQL)
|
||||
self.getBanner()
|
||||
|
||||
elif inject.checkBooleanExpression("STRCMP(LOWER(CURRENT_USER()), UPPER(CURRENT_USER()))=0"):
|
||||
backend.setVersion("< 5.0.0")
|
||||
Backend.setVersion("< 5.0.0")
|
||||
setDbms("%s 4" % DBMS.MYSQL)
|
||||
self.getBanner()
|
||||
|
||||
@@ -247,20 +247,20 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
# Check which version of MySQL < 5.0.0 it is
|
||||
if inject.checkBooleanExpression("3=(SELECT COERCIBILITY(USER()))"):
|
||||
backend.setVersionList([">= 4.1.11", "< 5.0.0"])
|
||||
Backend.setVersionList([">= 4.1.11", "< 5.0.0"])
|
||||
elif inject.checkBooleanExpression("2=(SELECT COERCIBILITY(USER()))"):
|
||||
backend.setVersionList([">= 4.1.1", "< 4.1.11"])
|
||||
Backend.setVersionList([">= 4.1.1", "< 4.1.11"])
|
||||
elif inject.checkBooleanExpression("CURRENT_USER()=CURRENT_USER()"):
|
||||
backend.setVersionList([">= 4.0.6", "< 4.1.1"])
|
||||
Backend.setVersionList([">= 4.0.6", "< 4.1.1"])
|
||||
|
||||
if inject.checkBooleanExpression("'utf8'=(SELECT CHARSET(CURRENT_USER()))"):
|
||||
backend.setVersion("= 4.1.0")
|
||||
Backend.setVersion("= 4.1.0")
|
||||
else:
|
||||
backend.setVersionList([">= 4.0.6", "< 4.1.0"])
|
||||
Backend.setVersionList([">= 4.0.6", "< 4.1.0"])
|
||||
else:
|
||||
backend.setVersionList([">= 4.0.0", "< 4.0.6"])
|
||||
Backend.setVersionList([">= 4.0.0", "< 4.0.6"])
|
||||
else:
|
||||
backend.setVersion("< 4.0.0")
|
||||
Backend.setVersion("< 4.0.0")
|
||||
setDbms("%s 3" % DBMS.MYSQL)
|
||||
self.getBanner()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import getRange
|
||||
from lib.core.common import isNumPosStrValue
|
||||
from lib.core.common import isTechniqueAvailable
|
||||
@@ -30,7 +30,7 @@ class Enumeration(GenericEnumeration):
|
||||
def getRoles(self, query2=False):
|
||||
infoMsg = "fetching database users roles"
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].roles
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].roles
|
||||
|
||||
if conf.user == "CU":
|
||||
infoMsg += " for current user"
|
||||
@@ -179,7 +179,7 @@ class Enumeration(GenericEnumeration):
|
||||
return []
|
||||
|
||||
def searchColumn(self):
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].search_column
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].search_column
|
||||
foundCols = {}
|
||||
dbs = { "USERS": {} }
|
||||
colList = conf.col.split(",")
|
||||
|
||||
@@ -10,8 +10,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
@@ -29,13 +29,13 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
@@ -46,16 +46,16 @@ class Fingerprint(GenericFingerprint):
|
||||
value += DBMS.ORACLE
|
||||
return value
|
||||
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
if kb.bannerFp:
|
||||
banVer = kb.bannerFp["dbmsVersion"] if 'dbmsVersion' in kb.bannerFp else None
|
||||
banVer = format.getDbms([banVer])
|
||||
banVer = Format.getDbms([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -63,7 +63,7 @@ class Fingerprint(GenericFingerprint):
|
||||
return value
|
||||
|
||||
def checkDbms(self):
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(ORACLE_ALIASES) or conf.dbms in ORACLE_ALIASES):
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(ORACLE_ALIASES) or conf.dbms in ORACLE_ALIASES):
|
||||
setDbms(DBMS.ORACLE)
|
||||
|
||||
self.getBanner()
|
||||
@@ -112,7 +112,7 @@ class Fingerprint(GenericFingerprint):
|
||||
output = inject.checkBooleanExpression("%d=(SELECT SUBSTR((VERSION), 1, %d) FROM SYS.PRODUCT_COMPONENT_VERSION WHERE ROWNUM=1)" % (number, 1 if number < 10 else 2))
|
||||
|
||||
if output:
|
||||
backend.setVersion(version)
|
||||
Backend.setVersion(version)
|
||||
break
|
||||
|
||||
return True
|
||||
|
||||
@@ -10,8 +10,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
@@ -32,13 +32,13 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
@@ -49,16 +49,16 @@ class Fingerprint(GenericFingerprint):
|
||||
value += DBMS.PGSQL
|
||||
return value
|
||||
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
if kb.bannerFp:
|
||||
banVer = kb.bannerFp["dbmsVersion"] if 'dbmsVersion' in kb.bannerFp else None
|
||||
banVer = format.getDbms([banVer])
|
||||
banVer = Format.getDbms([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -72,7 +72,7 @@ class Fingerprint(GenericFingerprint):
|
||||
* http://www.postgresql.org/docs/8.4/interactive/release.html (up to 8.4.2)
|
||||
"""
|
||||
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(PGSQL_ALIASES) or conf.dbms in PGSQL_ALIASES):
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(PGSQL_ALIASES) or conf.dbms in PGSQL_ALIASES):
|
||||
setDbms(DBMS.PGSQL)
|
||||
|
||||
self.getBanner()
|
||||
@@ -108,35 +108,35 @@ class Fingerprint(GenericFingerprint):
|
||||
logger.info(infoMsg)
|
||||
|
||||
if inject.checkBooleanExpression("2=(SELECT DIV(6, 3))"):
|
||||
backend.setVersion(">= 8.4.0")
|
||||
Backend.setVersion(">= 8.4.0")
|
||||
elif inject.checkBooleanExpression("EXTRACT(ISODOW FROM CURRENT_TIMESTAMP)<8"):
|
||||
backend.setVersionList([">= 8.3.0", "< 8.4"])
|
||||
Backend.setVersionList([">= 8.3.0", "< 8.4"])
|
||||
elif inject.checkBooleanExpression("ISFINITE(TRANSACTION_TIMESTAMP())"):
|
||||
backend.setVersionList([">= 8.2.0", "< 8.3.0"])
|
||||
Backend.setVersionList([">= 8.2.0", "< 8.3.0"])
|
||||
elif inject.checkBooleanExpression("9=(SELECT GREATEST(5, 9, 1))"):
|
||||
backend.setVersionList([">= 8.1.0", "< 8.2.0"])
|
||||
Backend.setVersionList([">= 8.1.0", "< 8.2.0"])
|
||||
elif inject.checkBooleanExpression("3=(SELECT WIDTH_BUCKET(5.35, 0.024, 10.06, 5))"):
|
||||
backend.setVersionList([">= 8.0.0", "< 8.1.0"])
|
||||
Backend.setVersionList([">= 8.0.0", "< 8.1.0"])
|
||||
elif inject.checkBooleanExpression("'d'=(SELECT SUBSTR(MD5('sqlmap'), 1, 1))"):
|
||||
backend.setVersionList([">= 7.4.0", "< 8.0.0"])
|
||||
Backend.setVersionList([">= 7.4.0", "< 8.0.0"])
|
||||
elif inject.checkBooleanExpression("'p'=(SELECT SUBSTR(CURRENT_SCHEMA(), 1, 1))"):
|
||||
backend.setVersionList([">= 7.3.0", "< 7.4.0"])
|
||||
Backend.setVersionList([">= 7.3.0", "< 7.4.0"])
|
||||
elif inject.checkBooleanExpression("8=(SELECT BIT_LENGTH(1))"):
|
||||
backend.setVersionList([">= 7.2.0", "< 7.3.0"])
|
||||
Backend.setVersionList([">= 7.2.0", "< 7.3.0"])
|
||||
elif inject.checkBooleanExpression("'a'=(SELECT SUBSTR(QUOTE_LITERAL('a'), 2, 1))"):
|
||||
backend.setVersionList([">= 7.1.0", "< 7.2.0"])
|
||||
Backend.setVersionList([">= 7.1.0", "< 7.2.0"])
|
||||
elif inject.checkBooleanExpression("8=(SELECT POW(2, 3))"):
|
||||
backend.setVersionList([">= 7.0.0", "< 7.1.0"])
|
||||
Backend.setVersionList([">= 7.0.0", "< 7.1.0"])
|
||||
elif inject.checkBooleanExpression("'a'=(SELECT MAX('a'))"):
|
||||
backend.setVersionList([">= 6.5.0", "< 6.5.3"])
|
||||
Backend.setVersionList([">= 6.5.0", "< 6.5.3"])
|
||||
elif inject.checkBooleanExpression("VERSION()=VERSION()"):
|
||||
backend.setVersionList([">= 6.4.0", "< 6.5.0"])
|
||||
Backend.setVersionList([">= 6.4.0", "< 6.5.0"])
|
||||
elif inject.checkBooleanExpression("2=(SELECT SUBSTR(CURRENT_DATE, 1, 1))"):
|
||||
backend.setVersionList([">= 6.3.0", "< 6.4.0"])
|
||||
Backend.setVersionList([">= 6.3.0", "< 6.4.0"])
|
||||
elif inject.checkBooleanExpression("'s'=(SELECT SUBSTRING('sqlmap', 1, 1))"):
|
||||
backend.setVersionList([">= 6.2.0", "< 6.3.0"])
|
||||
Backend.setVersionList([">= 6.2.0", "< 6.3.0"])
|
||||
else:
|
||||
backend.setVersion("< 6.2.0")
|
||||
Backend.setVersion("< 6.2.0")
|
||||
|
||||
return True
|
||||
else:
|
||||
|
||||
@@ -8,8 +8,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
@@ -28,13 +28,13 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
@@ -45,16 +45,16 @@ class Fingerprint(GenericFingerprint):
|
||||
value += DBMS.SQLITE
|
||||
return value
|
||||
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
if kb.bannerFp:
|
||||
banVer = kb.bannerFp["dbmsVersion"]
|
||||
banVer = format.getDbms([banVer])
|
||||
banVer = Format.getDbms([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -69,7 +69,7 @@ class Fingerprint(GenericFingerprint):
|
||||
* http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
|
||||
"""
|
||||
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(SQLITE_ALIASES) or conf.dbms in SQLITE_ALIASES):
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(SQLITE_ALIASES) or conf.dbms in SQLITE_ALIASES):
|
||||
setDbms(DBMS.SQLITE)
|
||||
|
||||
self.getBanner()
|
||||
@@ -98,7 +98,7 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
result = inject.checkBooleanExpression("RANDOMBLOB(-1)>0")
|
||||
version = '3' if result else '2'
|
||||
backend.setVersion(version)
|
||||
Backend.setVersion(version)
|
||||
|
||||
setDbms(DBMS.SQLITE)
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import format
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import Format
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
@@ -28,13 +28,13 @@ class Fingerprint(GenericFingerprint):
|
||||
|
||||
def getFingerprint(self):
|
||||
value = ""
|
||||
wsOsFp = format.getOs("web server", kb.headersFp)
|
||||
wsOsFp = Format.getOs("web server", kb.headersFp)
|
||||
|
||||
if wsOsFp:
|
||||
value += "%s\n" % wsOsFp
|
||||
|
||||
if kb.data.banner:
|
||||
dbmsOsFp = format.getOs("back-end DBMS", kb.bannerFp)
|
||||
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
||||
|
||||
if dbmsOsFp:
|
||||
value += "%s\n" % dbmsOsFp
|
||||
@@ -45,16 +45,16 @@ class Fingerprint(GenericFingerprint):
|
||||
value += DBMS.SYBASE
|
||||
return value
|
||||
|
||||
actVer = format.getDbms()
|
||||
actVer = Format.getDbms()
|
||||
blank = " " * 15
|
||||
value += "active fingerprint: %s" % actVer
|
||||
|
||||
if kb.bannerFp:
|
||||
banVer = kb.bannerFp["dbmsVersion"]
|
||||
banVer = format.getDbms([banVer])
|
||||
banVer = Format.getDbms([banVer])
|
||||
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
||||
|
||||
htmlErrorFp = format.getErrorParsedDBMSes()
|
||||
htmlErrorFp = Format.getErrorParsedDBMSes()
|
||||
|
||||
if htmlErrorFp:
|
||||
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
||||
@@ -62,10 +62,10 @@ class Fingerprint(GenericFingerprint):
|
||||
return value
|
||||
|
||||
def checkDbms(self):
|
||||
if not conf.extensiveFp and (backend.isDbmsWithin(SYBASE_ALIASES) \
|
||||
or conf.dbms in SYBASE_ALIASES) and backend.getVersion() and \
|
||||
backend.getVersion().isdigit():
|
||||
setDbms("%s %s" % (DBMS.SYBASE, backend.getVersion()))
|
||||
if not conf.extensiveFp and (Backend.isDbmsWithin(SYBASE_ALIASES) \
|
||||
or conf.dbms in SYBASE_ALIASES) and Backend.getVersion() and \
|
||||
Backend.getVersion().isdigit():
|
||||
setDbms("%s %s" % (DBMS.SYBASE, Backend.getVersion()))
|
||||
|
||||
self.getBanner()
|
||||
|
||||
@@ -107,7 +107,7 @@ class Fingerprint(GenericFingerprint):
|
||||
result = inject.checkBooleanExpression("@@VERSION_NUMBER/1000=%d" % version)
|
||||
|
||||
if result:
|
||||
backend.setVersion(str(version))
|
||||
Backend.setVersion(str(version))
|
||||
break
|
||||
|
||||
return True
|
||||
|
||||
@@ -12,13 +12,13 @@ import time
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import arrayizeValue
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import dataToStdout
|
||||
from lib.core.common import getRange
|
||||
from lib.core.common import getCompiledRegex
|
||||
from lib.core.common import getConsoleWidth
|
||||
from lib.core.common import getFileItems
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import isNumPosStrValue
|
||||
from lib.core.common import isTechniqueAvailable
|
||||
@@ -86,7 +86,7 @@ class Enumeration:
|
||||
infoMsg = "fetching banner"
|
||||
logger.info(infoMsg)
|
||||
|
||||
query = queries[backend.getIdentifiedDbms()].banner.query
|
||||
query = queries[Backend.getIdentifiedDbms()].banner.query
|
||||
kb.data.banner = inject.getValue(query)
|
||||
bannerParser(kb.data.banner)
|
||||
|
||||
@@ -108,7 +108,7 @@ class Enumeration:
|
||||
infoMsg = "fetching current user"
|
||||
logger.info(infoMsg)
|
||||
|
||||
query = queries[backend.getIdentifiedDbms()].current_user.query
|
||||
query = queries[Backend.getIdentifiedDbms()].current_user.query
|
||||
|
||||
if not kb.data.currentUser:
|
||||
kb.data.currentUser = inject.getValue(query)
|
||||
@@ -119,7 +119,7 @@ class Enumeration:
|
||||
infoMsg = "fetching current database"
|
||||
logger.info(infoMsg)
|
||||
|
||||
query = queries[backend.getIdentifiedDbms()].current_db.query
|
||||
query = queries[Backend.getIdentifiedDbms()].current_db.query
|
||||
|
||||
if not kb.data.currentDb:
|
||||
kb.data.currentDb = inject.getValue(query)
|
||||
@@ -130,11 +130,11 @@ class Enumeration:
|
||||
infoMsg = "testing if current user is DBA"
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
self.getCurrentUser()
|
||||
query = queries[backend.getIdentifiedDbms()].is_dba.query % kb.data.currentUser.split("@")[0]
|
||||
query = queries[Backend.getIdentifiedDbms()].is_dba.query % kb.data.currentUser.split("@")[0]
|
||||
else:
|
||||
query = queries[backend.getIdentifiedDbms()].is_dba.query
|
||||
query = queries[Backend.getIdentifiedDbms()].is_dba.query
|
||||
|
||||
query = agent.forgeCaseStatement(query)
|
||||
|
||||
@@ -146,10 +146,10 @@ class Enumeration:
|
||||
infoMsg = "fetching database users"
|
||||
logger.info(infoMsg)
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].users
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].users
|
||||
|
||||
condition = ( backend.getIdentifiedDbms() == DBMS.MSSQL and backend.isVersionWithin(("2005", "2008")) )
|
||||
condition |= ( backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema )
|
||||
condition = ( Backend.getIdentifiedDbms() == DBMS.MSSQL and Backend.isVersionWithin(("2005", "2008")) )
|
||||
condition |= ( Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema )
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if condition:
|
||||
@@ -175,14 +175,14 @@ class Enumeration:
|
||||
errMsg = "unable to retrieve the number of database users"
|
||||
raise sqlmapNoneDataException, errMsg
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
plusOne = True
|
||||
else:
|
||||
plusOne = False
|
||||
indexRange = getRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() in (DBMS.SYBASE, DBMS.MAXDB):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.SYBASE, DBMS.MAXDB):
|
||||
query = rootQuery.blind.query % (kb.data.cachedUsers[-1] if kb.data.cachedUsers else " ")
|
||||
elif condition:
|
||||
query = rootQuery.blind.query2 % index
|
||||
@@ -202,7 +202,7 @@ class Enumeration:
|
||||
def getPasswordHashes(self):
|
||||
infoMsg = "fetching database users password hashes"
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].passwords
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].passwords
|
||||
|
||||
if conf.user == "CU":
|
||||
infoMsg += " for current user"
|
||||
@@ -211,7 +211,7 @@ class Enumeration:
|
||||
logger.info(infoMsg)
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if backend.getIdentifiedDbms() == DBMS.MSSQL and backend.isVersionWithin(("2005", "2008")):
|
||||
if Backend.getIdentifiedDbms() == DBMS.MSSQL and Backend.isVersionWithin(("2005", "2008")):
|
||||
query = rootQuery.inband.query2
|
||||
else:
|
||||
query = rootQuery.inband.query
|
||||
@@ -224,7 +224,7 @@ class Enumeration:
|
||||
query += " WHERE "
|
||||
query += " OR ".join("%s = '%s'" % (condition, user) for user in users)
|
||||
else:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
parsedUser = re.search("[\047]*(.*?)[\047]*\@", conf.user)
|
||||
|
||||
if parsedUser:
|
||||
@@ -261,7 +261,7 @@ class Enumeration:
|
||||
retrievedUsers = set()
|
||||
|
||||
for user in users:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
parsedUser = re.search("[\047]*(.*?)[\047]*\@", user)
|
||||
|
||||
if parsedUser:
|
||||
@@ -274,7 +274,7 @@ class Enumeration:
|
||||
infoMsg += "for user '%s'" % user
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MSSQL and backend.isVersionWithin(("2005", "2008")):
|
||||
if Backend.getIdentifiedDbms() == DBMS.MSSQL and Backend.isVersionWithin(("2005", "2008")):
|
||||
query = rootQuery.blind.count2 % user
|
||||
else:
|
||||
query = rootQuery.blind.count % user
|
||||
@@ -291,14 +291,14 @@ class Enumeration:
|
||||
|
||||
passwords = []
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
plusOne = True
|
||||
else:
|
||||
plusOne = False
|
||||
indexRange = getRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
if index > 0:
|
||||
warnMsg = "unable to retrieve other password "
|
||||
warnMsg += "hashes for user '%s'" % user
|
||||
@@ -307,15 +307,15 @@ class Enumeration:
|
||||
else:
|
||||
query = rootQuery.blind.query % user
|
||||
getCurrentThreadData().disableStdOut = True
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
if backend.isVersionWithin(("2005", "2008")):
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
if Backend.isVersionWithin(("2005", "2008")):
|
||||
query = rootQuery.blind.query2 % (user, index, user)
|
||||
else:
|
||||
query = rootQuery.blind.query % (user, index, user)
|
||||
else:
|
||||
query = rootQuery.blind.query % (user, index)
|
||||
password = inject.getValue(query, inband=False, error=False)
|
||||
if backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
getCurrentThreadData().disableStdOut = False
|
||||
password = "0x%s" % strToHex(password)
|
||||
infoMsg = "retrieved: %s" % password
|
||||
@@ -352,31 +352,31 @@ class Enumeration:
|
||||
def __isAdminFromPrivileges(self, privileges):
|
||||
# In PostgreSQL the usesuper privilege means that the
|
||||
# user is DBA
|
||||
dbaCondition = ( backend.getIdentifiedDbms() == DBMS.PGSQL and "super" in privileges )
|
||||
dbaCondition = ( Backend.getIdentifiedDbms() == DBMS.PGSQL and "super" in privileges )
|
||||
|
||||
# In Oracle the DBA privilege means that the
|
||||
# user is DBA
|
||||
dbaCondition |= ( backend.getIdentifiedDbms() == DBMS.ORACLE and "DBA" in privileges )
|
||||
dbaCondition |= ( Backend.getIdentifiedDbms() == DBMS.ORACLE and "DBA" in privileges )
|
||||
|
||||
# In MySQL >= 5.0 the SUPER privilege means
|
||||
# that the user is DBA
|
||||
dbaCondition |= ( backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema and "SUPER" in privileges )
|
||||
dbaCondition |= ( Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema and "SUPER" in privileges )
|
||||
|
||||
# In MySQL < 5.0 the super_priv privilege means
|
||||
# that the user is DBA
|
||||
dbaCondition |= ( backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema and "super_priv" in privileges )
|
||||
dbaCondition |= ( Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema and "super_priv" in privileges )
|
||||
|
||||
# In Firebird there is no specific privilege that means
|
||||
# that the user is DBA
|
||||
# TODO: confirm
|
||||
dbaCondition |= ( backend.getIdentifiedDbms() == DBMS.FIREBIRD and "SELECT" in privileges and "INSERT" in privileges and "UPDATE" in privileges and "DELETE" in privileges and "REFERENCES" in privileges and "EXECUTE" in privileges )
|
||||
dbaCondition |= ( Backend.getIdentifiedDbms() == DBMS.FIREBIRD and "SELECT" in privileges and "INSERT" in privileges and "UPDATE" in privileges and "DELETE" in privileges and "REFERENCES" in privileges and "EXECUTE" in privileges )
|
||||
|
||||
return dbaCondition
|
||||
|
||||
def getPrivileges(self, query2=False):
|
||||
infoMsg = "fetching database users privileges"
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].privileges
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].privileges
|
||||
|
||||
if conf.user == "CU":
|
||||
infoMsg += " for current user"
|
||||
@@ -432,10 +432,10 @@ class Enumeration:
|
||||
}
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.inband.query2
|
||||
condition = rootQuery.inband.condition2
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE and query2:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE and query2:
|
||||
query = rootQuery.inband.query2
|
||||
condition = rootQuery.inband.condition2
|
||||
else:
|
||||
@@ -447,7 +447,7 @@ class Enumeration:
|
||||
query += " WHERE "
|
||||
# NOTE: I assume that the user provided is not in
|
||||
# MySQL >= 5.0 syntax 'user'@'host'
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
queryUser = "%" + conf.user + "%"
|
||||
query += " OR ".join("%s LIKE '%s'" % (condition, "%" + user + "%") for user in users)
|
||||
else:
|
||||
@@ -455,7 +455,7 @@ class Enumeration:
|
||||
|
||||
values = inject.getValue(query, blind=False)
|
||||
|
||||
if not values and backend.getIdentifiedDbms() == DBMS.ORACLE and not query2:
|
||||
if not values and Backend.getIdentifiedDbms() == DBMS.ORACLE and not query2:
|
||||
infoMsg = "trying with table USER_SYS_PRIVS"
|
||||
logger.info(infoMsg)
|
||||
|
||||
@@ -477,19 +477,19 @@ class Enumeration:
|
||||
|
||||
# In PostgreSQL we get 1 if the privilege is
|
||||
# True, 0 otherwise
|
||||
if backend.getIdentifiedDbms() == DBMS.PGSQL and getUnicode(privilege).isdigit():
|
||||
if Backend.getIdentifiedDbms() == DBMS.PGSQL and getUnicode(privilege).isdigit():
|
||||
for position, pgsqlPriv in pgsqlPrivs:
|
||||
if count == position and int(privilege) == 1:
|
||||
privileges.add(pgsqlPriv)
|
||||
|
||||
# In MySQL >= 5.0 and Oracle we get the list
|
||||
# of privileges as string
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE or ( backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema ):
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE or ( Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema ):
|
||||
privileges.add(privilege)
|
||||
|
||||
# In MySQL < 5.0 we get Y if the privilege is
|
||||
# True, N otherwise
|
||||
elif backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
for position, mysqlPriv in mysqlPrivs:
|
||||
if count == position and privilege.upper() == "Y":
|
||||
privileges.add(mysqlPriv)
|
||||
@@ -506,7 +506,7 @@ class Enumeration:
|
||||
conditionChar = "="
|
||||
|
||||
if conf.user:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
conditionChar = " LIKE "
|
||||
|
||||
if "," in conf.user:
|
||||
@@ -533,7 +533,7 @@ class Enumeration:
|
||||
for user in users:
|
||||
unescapedUser = None
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
unescapedUser = unescaper.unescape(user, quote=False)
|
||||
|
||||
if user in retrievedUsers:
|
||||
@@ -548,18 +548,18 @@ class Enumeration:
|
||||
else:
|
||||
queryUser = user
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.blind.count2 % queryUser
|
||||
elif backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
query = rootQuery.blind.count % (conditionChar, queryUser)
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE and query2:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE and query2:
|
||||
query = rootQuery.blind.count2 % queryUser
|
||||
else:
|
||||
query = rootQuery.blind.count % queryUser
|
||||
count = inject.getValue(query, inband=False, error=False, expected=EXPECTED.INT, charsetType=2)
|
||||
|
||||
if not isNumPosStrValue(count):
|
||||
if not (isinstance(count, basestring) and count.isdigit()) and backend.getIdentifiedDbms() == DBMS.ORACLE and not query2:
|
||||
if not (isinstance(count, basestring) and count.isdigit()) and Backend.getIdentifiedDbms() == DBMS.ORACLE and not query2:
|
||||
infoMsg = "trying with table USER_SYS_PRIVS"
|
||||
logger.info(infoMsg)
|
||||
|
||||
@@ -575,20 +575,20 @@ class Enumeration:
|
||||
|
||||
privileges = set()
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
plusOne = True
|
||||
else:
|
||||
plusOne = False
|
||||
indexRange = getRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.blind.query2 % (queryUser, index)
|
||||
elif backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema:
|
||||
query = rootQuery.blind.query % (conditionChar, queryUser, index)
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE and query2:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE and query2:
|
||||
query = rootQuery.blind.query2 % (queryUser, index)
|
||||
elif backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
query = rootQuery.blind.query % (index, queryUser)
|
||||
else:
|
||||
query = rootQuery.blind.query % (queryUser, index)
|
||||
@@ -596,7 +596,7 @@ class Enumeration:
|
||||
|
||||
# In PostgreSQL we get 1 if the privilege is True,
|
||||
# 0 otherwise
|
||||
if backend.getIdentifiedDbms() == DBMS.PGSQL and ", " in privilege:
|
||||
if Backend.getIdentifiedDbms() == DBMS.PGSQL and ", " in privilege:
|
||||
privilege = privilege.replace(", ", ",")
|
||||
privs = privilege.split(",")
|
||||
i = 1
|
||||
@@ -611,12 +611,12 @@ class Enumeration:
|
||||
|
||||
# In MySQL >= 5.0 and Oracle we get the list
|
||||
# of privileges as string
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE or ( backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema ):
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE or ( Backend.getIdentifiedDbms() == DBMS.MYSQL and kb.data.has_information_schema ):
|
||||
privileges.add(privilege)
|
||||
|
||||
# In MySQL < 5.0 we get Y if the privilege is
|
||||
# True, N otherwise
|
||||
elif backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
privilege = privilege.replace(", ", ",")
|
||||
privs = privilege.split(",")
|
||||
i = 1
|
||||
@@ -630,7 +630,7 @@ class Enumeration:
|
||||
i += 1
|
||||
|
||||
# In Firebird we get one letter for each privilege
|
||||
elif backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
privileges.add(firebirdPrivs[privilege.strip()])
|
||||
|
||||
if self.__isAdminFromPrivileges(privileges):
|
||||
@@ -639,7 +639,7 @@ class Enumeration:
|
||||
# In MySQL < 5.0 we break the cycle after the first
|
||||
# time we get the user's privileges otherwise we
|
||||
# duplicate the same query
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
break
|
||||
|
||||
if privileges:
|
||||
@@ -659,14 +659,14 @@ class Enumeration:
|
||||
return ( kb.data.cachedUsersPrivileges, areAdmins )
|
||||
|
||||
def getRoles(self, query2=False):
|
||||
warnMsg = "on %s the concept of roles does not " % backend.getIdentifiedDbms()
|
||||
warnMsg = "on %s the concept of roles does not " % Backend.getIdentifiedDbms()
|
||||
warnMsg += "exist. sqlmap will enumerate privileges instead"
|
||||
logger.warn(warnMsg)
|
||||
|
||||
return self.getPrivileges(query2)
|
||||
|
||||
def getDbs(self):
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
warnMsg = "information_schema not available, "
|
||||
warnMsg += "back-end DBMS is MySQL < 5. database "
|
||||
warnMsg += "names will be fetched from 'mysql' database"
|
||||
@@ -675,10 +675,10 @@ class Enumeration:
|
||||
infoMsg = "fetching database names"
|
||||
logger.info(infoMsg)
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].dbs
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].dbs
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.inband.query2
|
||||
else:
|
||||
query = rootQuery.inband.query
|
||||
@@ -691,7 +691,7 @@ class Enumeration:
|
||||
infoMsg = "fetching number of databases"
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.blind.count2
|
||||
else:
|
||||
query = rootQuery.blind.count
|
||||
@@ -704,9 +704,9 @@ class Enumeration:
|
||||
indexRange = getRange(count)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
query = rootQuery.blind.query % (kb.data.cachedDbs[-1] if kb.data.cachedDbs else " ")
|
||||
elif backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.blind.query2 % index
|
||||
else:
|
||||
query = rootQuery.blind.query % index
|
||||
@@ -726,13 +726,13 @@ class Enumeration:
|
||||
|
||||
self.forceDbmsEnum()
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
errMsg = "information_schema not available, "
|
||||
errMsg += "back-end DBMS is MySQL < 5.0"
|
||||
logger.error(errMsg)
|
||||
bruteForce = True
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
errMsg = "cannot retrieve table names, "
|
||||
errMsg += "back-end DBMS is Access"
|
||||
logger.error(errMsg)
|
||||
@@ -771,7 +771,7 @@ class Enumeration:
|
||||
infoMsg += " for database '%s'" % conf.db
|
||||
logger.info(infoMsg)
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].tables
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].tables
|
||||
|
||||
if conf.db:
|
||||
if "," in conf.db:
|
||||
@@ -789,7 +789,7 @@ class Enumeration:
|
||||
condition = rootQuery.inband.condition if 'condition' in rootQuery.inband else None
|
||||
|
||||
if condition:
|
||||
if conf.db and backend.getIdentifiedDbms() != DBMS.SQLITE:
|
||||
if conf.db and Backend.getIdentifiedDbms() != DBMS.SQLITE:
|
||||
if "," in conf.db:
|
||||
dbs = conf.db.split(",")
|
||||
query += " WHERE "
|
||||
@@ -802,12 +802,12 @@ class Enumeration:
|
||||
infoMsg = "skipping system databases '%s'" % ", ".join(db for db in self.excludeDbsList)
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
||||
query = safeStringFormat(query, conf.db)
|
||||
value = inject.getValue(query, blind=False)
|
||||
|
||||
if value:
|
||||
if backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
if isinstance(value, basestring):
|
||||
value = [[ DBMS.SQLITE, value ]]
|
||||
elif isinstance(value, (list, tuple, set)):
|
||||
@@ -836,7 +836,7 @@ class Enumeration:
|
||||
infoMsg += "database '%s'" % db
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.FIREBIRD, DBMS.MAXDB):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.FIREBIRD, DBMS.MAXDB):
|
||||
query = rootQuery.blind.count
|
||||
else:
|
||||
query = rootQuery.blind.count % db
|
||||
@@ -850,18 +850,18 @@ class Enumeration:
|
||||
|
||||
tables = []
|
||||
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MSSQL, DBMS.ORACLE ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MSSQL, DBMS.ORACLE ):
|
||||
plusOne = True
|
||||
else:
|
||||
plusOne = False
|
||||
indexRange = getRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.SYBASE:
|
||||
query = rootQuery.blind.query % (db, (kb.data.cachedTables[-1] if kb.data.cachedTables else " "))
|
||||
elif backend.getIdentifiedDbms() == DBMS.MAXDB:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MAXDB:
|
||||
query = rootQuery.blind.query % (kb.data.cachedTables[-1] if kb.data.cachedTables else " ")
|
||||
elif backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.FIREBIRD):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.FIREBIRD):
|
||||
query = rootQuery.blind.query % index
|
||||
else:
|
||||
query = rootQuery.blind.query % (db, index)
|
||||
@@ -902,13 +902,13 @@ class Enumeration:
|
||||
|
||||
conf.db = self.getCurrentDb()
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
errMsg = "information_schema not available, "
|
||||
errMsg += "back-end DBMS is MySQL < 5.0"
|
||||
logger.error(errMsg)
|
||||
bruteForce = True
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
errMsg = "cannot retrieve column names, "
|
||||
errMsg += "back-end DBMS is Access"
|
||||
logger.error(errMsg)
|
||||
@@ -959,13 +959,13 @@ class Enumeration:
|
||||
"37":"VARCHAR"
|
||||
}
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].columns
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].columns
|
||||
condition = rootQuery.blind.condition if 'condition' in rootQuery.blind else None
|
||||
|
||||
infoMsg = "fetching columns "
|
||||
|
||||
if conf.col:
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
conf.col = conf.col.upper()
|
||||
colList = conf.col.split(",")
|
||||
condQuery = " AND (" + " OR ".join("%s LIKE '%s'" % (condition, "%" + col + "%") for col in colList) + ")"
|
||||
@@ -978,24 +978,24 @@ class Enumeration:
|
||||
logger.info(infoMsg)
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
query = rootQuery.inband.query % (conf.tbl, conf.db)
|
||||
query += condQuery
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.inband.query % conf.tbl.upper()
|
||||
query += condQuery
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
query = rootQuery.inband.query % (conf.db, conf.db,
|
||||
conf.db, conf.db,
|
||||
conf.db, conf.db,
|
||||
conf.db, conf.tbl)
|
||||
query += condQuery.replace("[DB]", conf.db)
|
||||
elif backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
query = rootQuery.inband.query % conf.tbl
|
||||
|
||||
value = inject.getValue(query, blind=False)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
parseSqliteTableSchema(value)
|
||||
elif value:
|
||||
table = {}
|
||||
@@ -1018,19 +1018,19 @@ class Enumeration:
|
||||
infoMsg += " on database '%s'" % conf.db
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
query = rootQuery.blind.count % (conf.tbl, conf.db)
|
||||
query += condQuery
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.blind.count % conf.tbl.upper()
|
||||
query += condQuery
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
query = rootQuery.blind.count % (conf.db, conf.db, conf.tbl)
|
||||
query += condQuery.replace("[DB]", conf.db)
|
||||
elif backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
query = rootQuery.blind.count % (conf.tbl)
|
||||
query += condQuery
|
||||
elif backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
query = rootQuery.blind.query % conf.tbl
|
||||
value = inject.getValue(query, inband=False, error=False)
|
||||
|
||||
@@ -1052,22 +1052,22 @@ class Enumeration:
|
||||
indexRange = getRange(count)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
query = rootQuery.blind.query % (conf.tbl, conf.db)
|
||||
query += condQuery
|
||||
field = None
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.blind.query % (conf.tbl.upper())
|
||||
query += condQuery
|
||||
field = None
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
query = rootQuery.blind.query % (conf.db, conf.db,
|
||||
conf.db, conf.db,
|
||||
conf.db, conf.db,
|
||||
conf.tbl)
|
||||
query += condQuery.replace("[DB]", conf.db)
|
||||
field = condition.replace("[DB]", conf.db)
|
||||
elif backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
query = rootQuery.blind.query % (conf.tbl)
|
||||
query += condQuery
|
||||
field = None
|
||||
@@ -1076,20 +1076,20 @@ class Enumeration:
|
||||
column = inject.getValue(query, inband=False, error=False)
|
||||
|
||||
if not onlyColNames:
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
query = rootQuery.blind.query2 % (conf.tbl, column, conf.db)
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.blind.query2 % (conf.tbl.upper(), column)
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
query = rootQuery.blind.query2 % (conf.db, conf.db, conf.db,
|
||||
conf.db, column, conf.db,
|
||||
conf.db, conf.db, conf.tbl)
|
||||
elif backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
query = rootQuery.blind.query2 % (conf.tbl, column)
|
||||
|
||||
colType = inject.getValue(query, inband=False, error=False)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
if Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
colType = firebirdTypes[colType] if colType in firebirdTypes else colType
|
||||
|
||||
columns[column] = colType
|
||||
@@ -1135,9 +1135,9 @@ class Enumeration:
|
||||
|
||||
conf.db = self.getCurrentDb()
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].dump_table
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].dump_table
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if '-' in conf.tbl:
|
||||
conf.tbl = "`%s`" % conf.tbl
|
||||
if '-' in conf.db:
|
||||
@@ -1180,9 +1180,9 @@ class Enumeration:
|
||||
entriesCount = 0
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.inband.query % (colString, conf.tbl.upper())
|
||||
elif backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
query = rootQuery.inband.query % (colString, conf.tbl)
|
||||
else:
|
||||
query = rootQuery.inband.query % (colString, conf.db, conf.tbl)
|
||||
@@ -1228,9 +1228,9 @@ class Enumeration:
|
||||
infoMsg += "on database '%s'" % conf.db
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.blind.count % conf.tbl.upper()
|
||||
elif backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.FIREBIRD):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.FIREBIRD):
|
||||
query = rootQuery.blind.count % conf.tbl
|
||||
else:
|
||||
query = rootQuery.blind.count % (conf.db, conf.tbl)
|
||||
@@ -1250,14 +1250,14 @@ class Enumeration:
|
||||
lengths = {}
|
||||
entries = {}
|
||||
|
||||
if backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.MSSQL, DBMS.SYBASE):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.MSSQL, DBMS.SYBASE):
|
||||
plusOne = True
|
||||
else:
|
||||
plusOne = False
|
||||
indexRange = getRange(count, dump=True, plusOne=plusOne)
|
||||
|
||||
try:
|
||||
if backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
validColumnList = False
|
||||
validPivotValue = False
|
||||
|
||||
@@ -1334,22 +1334,22 @@ class Enumeration:
|
||||
if column not in entries:
|
||||
entries[column] = []
|
||||
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
query = rootQuery.blind.query % (column, conf.db,
|
||||
conf.tbl, index)
|
||||
elif backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
query = rootQuery.blind.query % (column, column,
|
||||
conf.tbl.upper(),
|
||||
index)
|
||||
elif backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
||||
query = rootQuery.blind.query % (column, index, conf.db,
|
||||
conf.tbl, colList[0],
|
||||
colList[0], colList[0])
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.SQLITE:
|
||||
query = rootQuery.blind.query % (column, conf.tbl, index)
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
|
||||
query = rootQuery.blind.query % (index, column, conf.tbl)
|
||||
|
||||
value = inject.getValue(query, inband=False, error=False)
|
||||
@@ -1393,7 +1393,7 @@ class Enumeration:
|
||||
return kb.data.dumpedTable
|
||||
|
||||
def dumpAll(self):
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
errMsg = "information_schema not available, "
|
||||
errMsg += "back-end DBMS is MySQL < 5.0"
|
||||
raise sqlmapUnsupportedFeatureException, errMsg
|
||||
@@ -1494,10 +1494,10 @@ class Enumeration:
|
||||
|
||||
def searchDb(self):
|
||||
foundDbs = []
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].search_db
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].search_db
|
||||
dbList = conf.db.split(",")
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
dbCond = rootQuery.inband.condition2
|
||||
else:
|
||||
dbCond = rootQuery.inband.condition
|
||||
@@ -1522,7 +1522,7 @@ class Enumeration:
|
||||
dbQuery = dbQuery % db
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.inband.query2
|
||||
else:
|
||||
query = rootQuery.inband.query
|
||||
@@ -1543,7 +1543,7 @@ class Enumeration:
|
||||
infoMsg += " '%s'" % db
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.blind.count2
|
||||
else:
|
||||
query = rootQuery.blind.count
|
||||
@@ -1563,7 +1563,7 @@ class Enumeration:
|
||||
indexRange = getRange(count)
|
||||
|
||||
for index in indexRange:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
query = rootQuery.blind.query2
|
||||
else:
|
||||
query = rootQuery.blind.query
|
||||
@@ -1578,12 +1578,12 @@ class Enumeration:
|
||||
def searchTable(self):
|
||||
bruteForce = False
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
errMsg = "information_schema not available, "
|
||||
errMsg += "back-end DBMS is MySQL < 5.0"
|
||||
bruteForce = True
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
errMsg = "cannot retrieve table names, "
|
||||
errMsg += "back-end DBMS is Access"
|
||||
logger.error(errMsg)
|
||||
@@ -1601,7 +1601,7 @@ class Enumeration:
|
||||
regex = "|".join(conf.tbl.split(","))
|
||||
return tableExists(paths.COMMON_TABLES, regex)
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].search_table
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].search_table
|
||||
foundTbls = {}
|
||||
tblList = conf.tbl.split(",")
|
||||
tblCond = rootQuery.inband.condition
|
||||
@@ -1610,7 +1610,7 @@ class Enumeration:
|
||||
tblConsider, tblCondParam = self.likeOrExact("table")
|
||||
|
||||
for tbl in tblList:
|
||||
if backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
if Backend.getIdentifiedDbms() == DBMS.ORACLE:
|
||||
tbl = tbl.upper()
|
||||
|
||||
infoMsg = "searching table"
|
||||
@@ -1720,12 +1720,12 @@ class Enumeration:
|
||||
def searchColumn(self):
|
||||
bruteForce = False
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
|
||||
errMsg = "information_schema not available, "
|
||||
errMsg += "back-end DBMS is MySQL < 5.0"
|
||||
bruteForce = True
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.ACCESS:
|
||||
errMsg = "cannot retrieve column names, "
|
||||
errMsg += "back-end DBMS is Access"
|
||||
logger.error(errMsg)
|
||||
@@ -1751,7 +1751,7 @@ class Enumeration:
|
||||
|
||||
return
|
||||
|
||||
rootQuery = queries[backend.getIdentifiedDbms()].search_column
|
||||
rootQuery = queries[Backend.getIdentifiedDbms()].search_column
|
||||
foundCols = {}
|
||||
dbs = {}
|
||||
colList = conf.col.split(",")
|
||||
@@ -1968,7 +1968,7 @@ class Enumeration:
|
||||
return output
|
||||
|
||||
def sqlShell(self):
|
||||
infoMsg = "calling %s shell. To quit type " % backend.getIdentifiedDbms()
|
||||
infoMsg = "calling %s shell. To quit type " % Backend.getIdentifiedDbms()
|
||||
infoMsg += "'x' or 'q' and press ENTER"
|
||||
logger.info(infoMsg)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import os
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import dataToOutFile
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import isTechniqueAvailable
|
||||
from lib.core.common import randomStr
|
||||
from lib.core.common import readInput
|
||||
@@ -87,13 +87,13 @@ class Filesystem:
|
||||
return fileLines
|
||||
|
||||
def __checkWrittenFile(self, wFile, dFile, fileType):
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
lengthQuery = "SELECT LENGTH(LOAD_FILE('%s'))" % dFile
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
lengthQuery = "SELECT LENGTH(data) FROM pg_largeobject WHERE loid=%d" % self.oid
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
self.createSupportTbl(self.fileTblName, self.tblField, "text")
|
||||
|
||||
# Reference: http://msdn.microsoft.com/en-us/library/ms188365.aspx
|
||||
@@ -271,7 +271,7 @@ class Filesystem:
|
||||
|
||||
fileContent = self.unionReadFile(rFile)
|
||||
|
||||
if fileContent in ( None, "" ) and backend.getIdentifiedDbms() != DBMS.PGSQL:
|
||||
if fileContent in ( None, "" ) and Backend.getIdentifiedDbms() != DBMS.PGSQL:
|
||||
self.cleanup(onlyFileTbl=True)
|
||||
|
||||
return
|
||||
@@ -289,7 +289,7 @@ class Filesystem:
|
||||
fileContent = self.__unhexString(fileContent)
|
||||
rFilePath = dataToOutFile(fileContent)
|
||||
|
||||
if backend.getIdentifiedDbms() != DBMS.PGSQL:
|
||||
if Backend.getIdentifiedDbms() != DBMS.PGSQL:
|
||||
self.cleanup(onlyFileTbl=True)
|
||||
|
||||
return rFilePath
|
||||
|
||||
@@ -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 backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import readInput
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
@@ -19,7 +19,7 @@ class Fingerprint:
|
||||
"""
|
||||
|
||||
def __init__(self, dbms):
|
||||
backend.forceDbms(dbms)
|
||||
Backend.forceDbms(dbms)
|
||||
|
||||
def getFingerprint(self):
|
||||
errMsg = "'getFingerprint' method must be defined "
|
||||
|
||||
@@ -10,7 +10,7 @@ See the file 'doc/COPYING' for copying permission
|
||||
import re
|
||||
|
||||
from lib.core.common import getCompiledRegex
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import isTechniqueAvailable
|
||||
from lib.core.common import normalizePath
|
||||
from lib.core.common import ntToPosixSlashes
|
||||
@@ -57,19 +57,19 @@ class Miscellaneous:
|
||||
infoMsg = "detecting back-end DBMS version from its banner"
|
||||
logger.info(infoMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
first, last = 1, 6
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
first, last = 12, 6
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
first, last = 29, 9
|
||||
|
||||
else:
|
||||
raise sqlmapUnsupportedFeatureException, "unsupported DBMS"
|
||||
|
||||
query = queries[backend.getIdentifiedDbms()].substring.query % (queries[backend.getIdentifiedDbms()].banner.query, first, last)
|
||||
query = queries[Backend.getIdentifiedDbms()].substring.query % (queries[Backend.getIdentifiedDbms()].banner.query, first, last)
|
||||
|
||||
if conf.direct:
|
||||
query = "SELECT %s" % query
|
||||
@@ -120,7 +120,7 @@ class Miscellaneous:
|
||||
if not onlyFileTbl:
|
||||
inject.goStacked("DROP TABLE %s" % self.cmdTblName, silent=True)
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||
return
|
||||
|
||||
if udfDict is None:
|
||||
@@ -133,7 +133,7 @@ class Miscellaneous:
|
||||
if not output or output in ("y", "Y"):
|
||||
dropStr = "DROP FUNCTION %s" % udf
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
inp = ", ".join(i for i in inpRet["input"])
|
||||
dropStr += "(%s)" % inp
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ See the file 'doc/COPYING' for copying permission
|
||||
|
||||
import os
|
||||
|
||||
from lib.core.common import backend
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import isTechniqueAvailable
|
||||
from lib.core.common import readInput
|
||||
from lib.core.common import runningAsAdmin
|
||||
@@ -45,7 +45,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
def osCmd(self):
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) or conf.direct:
|
||||
web = False
|
||||
elif not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
elif not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
infoMsg = "going to use a web backdoor for command execution"
|
||||
logger.info(infoMsg)
|
||||
|
||||
@@ -66,7 +66,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
def osShell(self):
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) or conf.direct:
|
||||
web = False
|
||||
elif not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
elif not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
infoMsg = "going to use a web backdoor for command prompt"
|
||||
logger.info(infoMsg)
|
||||
|
||||
@@ -149,7 +149,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
errMsg += "is unlikely to receive commands send from you"
|
||||
logger.error(errMsg)
|
||||
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
self.sysUdfs.pop("sys_bineval")
|
||||
|
||||
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) or conf.direct:
|
||||
@@ -159,7 +159,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
self.initEnv(web=web)
|
||||
|
||||
if tunnel == 1:
|
||||
if backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
|
||||
msg = "how do you want to execute the Metasploit shellcode "
|
||||
msg += "on the back-end database underlying operating system?"
|
||||
msg += "\n[1] Via UDF 'sys_bineval' (in-memory way, anti-forensics, default)"
|
||||
@@ -189,7 +189,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
self.uploadMsfPayloadStager()
|
||||
|
||||
if kb.os == "Windows" and conf.privEsc:
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
debugMsg = "by default MySQL on Windows runs as SYSTEM "
|
||||
debugMsg += "user, no need to privilege escalate"
|
||||
logger.debug(debugMsg)
|
||||
@@ -207,7 +207,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
self.uploadIcmpshSlave(web=web)
|
||||
self.icmpPwn()
|
||||
|
||||
elif not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
elif not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
web = True
|
||||
|
||||
infoMsg = "going to use a web backdoor to establish the tunnel"
|
||||
@@ -256,13 +256,13 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
raise sqlmapUnsupportedDBMSException(errMsg)
|
||||
|
||||
if not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and not conf.direct:
|
||||
if backend.getIdentifiedDbms() in ( DBMS.PGSQL, DBMS.MSSQL ):
|
||||
if Backend.getIdentifiedDbms() in ( DBMS.PGSQL, DBMS.MSSQL ):
|
||||
errMsg = "on this back-end DBMS it is only possible to "
|
||||
errMsg += "perform the SMB relay attack if stacked "
|
||||
errMsg += "queries are supported"
|
||||
raise sqlmapUnsupportedDBMSException(errMsg)
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
debugMsg = "since stacked queries are not supported, "
|
||||
debugMsg += "sqlmap is going to perform the SMB relay "
|
||||
debugMsg += "attack via inference blind SQL injection"
|
||||
@@ -271,19 +271,19 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
printWarn = True
|
||||
warnMsg = "it is unlikely that this attack will be successful "
|
||||
|
||||
if backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
if Backend.getIdentifiedDbms() == DBMS.MYSQL:
|
||||
warnMsg += "because by default MySQL on Windows runs as "
|
||||
warnMsg += "Local System which is not a real user, it does "
|
||||
warnMsg += "not send the NTLM session hash when connecting to "
|
||||
warnMsg += "a SMB service"
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
elif Backend.getIdentifiedDbms() == DBMS.PGSQL:
|
||||
warnMsg += "because by default PostgreSQL on Windows runs "
|
||||
warnMsg += "as postgres user which is a real user of the "
|
||||
warnMsg += "system, but not within the Administrators group"
|
||||
|
||||
elif backend.getIdentifiedDbms() == DBMS.MSSQL and backend.isVersionWithin(("2005", "2008")):
|
||||
warnMsg += "because often Microsoft SQL Server %s " % backend.getVersion()
|
||||
elif Backend.getIdentifiedDbms() == DBMS.MSSQL and Backend.isVersionWithin(("2005", "2008")):
|
||||
warnMsg += "because often Microsoft SQL Server %s " % Backend.getVersion()
|
||||
warnMsg += "runs as Network Service which is not a real user, "
|
||||
warnMsg += "it does not send the NTLM session hash when "
|
||||
warnMsg += "connecting to a SMB service"
|
||||
@@ -300,14 +300,14 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous):
|
||||
if not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and not conf.direct:
|
||||
return
|
||||
|
||||
if not backend.getIdentifiedDbms() == DBMS.MSSQL or not backend.isVersionWithin(("2000", "2005")):
|
||||
if not Backend.getIdentifiedDbms() == DBMS.MSSQL or not Backend.isVersionWithin(("2000", "2005")):
|
||||
errMsg = "the back-end DBMS must be Microsoft SQL Server "
|
||||
errMsg += "2000 or 2005 to be able to exploit the heap-based "
|
||||
errMsg += "buffer overflow in the 'sp_replwritetovarbin' "
|
||||
errMsg += "stored procedure (MS09-004)"
|
||||
raise sqlmapUnsupportedDBMSException(errMsg)
|
||||
|
||||
infoMsg = "going to exploit the Microsoft SQL Server %s " % backend.getVersion()
|
||||
infoMsg = "going to exploit the Microsoft SQL Server %s " % Backend.getVersion()
|
||||
infoMsg += "'sp_replwritetovarbin' stored procedure heap-based "
|
||||
infoMsg += "buffer overflow (MS09-004)"
|
||||
logger.info(infoMsg)
|
||||
|
||||
Reference in New Issue
Block a user