mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 11:03:47 +03:00
Added switch --schema to enumerate DBMS schema and now --columns does not require a mandatory table (-T) anymore, instead it will act as an alias for --schema
This commit is contained in:
parent
d3ed3268c3
commit
edac0b2558
|
@ -90,14 +90,11 @@ def action():
|
||||||
if conf.getTables:
|
if conf.getTables:
|
||||||
conf.dumper.dbTables(conf.dbmsHandler.getTables())
|
conf.dumper.dbTables(conf.dbmsHandler.getTables())
|
||||||
|
|
||||||
if conf.commonTables:
|
|
||||||
conf.dumper.dbTables(tableExists(paths.COMMON_TABLES))
|
|
||||||
|
|
||||||
if conf.getColumns:
|
if conf.getColumns:
|
||||||
conf.dumper.dbTableColumns(conf.dbmsHandler.getColumns())
|
conf.dumper.dbTableColumns(conf.dbmsHandler.getColumns())
|
||||||
|
|
||||||
if conf.commonColumns:
|
if conf.getSchema:
|
||||||
conf.dumper.dbTableColumns(columnExists(paths.COMMON_COLUMNS))
|
conf.dumper.dbTableColumns(conf.dbmsHandler.getSchema())
|
||||||
|
|
||||||
if conf.dumpTable:
|
if conf.dumpTable:
|
||||||
conf.dumper.dbTableValues(conf.dbmsHandler.dumpTable())
|
conf.dumper.dbTableValues(conf.dbmsHandler.dumpTable())
|
||||||
|
@ -114,6 +111,13 @@ def action():
|
||||||
if conf.sqlShell:
|
if conf.sqlShell:
|
||||||
conf.dbmsHandler.sqlShell()
|
conf.dbmsHandler.sqlShell()
|
||||||
|
|
||||||
|
# Brute force options
|
||||||
|
if conf.commonTables:
|
||||||
|
conf.dumper.dbTables(tableExists(paths.COMMON_TABLES))
|
||||||
|
|
||||||
|
if conf.commonColumns:
|
||||||
|
conf.dumper.dbTableColumns(columnExists(paths.COMMON_COLUMNS))
|
||||||
|
|
||||||
# User-defined function options
|
# User-defined function options
|
||||||
if conf.udfInject:
|
if conf.udfInject:
|
||||||
conf.dbmsHandler.udfInjectCustom()
|
conf.dbmsHandler.udfInjectCustom()
|
||||||
|
|
|
@ -92,6 +92,7 @@ optDict = {
|
||||||
"getDbs": ("boolean", "Databases"),
|
"getDbs": ("boolean", "Databases"),
|
||||||
"getTables": ("boolean", "Tables"),
|
"getTables": ("boolean", "Tables"),
|
||||||
"getColumns": ("boolean", "Columns"),
|
"getColumns": ("boolean", "Columns"),
|
||||||
|
"getSchema": "boolean",
|
||||||
"dumpTable": "boolean",
|
"dumpTable": "boolean",
|
||||||
"dumpAll": "boolean",
|
"dumpAll": "boolean",
|
||||||
"search": "boolean",
|
"search": "boolean",
|
||||||
|
|
|
@ -276,6 +276,9 @@ def cmdLineParser():
|
||||||
enumeration.add_option("--columns", dest="getColumns", action="store_true",
|
enumeration.add_option("--columns", dest="getColumns", action="store_true",
|
||||||
default=False, help="Enumerate DBMS database table columns")
|
default=False, help="Enumerate DBMS database table columns")
|
||||||
|
|
||||||
|
enumeration.add_option("--schema", dest="getSchema", action="store_true",
|
||||||
|
default=False, help="Enumerate DBMS schema")
|
||||||
|
|
||||||
enumeration.add_option("--dump", dest="dumpTable", action="store_true",
|
enumeration.add_option("--dump", dest="dumpTable", action="store_true",
|
||||||
default=False, help="Dump DBMS database table entries")
|
default=False, help="Dump DBMS database table entries")
|
||||||
|
|
||||||
|
|
|
@ -822,7 +822,6 @@ class Enumeration:
|
||||||
if Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
if Backend.getIdentifiedDbms() == DBMS.MSSQL:
|
||||||
query = safeStringFormat(query, conf.db)
|
query = safeStringFormat(query, conf.db)
|
||||||
value = inject.getValue(query, blind=False)
|
value = inject.getValue(query, blind=False)
|
||||||
|
|
||||||
value = filter(lambda x: x, value)
|
value = filter(lambda x: x, value)
|
||||||
|
|
||||||
if value:
|
if value:
|
||||||
|
@ -904,12 +903,43 @@ class Enumeration:
|
||||||
|
|
||||||
return kb.data.cachedTables
|
return kb.data.cachedTables
|
||||||
|
|
||||||
|
def getSchema(self):
|
||||||
|
pushValue(conf.db)
|
||||||
|
pushValue(conf.tbl)
|
||||||
|
|
||||||
|
conf.db = None
|
||||||
|
conf.tbl = None
|
||||||
|
|
||||||
|
self.getTables()
|
||||||
|
|
||||||
|
infoMsg = "fetched tables: "
|
||||||
|
infoMsg += ", ".join(["%s" % ", ".join("%s%s%s" % (db, ".." if \
|
||||||
|
Backend.isDbms(DBMS.MSSQL) or Backend.isDbms(DBMS.SYBASE) \
|
||||||
|
else ".", t) for t in tbl) for db, tbl in \
|
||||||
|
kb.data.cachedTables.items()])
|
||||||
|
logger.info(infoMsg)
|
||||||
|
|
||||||
|
for db, tables in kb.data.cachedTables.items():
|
||||||
|
for tbl in tables:
|
||||||
|
conf.db = db
|
||||||
|
conf.tbl = tbl
|
||||||
|
|
||||||
|
self.getColumns()
|
||||||
|
|
||||||
|
conf.tbl = popValue()
|
||||||
|
conf.db = popValue()
|
||||||
|
|
||||||
|
return kb.data.cachedColumns
|
||||||
|
|
||||||
def getColumns(self, onlyColNames=False):
|
def getColumns(self, onlyColNames=False):
|
||||||
bruteForce = False
|
bruteForce = False
|
||||||
|
|
||||||
if not conf.tbl:
|
if not conf.tbl:
|
||||||
errMsg = "missing table parameter"
|
warnMsg = "missing table parameter, sqlmap will enumerate "
|
||||||
raise sqlmapMissingMandatoryOptionException, errMsg
|
warnMsg += "the whole database management system schema"
|
||||||
|
logger.warn(warnMsg)
|
||||||
|
|
||||||
|
return self.getSchema()
|
||||||
|
|
||||||
if "." in conf.tbl:
|
if "." in conf.tbl:
|
||||||
if not conf.db:
|
if not conf.db:
|
||||||
|
@ -954,7 +984,10 @@ class Enumeration:
|
||||||
if db == conf.db and table == conf.tbl:
|
if db == conf.db and table == conf.tbl:
|
||||||
columns[colName] = colType
|
columns[colName] = colType
|
||||||
|
|
||||||
kb.data.cachedColumns[conf.db] = {conf.tbl: columns}
|
if conf.db in kb.data.cachedColumns:
|
||||||
|
kb.data.cachedColumns[conf.db][conf.tbl] = columns
|
||||||
|
else:
|
||||||
|
kb.data.cachedColumns[conf.db] = {conf.tbl: columns}
|
||||||
|
|
||||||
return kb.data.cachedColumns
|
return kb.data.cachedColumns
|
||||||
|
|
||||||
|
@ -1019,8 +1052,11 @@ class Enumeration:
|
||||||
else:
|
else:
|
||||||
columns[name] = columnData[1]
|
columns[name] = columnData[1]
|
||||||
|
|
||||||
table[conf.tbl] = columns
|
if conf.db in kb.data.cachedColumns:
|
||||||
kb.data.cachedColumns[conf.db] = table
|
kb.data.cachedColumns[conf.db][conf.tbl] = columns
|
||||||
|
else:
|
||||||
|
table[conf.tbl] = columns
|
||||||
|
kb.data.cachedColumns[conf.db] = table
|
||||||
|
|
||||||
if not kb.data.cachedColumns and not conf.direct:
|
if not kb.data.cachedColumns and not conf.direct:
|
||||||
infoMsg = "fetching number of columns "
|
infoMsg = "fetching number of columns "
|
||||||
|
@ -1112,8 +1148,11 @@ class Enumeration:
|
||||||
columns[column] = None
|
columns[column] = None
|
||||||
|
|
||||||
if columns:
|
if columns:
|
||||||
table[conf.tbl] = columns
|
if conf.db in kb.data.cachedColumns:
|
||||||
kb.data.cachedColumns[conf.db] = table
|
kb.data.cachedColumns[conf.db][conf.tbl] = columns
|
||||||
|
else:
|
||||||
|
table[conf.tbl] = columns
|
||||||
|
kb.data.cachedColumns[conf.db] = table
|
||||||
|
|
||||||
if not kb.data.cachedColumns:
|
if not kb.data.cachedColumns:
|
||||||
errMsg = "unable to retrieve the columns "
|
errMsg = "unable to retrieve the columns "
|
||||||
|
|
|
@ -306,11 +306,14 @@ getDbs = False
|
||||||
getTables = False
|
getTables = False
|
||||||
|
|
||||||
# Enumerate back-end database management system database table columns.
|
# Enumerate back-end database management system database table columns.
|
||||||
# Requires: tbl
|
# Optional: db, tbl, col
|
||||||
# Optional: db, col
|
|
||||||
# Valid: True or False
|
# Valid: True or False
|
||||||
getColumns = False
|
getColumns = False
|
||||||
|
|
||||||
|
# Enumerate back-end database management system schema.
|
||||||
|
# Valid: True or False
|
||||||
|
getSchema = False
|
||||||
|
|
||||||
# Dump back-end database management system database table entries.
|
# Dump back-end database management system database table entries.
|
||||||
# Requires: tbl and/or col
|
# Requires: tbl and/or col
|
||||||
# Optional: db
|
# Optional: db
|
||||||
|
|
Loading…
Reference in New Issue
Block a user