Skip to content

Commit cc67311

Browse files
committed
Add IP checking for attacker host
1 parent 9f7e060 commit cc67311

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

nosqlmap.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def options():
137137
select = raw_input("Select an option: ")
138138

139139
if select == "1":
140-
#Unset the boolean since we're setting it again.
140+
#Unset the boolean if it's set since we're setting it again.
141141
optionSet[0] = False
142142
goodLen = False
143143
goodDigits = False
@@ -209,10 +209,41 @@ def options():
209209
print "Invalid selection"
210210

211211
elif select == "5":
212-
myIP = raw_input("Enter host IP for my Mongo/Shells: ")
213-
print "Shell IP set to " + myIP + "\n"
214-
optionSet[4] = True
212+
#Unset the setting boolean since we're setting it again.
213+
optionSet[4] = False
214+
goodLen = False
215+
goodDigits = False
216+
while optionSet[4] == False:
217+
myIP = raw_input("Enter the host IP for my Mongo/Shells: ")
218+
#make sure we got a valid IP
219+
octets = myIP.split(".")
220+
#If there aren't 4 octets, toss an error.
221+
if len(octets) != 4:
222+
print "Invalid IP length."
223+
224+
else:
225+
goodLen = True
226+
227+
if goodLen == True:
228+
#If the format of the IP is good, check and make sure the octets are all within acceptable ranges.
229+
for item in octets:
230+
if int(item) < 0 or int(item) > 255:
231+
print "Bad octet in IP address."
232+
goodDigits = False
233+
234+
else:
235+
goodDigits = True
236+
237+
238+
#If everything checks out set the IP and break the loop
239+
if goodLen == True and goodDigits == True:
240+
print "\nShell/DB listener set to " + myIP + "\n"
241+
optionSet[4] = True
215242
options()
243+
#myIP = raw_input("Enter host IP for my Mongo/Shells: ")
244+
#print "Shell IP set to " + myIP + "\n"
245+
#optionSet[4] = True
246+
#options()
216247

217248
elif select == "6":
218249
myPort = raw_input("Enter TCP listener for shells: ")

0 commit comments

Comments
 (0)