Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60242f9

Browse files
committed
made --search -D on MSSQL consistent with other DBMSes - issue #81
1 parent 7f10b01 commit 60242f9

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

plugins/dbms/mssqlserver/enumeration.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,16 @@ def getTables(self):
158158
return kb.data.cachedTables
159159

160160
def searchTable(self):
161-
rootQuery = queries[Backend.getIdentifiedDbms()].search_table
162161
foundTbls = {}
163162
tblList = conf.tbl.split(",")
163+
rootQuery = queries[Backend.getIdentifiedDbms()].search_table
164164
tblCond = rootQuery.inband.condition
165165
#dbCond = rootQuery.inband.condition2
166-
167166
tblConsider, tblCondParam = self.likeOrExact("table")
168167

169-
if not len(kb.data.cachedDbs):
168+
if conf.db and conf.db != CURRENT_DB:
169+
enumDbs = conf.db.split(",")
170+
elif not len(kb.data.cachedDbs):
170171
enumDbs = self.getDbs()
171172
else:
172173
enumDbs = kb.data.cachedDbs
@@ -247,7 +248,13 @@ def searchTable(self):
247248
if len(tbls) == 0:
248249
foundTbls.pop(db)
249250

250-
return foundTbls
251+
if not foundTbls:
252+
warnMsg = "no databases contain any of the provided tables"
253+
logger.warn(warnMsg)
254+
return
255+
256+
conf.dumper.dbTables(foundTbls)
257+
self.dumpFoundTables(foundTbls)
251258

252259
def searchColumn(self):
253260
rootQuery = queries[Backend.getIdentifiedDbms()].search_column

plugins/generic/search.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,10 @@ def searchTable(self):
154154

155155
foundTbls = {}
156156
tblList = conf.tbl.split(",")
157-
158157
rootQuery = queries[Backend.getIdentifiedDbms()].search_table
159158
tblCond = rootQuery.inband.condition
160159
dbCond = rootQuery.inband.condition2
161160
whereDbsQuery = ""
162-
163161
tblConsider, tblCondParam = self.likeOrExact("table")
164162

165163
for tbl in tblList:

0 commit comments

Comments
 (0)