Skip to content

Commit 20556e0

Browse files
committed
Add Burp parsing, REST API DB enumeration, cleaned up server info
1 parent ab00021 commit 20556e0

File tree

1 file changed

+66
-15
lines changed

1 file changed

+66
-15
lines changed

nosqlmap.py

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import urllib
2424
import pymongo
2525
import subprocess
26+
import json
2627

2728
#Set a list so we can track whether options are set or not to avoid resetting them in subsequent cals to the options menu.
2829
global optionSet
@@ -109,8 +110,9 @@ def options():
109110
print "5-Set my local Mongo/Shell IP (Current: " + str(myIP) + ")"
110111
print "6-Set shell listener port (Current: " + str(myPort) + ")"
111112
print "7-Load options file"
112-
print "8-Save options file"
113-
print "9-Back to main menu"
113+
print "8-Load options from saved Burp request"
114+
print "9-Save options file"
115+
print "x-Back to main menu"
114116

115117
select = raw_input("Select an option: ")
116118

@@ -188,8 +190,35 @@ def options():
188190
except:
189191
print "Couldn't load options file!"
190192
options()
191-
193+
192194
elif select == "8":
195+
loadPath = raw_input("Enter path to Burp request file: ")
196+
197+
try:
198+
fo = open(loadPath,"r")
199+
reqData = fo.readlines()
200+
201+
except:
202+
raw_input("error reading file. Press enter to continue...")
203+
mainMenu()
204+
205+
methodPath = reqData[0].split(" ")
206+
207+
if methodPath[0] == "GET":
208+
httpMethod = "GET"
209+
210+
elif methodPath[0] == "POST":
211+
httpMethod = "POST"
212+
postData = reqData[len(reqData)-1]
213+
else:
214+
print "unsupported method in request header."
215+
216+
victim = reqData[1].split( " ")[1].replace("\r\n","")
217+
optionSet[0] = True
218+
uri = methodPath[1].replace("\r\n","")
219+
optList[2] = True
220+
221+
elif select == "9":
193222
savePath = raw_input("Enter file name to save: ")
194223
try:
195224
fo = open(savePath, "wb")
@@ -198,9 +227,10 @@ def options():
198227
print "Options file saved!"
199228
except:
200229
print "Couldn't save options file."
201-
elif select == "9":
202-
mainMenu()
203230

231+
elif select == "x":
232+
mainMenu()
233+
204234
def netAttacks(target):
205235
mgtOpen = False
206236
webOpen = False
@@ -217,10 +247,7 @@ def netAttacks(target):
217247
mgtOpen = True
218248

219249
except:
220-
print "MongoDB port closed."
221-
222-
223-
250+
print "MongoDB port closed."
224251

225252
elif srvNeedCreds == "y" or srvNeedCreds == "Y":
226253
srvUser = raw_input("Enter server username: ")
@@ -243,17 +270,41 @@ def netAttacks(target):
243270
mgtRespCode = urllib.urlopen(mgtUrl).getcode()
244271
if mgtRespCode == 200:
245272
print "MongoDB web management open at " + mgtUrl + ". No authentication required!"
273+
testRest = raw_input("Start tests for REST Interface? ")
274+
275+
if testRest == "y" or testRest == "Y":
276+
restUrl = mgtUrl + "/listDatabases?text=1"
277+
restResp = urllib.urlopen(restUrl).read()
278+
restOn = restResp.find('REST is not enabled.')
279+
280+
if restOn == -1:
281+
print "REST interface enabled!"
282+
dbs = json.loads(restResp)
283+
menuItem = 1
284+
print "List of databases from REST API:"
285+
286+
for x in range(0,len(dbs['databases'])):
287+
dbTemp= dbs['databases'][x]['name']
288+
print str(menuItem) + "-" + dbTemp
289+
menuItem += 1
290+
print "\n"
291+
292+
else:
293+
print "REST interface not enabled."
246294

247295
except:
248296

249-
print "MongoDB web management closed or requires authentication."
297+
print "MongoDB web management closed or requires authentication."
250298

251299
if mgtOpen == True:
252300
#Ths is compiling server info?????
253301
print "Server Info:"
254-
serverInfo = conn.server_info()
255-
print serverInfo
256-
302+
mongoVer = conn.server_info()['version']
303+
print "MongoDB Version: " + mongoVer
304+
mongoDebug = conn.server_info()['debug']
305+
print "Debugs enabled : " + str(mongoDebug)
306+
mongoPlatform = conn.server_info()['bits']
307+
print "Platform: " + str(mongoPlatform) + " bit"
257308
print "\n"
258309

259310
try:
@@ -512,8 +563,8 @@ def webApps():
512563
print "Injected response was smaller than random response. Injection may have worked but requires verification."
513564
possAddrs.append(intThisNeqUri)
514565

515-
516-
doTimeAttack = raw_input("Start timing based tests?")
566+
print "\n"
567+
doTimeAttack = raw_input("Start timing based tests? ")
517568

518569
if doTimeAttack == "y" or doTimeAttack == "Y":
519570
print "Starting Javascript string escape time based injection..."

0 commit comments

Comments
 (0)