diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py
index acf14c88f..07f9321de 100644
--- a/lib/core/optiondict.py
+++ b/lib/core/optiondict.py
@@ -121,6 +121,7 @@ optDict = {
"dumpTable": "boolean",
"dumpAll": "boolean",
"search": "boolean",
+ "getComments": "boolean",
"db": "string",
"tbl": "string",
"col": "string",
diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py
index cb1c99efe..5f4503c24 100644
--- a/lib/parse/cmdline.py
+++ b/lib/parse/cmdline.py
@@ -386,6 +386,9 @@ def cmdLineParser():
enumeration.add_option("--search", dest="search", action="store_true",
help="Search column(s), table(s) and/or database name(s)")
+ enumeration.add_option("--comments", dest="getComments", action="store_true",
+ help="Retrieve DBMS comments")
+
enumeration.add_option("-D", dest="db",
help="DBMS database to enumerate")
diff --git a/plugins/generic/databases.py b/plugins/generic/databases.py
index 90fc7d7bd..df03dbf3c 100644
--- a/plugins/generic/databases.py
+++ b/plugins/generic/databases.py
@@ -554,6 +554,19 @@ class Databases:
name = safeSQLIdentificatorNaming(columnData[0])
if name:
+ if conf.getComments:
+ _ = queries[Backend.getIdentifiedDbms()].column_comment
+ if hasattr(_, "query"):
+ if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
+ query = _.query % (unsafeSQLIdentificatorNaming(conf.db.upper()), unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(name.upper()))
+ else:
+ query = _.query % (unsafeSQLIdentificatorNaming(conf.db), unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(name))
+ comment = unArrayizeValue(inject.getValue(query, blind=False, time=False))
+ else:
+ warnMsg = "on %s it is not " % Backend.getIdentifiedDbms()
+ warnMsg += "possible to get column comments"
+ singleTimeWarnMessage(warnMsg)
+
if len(columnData) == 1:
columns[name] = None
else:
@@ -666,6 +679,19 @@ class Databases:
column = unArrayizeValue(inject.getValue(query, union=False, error=False))
if not isNoneValue(column):
+ if conf.getComments:
+ _ = queries[Backend.getIdentifiedDbms()].column_comment
+ if hasattr(_, "query"):
+ if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
+ query = _.query % (unsafeSQLIdentificatorNaming(conf.db.upper()), unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(column.upper()))
+ else:
+ query = _.query % (unsafeSQLIdentificatorNaming(conf.db), unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(column))
+ comment = unArrayizeValue(inject.getValue(query, union=False, error=False))
+ else:
+ warnMsg = "on %s it is not " % Backend.getIdentifiedDbms()
+ warnMsg += "possible to get column comments"
+ singleTimeWarnMessage(warnMsg)
+
if not onlyColNames:
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
query = rootQuery.blind.query2 % (unsafeSQLIdentificatorNaming(tbl), column, unsafeSQLIdentificatorNaming(conf.db))
diff --git a/sqlmap.conf b/sqlmap.conf
index f88d4cb15..5f363c567 100644
--- a/sqlmap.conf
+++ b/sqlmap.conf
@@ -429,6 +429,10 @@ dumpAll = False
# Valid: True or False
search = False
+# Retrieve back-end database management system comments.
+# Valid: True or False
+getComments = False
+
# Back-end database management system database to enumerate.
db =
diff --git a/xml/queries.xml b/xml/queries.xml
index ee0f61086..05f53cc65 100644
--- a/xml/queries.xml
+++ b/xml/queries.xml
@@ -240,9 +240,9 @@
NOTE: in Oracle to check if the session user is DBA you can use:
SELECT USERENV('ISDBA') FROM DUAL
-->
-
-
-
+
+
+
@@ -324,6 +324,8 @@
+
+
@@ -374,6 +376,8 @@
+
+
@@ -415,6 +419,8 @@
+
+
@@ -471,6 +477,8 @@
+
+
@@ -521,6 +529,8 @@
+
+
@@ -592,6 +602,8 @@
+
+
@@ -657,6 +669,8 @@
+
+