3535from hashlib import md5
3636from threading import Thread
3737
38- #Set a list so we can track whether options are set or not to avoid resetting them in subsequent cals to the options menu.
39- global optionSet
40- optionSet = [False ,False ,False ,False ,False ,False ,False ,False ,False ]
41- global yes_tag
42- global no_tag
43- yes_tag = ['y' , 'Y' ]
44- no_tag = ['n' , 'N' ]
45- global victim
46- global webPort
47- global uri
48- global httpMethod
49- global https
50- global myIP
51- global myPort
52- global verb
53- global scanNeedCreds
54- global dbPort
55- dbPort = 27017
5638
39+ def main ():
40+ signal .signal (signal .SIGINT , signal_handler )
41+ global optionSet
42+ #Set a list so we can track whether options are set or not to avoid resetting them in subsequent cals to the options menu.
43+ optionSet = [False ,False ,False ,False ,False ,False ,False ,False ,False ]
44+ global yes_tag
45+ global no_tag
46+ yes_tag = ['y' , 'Y' ]
47+ no_tag = ['n' , 'N' ]
48+ global victim
49+ global webPort
50+ global uri
51+ global httpMethod
52+ global https
53+ global myIP
54+ global myPort
55+ global verb
56+ global scanNeedCreds
57+ global dbPort
58+ dbPort = 27017
59+ mainMenu ()
60+
5761def mainMenu ():
5862 mmSelect = True
5963 while mmSelect :
@@ -67,7 +71,7 @@ def mainMenu():
6771 print "| |\ | (_) /\__/ /\ \/' / |____| | | | (_| | |_) |"
6872 print "\_| \_/\___/\____/ \_/\_\_____/\_| |_/\__,_| .__/"
6973 print "===================================================="
70- print "NoSQLMap-v0.4 "
74+ print "NoSQLMap-v0.4a-DEV "
71757276 print "\n "
7377 print "1-Set options"
@@ -1439,10 +1443,11 @@ def buildUri(origUri, randValue):
14391443
14401444def stealDBs (myDB ,mongoConn ):
14411445 dbList = mongoConn .database_names ()
1446+ dbLoot = True
14421447 menuItem = 1
14431448 if optionSet [4 ] == False :
1444- raw_input ("No destination database set! Press enter to return to the main menu ." )
1445- mainMenu ()
1449+ raw_input ("No destination database set! Press enter to return." )
1450+ return
14461451
14471452 if len (dbList ) == 0 :
14481453 print "Can't get a list of databases to steal. The provided credentials may not have rights."
@@ -1452,12 +1457,14 @@ def stealDBs(myDB,mongoConn):
14521457 print str (menuItem ) + "-" + dbName
14531458 menuItem += 1
14541459
1455- try :
1460+ while dbLoot :
14561461 dbLoot = raw_input ("Select a database to steal:" )
1457-
1458- except :
1459- print "Invalid selection."
1460- stealDBs (myDB )
1462+
1463+ if dbLoot > menuItem :
1464+ print "Invalid selection."
1465+
1466+ else :
1467+ dbLoot = False
14611468
14621469 try :
14631470 #Mongo can only pull, not push, connect to my instance and pull from verified open remote instance.
@@ -1990,5 +1997,5 @@ def signal_handler(signal, frame):
19901997 print "CTRL+C detected. Exiting."
19911998 sys .exit ()
19921999
1993- signal . signal ( signal . SIGINT , signal_handler )
1994- mainMenu ()
2000+ if __name__ == '__main__' :
2001+ main ()
0 commit comments