3434import re
3535from hashlib import md5
3636from threading import Thread
37+ import Queue
3738
3839#Set a list so we can track whether options are set or not to avoid resetting them in subsequent cals to the options menu.
3940global optionSet
@@ -1498,6 +1499,10 @@ def stealDBs(myDB,mongoConn):
14981499 return
14991500
15001501def accessCheck (ip ,port ,pingIt ):
1502+ global success
1503+ global versions
1504+ global creds
1505+ global commError
15011506
15021507 if pingIt == True :
15031508 test = os .system ("ping -c 1 -n -W 1 " + ip + ">/dev/null" )
@@ -1510,22 +1515,32 @@ def accessCheck(ip,port,pingIt):
15101515 dbList = conn .database_names ()
15111516 dbVer = conn .server_info ()['version' ]
15121517 conn .disconnect ()
1513- return [0 ,dbVer ]
1518+ print "Successful default access on " + ip .rstrip () + "(Mongo Version: " + dbVer + ")."
1519+ success .append (ip .rstrip ())
1520+ versions .append (dbVer )
1521+ return
15141522
15151523 except :
15161524 if str (sys .exc_info ()).find ('need to login' ) != - 1 :
15171525 conn .disconnect ()
1518- return [1 ,None ]
1526+ print "MongoDB running but credentials required on " + ip .rstrip () + "."
1527+ creds .append (ip .rstrip ()) #Future use
1528+ return
15191529
15201530 else :
15211531 conn .disconnect ()
1522- return [2 ,None ]
1532+ print "Successful MongoDB connection to " + ip .rstrip () + " but error executing command."
1533+ commError .append (ip .rstrip ())
1534+ return
15231535
15241536 except :
1525- return [3 ,None ]
1537+ print "Couldn't connect to " + ip .rstrip () + "."
1538+ return
1539+
15261540
15271541 else :
1528- return [4 ,None ]
1542+ print target .rstrip () + " didn't respond to ping."
1543+ return
15291544 else :
15301545 try :
15311546 conn = pymongo .MongoClient (ip ,port ,connectTimeoutMS = 4000 ,socketTimeoutMS = 4000 )
@@ -1534,26 +1549,38 @@ def accessCheck(ip,port,pingIt):
15341549 dbList = conn .database_names ()
15351550 dbVer = conn .server_info ()['version' ]
15361551 conn .disconnect ()
1537- return [0 ,dbVer ]
1552+ print "Successful default access on " + ip .rstrip () + "(Mongo Version: " + dbVer + ")."
1553+ success .append (ip .rstrip ())
1554+ versions .append (dbVer )
1555+ return
15381556
15391557 except :
15401558 if str (sys .exc_info ()).find ('need to login' ) != - 1 :
15411559 conn .disconnect ()
1542- return [1 ,None ]
1560+ print "MongoDB running but credentials required on " + ip .rstrip () + "."
1561+ creds .append (ip .rstrip ()) #Future use
1562+ return
15431563
15441564 else :
15451565 conn .disconnect ()
1546- return [2 ,None ]
1566+ print "Successful MongoDB connection to " + ip .rstrip () + " but error executing command."
1567+ commError .append (ip .rstrip ())
1568+ return
15471569
15481570 except :
1549- return [3 ,None ]
1571+ print "Couldn't connect to " + ip .rstrip () + "."
1572+ return
15501573
15511574
15521575def massMongo ():
15531576 global victim
15541577 optCheck = True
15551578 loadCheck = False
15561579 ping = False
1580+ global success
1581+ global versions
1582+ global creds
1583+ global commError
15571584 success = []
15581585 versions = []
15591586 creds = []
@@ -1608,27 +1635,10 @@ def massMongo():
16081635
16091636 print "\n "
16101637 for target in ipList :
1611- result = accessCheck (target .rstrip (),27017 ,ping )
1612-
1613- if result [0 ] == 0 :
1614- print "Successful default access on " + target .rstrip () + "(Mongo Version: " + result [1 ] + ")."
1615- success .append (target .rstrip ())
1616- versions .append (result [1 ])
1617-
1618- elif result [0 ] == 1 :
1619- print "MongoDB running but credentials required on " + target .rstrip () + "."
1620- creds .append (target .rstrip ()) #Future use
1621-
1622- elif result [0 ] == 2 :
1623- print "Successful MongoDB connection to " + target .rstrip () + " but error executing command."
1624- commError .append (target .rstrip ()) #Future use
1625-
1626- elif result [0 ] == 3 :
1627- print "Couldn't connect to " + target .rstrip () + "."
1638+ #result = accessCheck(target.rstrip(),27017,ping)
16281639
1629- elif result [0 ] == 4 :
1630- print target .rstrip () + " didn't respond to ping."
1631-
1640+ t = Thread (target = accessCheck , args = (target .rstrip (), 27017 , ping ))
1641+ t .start ()
16321642
16331643 print "\n \n "
16341644 select = True
0 commit comments