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

Skip to content

Commit 65a0545

Browse files
committed
Added option --search to work in conjunction with -D (done), -T (soon) or -C (replaces --dump -C) - See #190:
* --search -D foobar: searches all database names like the ones provided * --search -T foobar: searches all databases' table names like the ones provided (soon) * --search -C foobar: replaces --dump -C
1 parent 7b6050f commit 65a0545

13 files changed

Lines changed: 439 additions & 261 deletions

File tree

lib/controller/action.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def action():
120120
if conf.dumpAll:
121121
conf.dbmsHandler.dumpAll()
122122

123+
if conf.search:
124+
conf.dbmsHandler.search()
125+
123126
if conf.query:
124127
dumper.string(conf.query, conf.dbmsHandler.sqlQuery(conf.query))
125128

lib/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def normalizePath(path):
10061006
return retVal
10071007

10081008
def safeStringFormat(formatStr, params):
1009-
retVal = formatStr.replace('%d', '%s')
1009+
retVal = formatStr.replace("%d", "%s")
10101010

10111011
if isinstance(params, str):
10121012
retVal = retVal.replace("%s", params)
@@ -1015,7 +1015,7 @@ def safeStringFormat(formatStr, params):
10151015
index = 0
10161016

10171017
while index != -1:
1018-
index = retVal.find('%s')
1018+
index = retVal.find("%s")
10191019

10201020
if index != -1:
10211021
if count < len(params):

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"getColumns": "boolean",
9797
"dumpTable": "boolean",
9898
"dumpAll": "boolean",
99+
"search": "boolean",
99100
"user": "string",
100101
"db": "string",
101102
"tbl": "string",

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ def cmdLineParser():
275275
enumeration.add_option("--dump-all", dest="dumpAll", action="store_true",
276276
help="Dump all DBMS databases tables entries")
277277

278+
enumeration.add_option("--search", dest="search", action="store_true",
279+
help="Search column(s), table(s) and/or database name(s)")
280+
278281
enumeration.add_option("-D", dest="db",
279282
help="DBMS database to enumerate")
280283

lib/parse/queriesfile.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,34 @@ def endElement(self, name):
207207

208208
self.__queries.columns = self.__columns
209209

210-
elif name == "dump_column":
211-
self.__dumpColumn = {}
212-
self.__dumpColumn["inband"] = { "query": self.__inband, "query2": self.__inband2, "condition": self.__conditionInband, "condition2": self.__conditionInband2 }
213-
self.__dumpColumn["blind"] = { "query": self.__blind, "query2": self.__blind2, "count": self.__count, "count2": self.__count2, "condition": self.__conditionBlind, "condition2": self.__conditionBlind2 }
214-
215-
self.__queries.dumpColumn = self.__dumpColumn
216-
217210
elif name == "dump_table":
218211
self.__dumpTable = {}
219212
self.__dumpTable["inband"] = { "query": self.__inband }
220213
self.__dumpTable["blind"] = { "query": self.__blind, "count": self.__count }
221214

222215
self.__queries.dumpTable = self.__dumpTable
223216

217+
elif name == "search_db":
218+
self.__searchDb = {}
219+
self.__searchDb["inband"] = { "query": self.__inband, "query2": self.__inband2, "condition": self.__conditionInband, "condition2": self.__conditionInband2 }
220+
self.__searchDb["blind"] = { "query": self.__blind, "query2": self.__blind2, "count": self.__count, "count2": self.__count2, "condition": self.__conditionBlind, "condition2": self.__conditionBlind2 }
221+
222+
self.__queries.searchDb = self.__searchDb
223+
224+
elif name == "search_table":
225+
self.__searchTable = {}
226+
self.__searchTable["inband"] = { "query": self.__inband, "query2": self.__inband2, "condition": self.__conditionInband, "condition2": self.__conditionInband2 }
227+
self.__searchTable["blind"] = { "query": self.__blind, "query2": self.__blind2, "count": self.__count, "count2": self.__count2, "condition": self.__conditionBlind, "condition2": self.__conditionBlind2 }
228+
229+
self.__queries.searchTable = self.__searchTable
230+
231+
elif name == "search_column":
232+
self.__searchColumn = {}
233+
self.__searchColumn["inband"] = { "query": self.__inband, "query2": self.__inband2, "condition": self.__conditionInband, "condition2": self.__conditionInband2 }
234+
self.__searchColumn["blind"] = { "query": self.__blind, "query2": self.__blind2, "count": self.__count, "count2": self.__count2, "condition": self.__conditionBlind, "condition2": self.__conditionBlind2 }
235+
236+
self.__queries.searchColumn = self.__searchColumn
237+
224238
def queriesParser():
225239
"""
226240
This function calls a class to parse the default DBMS queries

plugins/dbms/access/enumeration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class Enumeration(GenericEnumeration):
3030
def __init__(self):
3131
GenericEnumeration.__init__(self, "Microsoft Access")
32-
32+
3333
def getDbs(self):
3434
warnMsg = "on Microsoft Access it is not possible to enumerate databases"
3535
logger.warn(warnMsg)
@@ -47,3 +47,9 @@ def getPasswordHashes(self):
4747
logger.warn(warnMsg)
4848

4949
return {}
50+
51+
def searchDb(self):
52+
warnMsg = "on Microsoft Access it is not possible to search databases"
53+
logger.warn(warnMsg)
54+
55+
return []

plugins/dbms/firebird/enumeration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ def getPasswordHashes(self):
4141
logger.warn(warnMsg)
4242

4343
return {}
44+
45+
def searchDb(self):
46+
warnMsg = "on Firebird it is not possible to search databases"
47+
logger.warn(warnMsg)
48+
49+
return []

plugins/dbms/oracle/enumeration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,9 @@ def getDbs(self):
180180
logger.warn(warnMsg)
181181

182182
return []
183+
184+
def searchDb(self):
185+
warnMsg = "on Oracle it is not possible to search databases"
186+
logger.warn(warnMsg)
187+
188+
return []

plugins/dbms/sqlite/enumeration.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@ def getColumns(self, onlyColNames=False):
7878

7979
logger.warn(errMsg)
8080

81-
def dumpColumn(self):
81+
def dumpAll(self):
8282
errMsg = "on SQLite you must specify the table and columns to dump"
8383
raise sqlmapUnsupportedFeatureException, errMsg
8484

85-
def dumpAll(self):
85+
def searchDb(self):
86+
warnMsg = "on SQLite it is not possible to search databases"
87+
logger.warn(warnMsg)
88+
89+
return []
90+
91+
def searchColumn(self):
8692
errMsg = "on SQLite you must specify the table and columns to dump"
8793
raise sqlmapUnsupportedFeatureException, errMsg

0 commit comments

Comments
 (0)