Skip to content

Commit 6863436

Browse files
committed
Implementation for an Issue sqlmapproject#596
1 parent b4139f5 commit 6863436

File tree

8 files changed

+44
-7
lines changed

8 files changed

+44
-7
lines changed

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"db": "string",
128128
"tbl": "string",
129129
"col": "string",
130+
"excludeCol": "string",
130131
"user": "string",
131132
"excludeSysDbs": "boolean",
132133
"limitStart": "integer",

lib/parse/cmdline.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,13 @@ def cmdLineParser():
404404
help="DBMS database to enumerate")
405405

406406
enumeration.add_option("-T", dest="tbl",
407-
help="DBMS database table to enumerate")
407+
help="DBMS database table(s) to enumerate")
408408

409409
enumeration.add_option("-C", dest="col",
410-
help="DBMS database table column to enumerate")
410+
help="DBMS database table column(s) to enumerate")
411+
412+
enumeration.add_option("-X", dest="excludeCol",
413+
help="DBMS database table column(s) to not enumerate")
411414

412415
enumeration.add_option("-U", dest="user",
413416
help="DBMS user to enumerate")

plugins/dbms/mssqlserver/enumeration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ def searchColumn(self):
263263
infoMsgTbl = ""
264264
infoMsgDb = ""
265265
colList = conf.col.split(",")
266+
267+
if conf.excludeCol:
268+
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
269+
266270
origTbl = conf.tbl
267271
origDb = conf.db
268272
colCond = rootQuery.inband.condition

plugins/dbms/sybase/enumeration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ def getColumns(self, onlyColNames=False):
181181
else:
182182
colList = []
183183

184+
if conf.excludeCol:
185+
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
186+
184187
for col in colList:
185188
colList[colList.index(col)] = safeSQLIdentificatorNaming(col)
186189

plugins/generic/databases.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,13 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
399399
if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
400400
conf.col = conf.col.upper()
401401

402-
colList = conf.col.split(",")
402+
colList = conf.col.split(',')
403403
else:
404404
colList = []
405405

406+
if conf.excludeCol:
407+
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
408+
406409
for col in colList:
407410
colList[colList.index(col)] = safeSQLIdentificatorNaming(col)
408411

plugins/generic/entries.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ def dumpTable(self, foundData=None):
122122

123123
columns = kb.data.cachedColumns[safeSQLIdentificatorNaming(conf.db)][safeSQLIdentificatorNaming(tbl, True)]
124124
colList = sorted(filter(None, columns.keys()))
125+
126+
if conf.excludeCol:
127+
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
128+
129+
if not colList:
130+
warnMsg = "skipping table '%s'" % unsafeSQLIdentificatorNaming(tbl)
131+
warnMsg += " in database '%s'" % unsafeSQLIdentificatorNaming(conf.db)
132+
warnMsg += " (no usable column names)"
133+
logger.warn(warnMsg)
134+
continue
135+
125136
colNames = colString = ", ".join(column for column in colList)
126137
rootQuery = queries[Backend.getIdentifiedDbms()].dump_table
127138

@@ -420,7 +431,12 @@ def dumpFoundColumn(self, dbs, foundCols, colConsider):
420431
continue
421432

422433
conf.tbl = table
423-
conf.col = ",".join(column for column in filter(None, sorted(columns)))
434+
colList = filter(None, sorted(columns))
435+
436+
if conf.excludeCol:
437+
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
438+
439+
conf.col = ",".join(colList)
424440
kb.data.cachedColumns = {}
425441
kb.data.dumpedTable = {}
426442

plugins/generic/search.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def searchColumn(self):
349349
elif test[0] in ("q", "Q"):
350350
raise SqlmapUserQuitException
351351
else:
352-
regex = "|".join(conf.col.split(","))
352+
regex = '|'.join(conf.col.split(','))
353353
conf.dumper.dbTableColumns(columnExists(paths.COMMON_COLUMNS, regex))
354354

355355
message = "do you want to dump entries? [Y/n] "
@@ -368,6 +368,10 @@ def searchColumn(self):
368368
infoMsgTbl = ""
369369
infoMsgDb = ""
370370
colList = conf.col.split(",")
371+
372+
if conf.excludeCol:
373+
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
374+
371375
origTbl = conf.tbl
372376
origDb = conf.db
373377
colCond = rootQuery.inband.condition

sqlmap.conf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,15 @@ getComments = False
445445
# Back-end database management system database to enumerate.
446446
db =
447447

448-
# Back-end database management system database table to enumerate.
448+
# Back-end database management system database table(s) to enumerate.
449449
tbl =
450450

451-
# Back-end database management system database table column to enumerate.
451+
# Back-end database management system database table column(s) to enumerate.
452452
col =
453453

454+
# Back-end database management system database table column(s) to not enumerate.
455+
excludeCol =
456+
454457
# Back-end database management system database user to enumerate.
455458
user =
456459

0 commit comments

Comments
 (0)