29
29
#Set a list so we can track whether options are set or not to avoid resetting them in subsequent cals to the options menu.
30
30
global optionSet
31
31
optionSet = [False ,False ,False ,False ,False ,False ]
32
+ global victim
33
+ global webPort
34
+ global uri
35
+ global httpMethod
36
+ global myIP
37
+ global myPort
32
38
33
39
34
40
def mainMenu ():
@@ -39,10 +45,11 @@ def mainMenu():
39
45
print "NoSQLMap-v0.15b"
40
46
41
47
print "\n "
42
- print "1-Set options (do this first) "
48
+ print "1-Set options"
43
49
print "2-NoSQL DB Access Attacks"
44
50
print "3-NoSQL Web App attacks"
45
- print "4-Exit"
51
+ print "4-Scan for Anonymous MongoDB Access"
52
+ print "5-Exit"
46
53
47
54
select = raw_input ("Select an option: " )
48
55
@@ -67,8 +74,11 @@ def mainMenu():
67
74
else :
68
75
raw_input ("Options not set! Check Host and URI path. Press enter to continue..." )
69
76
mainMenu ()
70
-
77
+
71
78
elif select == "4" :
79
+ massMongo ()
80
+
81
+ elif select == "5" :
72
82
sys .exit ()
73
83
74
84
else :
@@ -83,7 +93,6 @@ def options():
83
93
global httpMethod
84
94
global myIP
85
95
global myPort
86
-
87
96
#Set default value if needed
88
97
if optionSet [0 ] == False :
89
98
victim = "Not Set"
@@ -829,6 +838,57 @@ def stealDBs(myDB):
829
838
830
839
except :
831
840
raw_input ("Something went wrong. Are you sure your MongoDB is running and options are set? Press enter to return..." )
832
- mainMenu ()
841
+ mainMenu ()
842
+
843
+ def massMongo ():
844
+ global victim
845
+ success = []
846
+ print "\n "
847
+ print "Massmongo-Scan for default access to MongoDB servers"
848
+ print "===================================================="
849
+ loadPath = raw_input ("Enter file name with IP list to scan: " )
850
+
851
+ with open (loadPath ) as f :
852
+ ipList = f .readlines ()
853
+
854
+
855
+ for target in ipList :
856
+ try :
857
+ conn = pymongo .MongoClient (target ,27017 )
858
+ print " Connected to " + target [:- 1 ]
859
+ dbList = conn .database_names ()
860
+
861
+ print "Successful admin access to " + target [:- 1 ]
862
+ target = target [:- 1 ]
863
+ success .append (target )
864
+ conn .disconnect ()
865
+
866
+ except :
867
+ print "Failed to connect to " + target + " or credentials required."
868
+
869
+ print "\n \n "
870
+ print "Discovered MongoDB Servers:"
871
+
872
+ menuItem = 1
873
+ print "List of servers:"
874
+ for server in success :
875
+ print str (menuItem ) + "-" + server
876
+ menuItem += 1
877
+
878
+ select = True
879
+ while select :
880
+ select = raw_input ("Select a NoSQLMap target or press x to exit: " )
881
+
882
+ if select == "x" or select == "X" :
883
+ mainMenu ()
884
+
885
+ elif select .isdigit () == True :
886
+ victim = success [int (select ) - 1 ]
887
+ optionSet [0 ] = True
888
+ raw_input ("New target set! Press enter to return to the main menu." )
889
+ mainMenu ()
890
+
891
+ else :
892
+ raw_input ("Invalid selection." )
833
893
834
894
mainMenu ()
0 commit comments