Skip to content

Commit 94774c9

Browse files
committed
Error handling for file loads
1 parent 8ed1eef commit 94774c9

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

nosqlmap.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -879,14 +879,22 @@ def stealDBs(myDB):
879879

880880
def massMongo():
881881
global victim
882+
loadCheck = False
882883
success = []
883884
print "\n"
884885
print "MongoDB Default Access Scanner"
885886
print "=============================="
886-
loadPath = raw_input("Enter file name with IP list to scan: ")
887+
888+
while loadCheck == False:
889+
loadPath = raw_input("Enter file name with IP list to scan: ")
887890

888-
with open (loadPath) as f:
889-
ipList = f.readlines()
891+
try:
892+
with open (loadPath) as f:
893+
ipList = f.readlines()
894+
loadCheck = True
895+
except:
896+
print "Couldn't open file."
897+
890898

891899
print "\n"
892900
for target in ipList:
@@ -933,18 +941,22 @@ def gen_pass(user, passw):
933941

934942

935943
def brute_pass(user,key):
936-
dictionary = raw_input("Enter path to password dictionary: ")
937-
#print user
938-
#print key
939-
print "Preparing dictionary attack..."
940-
with open (dictionary) as f:
941-
passList = f.readlines()
942-
943-
print "debug: " + str(passList)
944-
944+
loadCheck = False
945+
946+
while loadCheck == False:
947+
dictionary = raw_input("Enter path to password dictionary: ")
948+
try:
949+
with open (dictionary) as f:
950+
passList = f.readlines()
951+
loadCheck = True
952+
except:
953+
print " Couldn't load file."
954+
955+
956+
print "Running dictionary attack..."
945957
for passGuess in passList:
946958
temp = passGuess.split("\n")[0]
947-
#print "debug: " + temp
959+
948960
if gen_pass(user, temp) == key:
949961
print "\nFound - "+user+":"+passGuess
950962
return passGuess

0 commit comments

Comments
 (0)