@@ -904,6 +904,9 @@ def getTables(self, bruteForce=None):
904904 return kb .data .cachedTables
905905
906906 def getSchema (self ):
907+ infoMsg = "enumerating database management system schema"
908+ logger .info (infoMsg )
909+
907910 pushValue (conf .db )
908911 pushValue (conf .tbl )
909912
@@ -934,27 +937,36 @@ def getSchema(self):
934937 def getColumns (self , onlyColNames = False ):
935938 bruteForce = False
936939
937- if not conf .tbl :
938- warnMsg = "missing table parameter, sqlmap will enumerate "
939- warnMsg += "the whole database management system schema"
940- logger .warn (warnMsg )
941-
942- return self .getSchema ()
943-
944- if "." in conf .tbl :
940+ if conf .tbl is not None and "." in conf .tbl :
945941 if not conf .db :
946942 conf .db , conf .tbl = conf .tbl .split ("." )
947943
948- self .forceDbmsEnum ()
949-
950- if not conf .db :
951- warnMsg = "missing database parameter, sqlmap is going to "
944+ if conf .tbl is not None and conf .db is None :
945+ warnMsg = "missing database parameter, sqlmap is going to "
952946 warnMsg += "use the current database to enumerate table "
953947 warnMsg += "'%s' columns" % conf .tbl
954948 logger .warn (warnMsg )
955949
956950 conf .db = self .getCurrentDb ()
957951
952+ self .forceDbmsEnum ()
953+
954+ if kb .data .cachedColumns and conf .db in kb .data .cachedColumns \
955+ and conf .tbl in kb .data .cachedColumns [conf .db ]:
956+ infoMsg = "fetching columns "
957+ infoMsg += "for table '%s' " % conf .tbl
958+ infoMsg += "on database '%s'" % conf .db
959+ logger .info (infoMsg )
960+
961+ return { conf .db : kb .data .cachedColumns [conf .db ]}
962+
963+ if not conf .tbl :
964+ warnMsg = "missing table parameter, sqlmap will enumerate "
965+ warnMsg += "the full database management system schema"
966+ logger .warn (warnMsg )
967+
968+ return self .getSchema ()
969+
958970 if Backend .getIdentifiedDbms () == DBMS .MYSQL and not kb .data .has_information_schema :
959971 errMsg = "information_schema not available, "
960972 errMsg += "back-end DBMS is MySQL < 5.0"
@@ -1155,7 +1167,7 @@ def getColumns(self, onlyColNames=False):
11551167 kb .data .cachedColumns [conf .db ] = table
11561168
11571169 if not kb .data .cachedColumns :
1158- errMsg = "unable to retrieve the columns "
1170+ errMsg = "unable to retrieve the columns "
11591171 errMsg += "for table '%s' " % conf .tbl
11601172 errMsg += "on database '%s'" % conf .db
11611173 raise sqlmapNoneDataException , errMsg
0 commit comments