13
13
#You should have received a copy of the GNU General Public License
14
14
#along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
16
+
16
17
import sys
17
18
import string
18
19
import random
22
23
import pymongo
23
24
from subprocess import call
24
25
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 ]
25
29
26
30
27
31
def mainMenu ():
@@ -41,10 +45,20 @@ def mainMenu():
41
45
options ()
42
46
43
47
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
+
45
54
46
55
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 ()
48
62
49
63
elif select == "4" :
50
64
sys .exit ()
@@ -60,34 +74,53 @@ def options():
60
74
global uri
61
75
global httpMethod
62
76
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
+
63
93
select = True
64
94
65
95
while select :
66
96
print "\n \n "
67
97
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 ) + ") "
71
101
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 ) + ") "
74
104
print "7-Back to main menu"
75
105
76
106
select = raw_input ("Select an option: " )
77
107
78
108
if select == "1" :
79
109
victim = raw_input ("Enter the host IP/DNS name: " )
80
110
print "Target set to " + victim + "\n "
111
+ optionSet [0 ] = True
81
112
options ()
82
113
83
114
elif select == "2" :
84
115
webPort = raw_input ("Enter the HTTP port for web apps: " )
85
116
print "HTTP port set to " + webPort + "\n "
117
+ optionSet [1 ] = True
86
118
options ()
87
119
88
120
elif select == "3" :
89
121
uri = raw_input ("Enter URI Path (Press enter for no URI): " )
90
122
print "URI Path set to " + uri + "\n "
123
+ optionSet [2 ] = True
91
124
options ()
92
125
93
126
elif select == "4" :
@@ -100,22 +133,26 @@ def options():
100
133
101
134
if httpMethod == "1" :
102
135
print "GET request set"
136
+ optionSet [3 ] = True
103
137
options ()
104
138
105
139
elif httpMethod == "2" :
106
140
print "POST request set"
141
+ optionSet [3 ] = True
107
142
options ()
108
143
else :
109
144
print "Invalid selection"
110
145
111
146
elif select == "5" :
112
147
myIP = raw_input ("Enter host IP for my Mongo/Shells: " )
113
148
print "Shell IP set to " + myIP + "\n "
149
+ optionSet [4 ] = True
114
150
options ()
115
151
116
152
elif select == "6" :
117
153
myPort = raw_input ("Enter TCP listener for shells: " )
118
154
print "Shell TCP listener set to " + myPort + "\n "
155
+ optionSet [5 ] = True
119
156
options ()
120
157
121
158
elif select == "7" :
@@ -136,9 +173,10 @@ def netAttacks(target):
136
173
137
174
138
175
mgtUrl = "http://" + target + ":28017"
139
- mgtRespCode = urllib .urlopen (mgtUrl ).getcode ()
140
176
141
- try :
177
+
178
+ try :
179
+ mgtRespCode = urllib .urlopen (mgtUrl ).getcode ()
142
180
if mgtRespCode == 200 :
143
181
print "MongoDB web management open at " + mgtUrl + ". Check this out!"
144
182
@@ -184,9 +222,9 @@ def webApps():
184
222
print "Checking to see if site at " + str (victim ) + ":" + str (webPort ) + str (uri ) + " is up..."
185
223
186
224
appURL = "http://" + str (victim ) + ":" + str (webPort ) + str (uri )
187
- appRespCode = urllib .urlopen (appURL ).getcode ()
188
225
189
226
try :
227
+ appRespCode = urllib .urlopen (appURL ).getcode ()
190
228
if appRespCode == 200 :
191
229
normLength = int (len (urllib .urlopen (appURL ).read ()))
192
230
@@ -401,7 +439,7 @@ def stealDBs(myDB):
401
439
return ()
402
440
403
441
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 ( )
406
444
407
445
mainMenu ()
0 commit comments