mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-09 06:01:29 +00:00
Adding support for Altibase
This commit is contained in:
@@ -48,7 +48,7 @@ from lib.core.exception import SqlmapNoneDataException
|
||||
from lib.core.exception import SqlmapUserQuitException
|
||||
from lib.core.settings import CURRENT_DB
|
||||
from lib.core.settings import REFLECTED_VALUE_MARKER
|
||||
from lib.core.settings import UPPER_CASE_IDENTIFIERS
|
||||
from lib.core.settings import UPPER_CASE_DBMSES
|
||||
from lib.core.settings import VERTICA_DEFAULT_SCHEMA
|
||||
from lib.request import inject
|
||||
from lib.techniques.union.use import unionUse
|
||||
@@ -87,6 +87,11 @@ class Databases(object):
|
||||
warnMsg += "schema names for enumeration as the counterpart to database "
|
||||
warnMsg += "names on other DBMSes"
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ALTIBASE,):
|
||||
warnMsg = "on %s you'll need to use " % Backend.getIdentifiedDbms()
|
||||
warnMsg += "user names for enumeration as the counterpart to database "
|
||||
warnMsg += "names on other DBMSes"
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
|
||||
return kb.data.currentDb
|
||||
|
||||
@@ -110,6 +115,14 @@ class Databases(object):
|
||||
|
||||
infoMsg = "fetching database (schema) names"
|
||||
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ALTIBASE,):
|
||||
warnMsg = "user names are going to be used on %s " % Backend.getIdentifiedDbms()
|
||||
warnMsg += "for enumeration as the counterpart to database "
|
||||
warnMsg += "names on other DBMSes"
|
||||
logger.warn(warnMsg)
|
||||
|
||||
infoMsg = "fetching database (user) names"
|
||||
|
||||
else:
|
||||
infoMsg = "fetching database names"
|
||||
|
||||
@@ -142,7 +155,7 @@ class Databases(object):
|
||||
errMsg = "unable to retrieve the number of databases"
|
||||
logger.error(errMsg)
|
||||
else:
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
@@ -229,7 +242,7 @@ class Databases(object):
|
||||
if conf.db == CURRENT_DB:
|
||||
conf.db = self.getCurrentDb()
|
||||
|
||||
if conf.db and Backend.getIdentifiedDbms() in UPPER_CASE_IDENTIFIERS:
|
||||
if conf.db and Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
conf.db = conf.db.upper()
|
||||
|
||||
if conf.db:
|
||||
@@ -316,7 +329,7 @@ class Databases(object):
|
||||
if conf.getComments:
|
||||
_ = queries[Backend.getIdentifiedDbms()].table_comment
|
||||
if hasattr(_, "query"):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(db.upper()), unsafeSQLIdentificatorNaming(table.upper()))
|
||||
else:
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(db), unsafeSQLIdentificatorNaming(table))
|
||||
@@ -373,7 +386,7 @@ class Databases(object):
|
||||
|
||||
tables = []
|
||||
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
@@ -398,7 +411,7 @@ class Databases(object):
|
||||
if conf.getComments:
|
||||
_ = queries[Backend.getIdentifiedDbms()].table_comment
|
||||
if hasattr(_, "query"):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(db.upper()), unsafeSQLIdentificatorNaming(table.upper()))
|
||||
else:
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(db), unsafeSQLIdentificatorNaming(table))
|
||||
@@ -458,7 +471,7 @@ class Databases(object):
|
||||
raise SqlmapNoneDataException(errMsg)
|
||||
|
||||
elif conf.db is not None:
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_IDENTIFIERS:
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
conf.db = conf.db.upper()
|
||||
|
||||
if ',' in conf.db:
|
||||
@@ -469,7 +482,7 @@ class Databases(object):
|
||||
conf.db = safeSQLIdentificatorNaming(conf.db)
|
||||
|
||||
if conf.col:
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
conf.col = conf.col.upper()
|
||||
|
||||
colList = conf.col.split(',')
|
||||
@@ -485,7 +498,7 @@ class Databases(object):
|
||||
colList = [_ for _ in colList if _]
|
||||
|
||||
if conf.tbl:
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
conf.tbl = conf.tbl.upper()
|
||||
|
||||
tblList = conf.tbl.split(',')
|
||||
@@ -593,7 +606,7 @@ class Databases(object):
|
||||
query = rootQuery.inband.query % (unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(conf.db))
|
||||
query += condQuery
|
||||
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.inband.query % (unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(conf.db.upper()))
|
||||
query += condQuery
|
||||
|
||||
@@ -669,7 +682,7 @@ class Databases(object):
|
||||
if conf.getComments:
|
||||
_ = queries[Backend.getIdentifiedDbms()].column_comment
|
||||
if hasattr(_, "query"):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_IDENTIFIERS:
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(conf.db.upper()), unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(name.upper()))
|
||||
else:
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(conf.db), unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(name))
|
||||
@@ -735,7 +748,7 @@ class Databases(object):
|
||||
query = rootQuery.blind.count % (unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(conf.db))
|
||||
query += condQuery
|
||||
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.blind.count % (unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(conf.db.upper()))
|
||||
query += condQuery
|
||||
|
||||
@@ -809,7 +822,7 @@ class Databases(object):
|
||||
elif Backend.isDbms(DBMS.MONETDB):
|
||||
query = safeStringFormat(rootQuery.blind.query, (unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(conf.db), index))
|
||||
field = None
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.blind.query % (unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(conf.db.upper()))
|
||||
query += condQuery
|
||||
field = None
|
||||
@@ -833,7 +846,7 @@ class Databases(object):
|
||||
if conf.getComments:
|
||||
_ = queries[Backend.getIdentifiedDbms()].column_comment
|
||||
if hasattr(_, "query"):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_IDENTIFIERS:
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(conf.db.upper()), unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(column.upper()))
|
||||
else:
|
||||
query = _.query % (unsafeSQLIdentificatorNaming(conf.db), unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(column))
|
||||
@@ -850,7 +863,7 @@ class Databases(object):
|
||||
if not onlyColNames:
|
||||
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.HSQLDB, DBMS.H2, DBMS.VERTICA, DBMS.PRESTO):
|
||||
query = rootQuery.blind.query2 % (unsafeSQLIdentificatorNaming(tbl), column, unsafeSQLIdentificatorNaming(conf.db))
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.blind.query2 % (unsafeSQLIdentificatorNaming(tbl.upper()), column, unsafeSQLIdentificatorNaming(conf.db.upper()))
|
||||
elif Backend.isDbms(DBMS.MSSQL):
|
||||
query = rootQuery.blind.query2 % (conf.db, conf.db, conf.db, conf.db, column, conf.db, conf.db, conf.db, unsafeSQLIdentificatorNaming(tbl).split(".")[-1])
|
||||
@@ -935,7 +948,7 @@ class Databases(object):
|
||||
if not db or not table:
|
||||
return None
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
db = db.upper()
|
||||
table = table.upper()
|
||||
|
||||
@@ -1027,7 +1040,7 @@ class Databases(object):
|
||||
errMsg = "unable to retrieve the number of statements"
|
||||
raise SqlmapNoneDataException(errMsg)
|
||||
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
|
||||
@@ -43,6 +43,7 @@ from lib.core.exception import SqlmapUnsupportedFeatureException
|
||||
from lib.core.settings import CHECK_ZERO_COLUMNS_THRESHOLD
|
||||
from lib.core.settings import CURRENT_DB
|
||||
from lib.core.settings import NULL
|
||||
from lib.core.settings import UPPER_CASE_DBMSES
|
||||
from lib.request import inject
|
||||
from lib.utils.hash import attackDumpedTable
|
||||
from lib.utils.pivotdumptable import pivotDumpTable
|
||||
@@ -70,7 +71,7 @@ class Entries(object):
|
||||
conf.db = self.getCurrentDb()
|
||||
|
||||
elif conf.db is not None:
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
conf.db = conf.db.upper()
|
||||
|
||||
if ',' in conf.db:
|
||||
@@ -86,7 +87,7 @@ class Entries(object):
|
||||
conf.db = safeSQLIdentificatorNaming(conf.db)
|
||||
|
||||
if conf.tbl:
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
conf.tbl = conf.tbl.upper()
|
||||
|
||||
tblList = conf.tbl.split(',')
|
||||
@@ -176,7 +177,7 @@ class Entries(object):
|
||||
entries = []
|
||||
query = None
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.inband.query % (colString, tbl.upper() if not conf.db else ("%s.%s" % (conf.db.upper(), tbl.upper())))
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.FIREBIRD, DBMS.MAXDB, DBMS.MCKOI):
|
||||
query = rootQuery.inband.query % (colString, tbl)
|
||||
@@ -285,7 +286,7 @@ class Entries(object):
|
||||
infoMsg += "in database '%s'" % unsafeSQLIdentificatorNaming(conf.db)
|
||||
logger.info(infoMsg)
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.blind.count % (tbl.upper() if not conf.db else ("%s.%s" % (conf.db.upper(), tbl.upper())))
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.FIREBIRD, DBMS.MCKOI):
|
||||
query = rootQuery.blind.count % tbl
|
||||
@@ -380,7 +381,7 @@ class Entries(object):
|
||||
|
||||
else:
|
||||
emptyColumns = []
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
if len(colList) < len(indexRange) > CHECK_ZERO_COLUMNS_THRESHOLD:
|
||||
@@ -407,7 +408,7 @@ class Entries(object):
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.HSQLDB, DBMS.H2, DBMS.VERTICA, DBMS.PRESTO):
|
||||
query = rootQuery.blind.query % (agent.preprocessField(tbl, column), conf.db, conf.tbl, sorted(colList, key=len)[0], index)
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY):
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.DERBY, DBMS.ALTIBASE):
|
||||
query = rootQuery.blind.query % (agent.preprocessField(tbl, column), tbl.upper() if not conf.db else ("%s.%s" % (conf.db.upper(), tbl.upper())), index)
|
||||
elif Backend.isDbms(DBMS.SQLITE):
|
||||
query = rootQuery.blind.query % (agent.preprocessField(tbl, column), tbl, index)
|
||||
|
||||
@@ -34,6 +34,7 @@ from lib.core.exception import SqlmapMissingMandatoryOptionException
|
||||
from lib.core.exception import SqlmapUserQuitException
|
||||
from lib.core.settings import CURRENT_DB
|
||||
from lib.core.settings import METADB_SUFFIX
|
||||
from lib.core.settings import UPPER_CASE_DBMSES
|
||||
from lib.request import inject
|
||||
from lib.utils.brute import columnExists
|
||||
from lib.utils.brute import tableExists
|
||||
@@ -63,7 +64,7 @@ class Search(object):
|
||||
values = []
|
||||
db = safeSQLIdentificatorNaming(db)
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
db = db.upper()
|
||||
|
||||
infoMsg = "searching database"
|
||||
@@ -170,7 +171,7 @@ class Search(object):
|
||||
values = []
|
||||
tbl = safeSQLIdentificatorNaming(tbl, True)
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.FIREBIRD, DBMS.HSQLDB, DBMS.H2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
tbl = tbl.upper()
|
||||
conf.db = conf.db.upper() if conf.db else conf.db
|
||||
|
||||
@@ -393,7 +394,7 @@ class Search(object):
|
||||
conf.db = origDb
|
||||
conf.tbl = origTbl
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.DERBY):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
column = column.upper()
|
||||
conf.db = conf.db.upper() if conf.db else conf.db
|
||||
conf.tbl = conf.tbl.upper() if conf.tbl else conf.tbl
|
||||
@@ -602,7 +603,7 @@ class Search(object):
|
||||
logger.warn(warnMsg)
|
||||
|
||||
def search(self):
|
||||
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
|
||||
if Backend.getIdentifiedDbms() in UPPER_CASE_DBMSES:
|
||||
for item in ('db', 'tbl', 'col'):
|
||||
if getattr(conf, item, None):
|
||||
setattr(conf, item, getattr(conf, item).upper())
|
||||
|
||||
@@ -128,7 +128,7 @@ class Users(object):
|
||||
errMsg = "unable to retrieve the number of database users"
|
||||
raise SqlmapNoneDataException(errMsg)
|
||||
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
@@ -293,7 +293,7 @@ class Users(object):
|
||||
|
||||
passwords = []
|
||||
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
@@ -541,7 +541,7 @@ class Users(object):
|
||||
|
||||
privileges = set()
|
||||
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2)
|
||||
plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.ALTIBASE)
|
||||
indexRange = getLimitRange(count, plusOne=plusOne)
|
||||
|
||||
for index in indexRange:
|
||||
|
||||
Reference in New Issue
Block a user