Skip to content

Commit 8e54467

Browse files
committed
v0.08
1 parent a69ea87 commit 8e54467

File tree

1 file changed

+50
-12
lines changed

1 file changed

+50
-12
lines changed

nosqlmap.py

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#You should have received a copy of the GNU General Public License
1414
#along with this program. If not, see <http://www.gnu.org/licenses/>.
1515

16+
1617
import sys
1718
import string
1819
import random
@@ -22,6 +23,9 @@
2223
import pymongo
2324
from subprocess import call
2425

26+
#Set a list so we can track whether options are set or not
27+
global optionSet
28+
optionSet = [False,False,False,False,False,False]
2529

2630

2731
def mainMenu():
@@ -41,10 +45,20 @@ def mainMenu():
4145
options()
4246

4347
elif select == "2":
44-
netAttacks(victim)
48+
if optionSet[0] == True:
49+
netAttacks(victim)
50+
else:
51+
raw_input("Target not set! Check options. Press enter to continue...")
52+
mainMenu()
53+
4554

4655
elif select == "3":
47-
webApps()
56+
if (optionSet[0] == True) and (optionSet[2] == True):
57+
webApps()
58+
59+
else:
60+
raw_input("Options not set! Check Host and URI path. Press enter to continue...")
61+
mainMenu()
4862

4963
elif select == "4":
5064
sys.exit()
@@ -60,34 +74,53 @@ def options():
6074
global uri
6175
global httpMethod
6276
global myIP
77+
global myPort
78+
79+
80+
if optionSet[0] == False:
81+
victim = "Not Set"
82+
if optionSet[1] == False:
83+
webPort = 80
84+
if optionSet[2] == False:
85+
uri = "Not Set"
86+
if optionSet[3] == False:
87+
httpMethod = "GET"
88+
if optionSet[4] == False:
89+
myIP = "Not Set"
90+
if optionSet[5] == False:
91+
myPort = "Not Set"
92+
6393
select = True
6494

6595
while select:
6696
print "\n\n"
6797
print "Options"
68-
print "1-Set target host/IP"
69-
print "2-Set web app port"
70-
print "3-Set URI Path"
98+
print "1-Set target host/IP (Current: " + str(victim) + ")"
99+
print "2-Set web app port (Current: " + str(webPort) + ")"
100+
print "3-Set URI Path (Current: " + str(uri) + ")"
71101
print "4-Set HTTP Request Method (GET/POST)"
72-
print "5-Set my local Mongo/Shell IP"
73-
print "6-Set shell listener port"
102+
print "5-Set my local Mongo/Shell IP (Current: " + str(myIP) + ")"
103+
print "6-Set shell listener port (Current: " + str(myPort) + ")"
74104
print "7-Back to main menu"
75105

76106
select = raw_input("Select an option: ")
77107

78108
if select == "1":
79109
victim = raw_input("Enter the host IP/DNS name: ")
80110
print "Target set to " + victim + "\n"
111+
optionSet[0] = True
81112
options()
82113

83114
elif select == "2":
84115
webPort = raw_input("Enter the HTTP port for web apps: ")
85116
print "HTTP port set to " + webPort + "\n"
117+
optionSet[1] = True
86118
options()
87119

88120
elif select == "3":
89121
uri = raw_input("Enter URI Path (Press enter for no URI): ")
90122
print "URI Path set to " + uri + "\n"
123+
optionSet[2] = True
91124
options()
92125

93126
elif select == "4":
@@ -100,22 +133,26 @@ def options():
100133

101134
if httpMethod == "1":
102135
print "GET request set"
136+
optionSet[3] = True
103137
options()
104138

105139
elif httpMethod == "2":
106140
print "POST request set"
141+
optionSet[3] = True
107142
options()
108143
else:
109144
print "Invalid selection"
110145

111146
elif select == "5":
112147
myIP = raw_input("Enter host IP for my Mongo/Shells: ")
113148
print "Shell IP set to " + myIP + "\n"
149+
optionSet[4] = True
114150
options()
115151

116152
elif select == "6":
117153
myPort = raw_input("Enter TCP listener for shells: ")
118154
print "Shell TCP listener set to " + myPort + "\n"
155+
optionSet[5] = True
119156
options()
120157

121158
elif select == "7":
@@ -136,9 +173,10 @@ def netAttacks(target):
136173

137174

138175
mgtUrl = "http://" + target + ":28017"
139-
mgtRespCode = urllib.urlopen(mgtUrl).getcode()
140176

141-
try:
177+
178+
try:
179+
mgtRespCode = urllib.urlopen(mgtUrl).getcode()
142180
if mgtRespCode == 200:
143181
print "MongoDB web management open at " + mgtUrl + ". Check this out!"
144182

@@ -184,9 +222,9 @@ def webApps():
184222
print "Checking to see if site at " + str(victim) + ":" + str(webPort) + str(uri) + " is up..."
185223

186224
appURL = "http://" + str(victim) + ":" + str(webPort) + str(uri)
187-
appRespCode = urllib.urlopen(appURL).getcode()
188225

189226
try:
227+
appRespCode = urllib.urlopen(appURL).getcode()
190228
if appRespCode == 200:
191229
normLength = int(len(urllib.urlopen(appURL).read()))
192230

@@ -401,7 +439,7 @@ def stealDBs(myDB):
401439
return()
402440

403441
except:
404-
print "Something went wrong. Are you sure your MongoDB is running?" , sys.exc_info()
405-
stealDBs(myDB)
442+
raw_input ("Something went wrong. Are you sure your MongoDB is running and options are set? Press enter to return...")
443+
mainMenu()
406444

407445
mainMenu()

0 commit comments

Comments
 (0)