@@ -380,7 +380,7 @@ def netAttacks(target):
380
380
dbList = []
381
381
382
382
print "Checking to see if credentials are needed..."
383
- needCreds = accessCheck (target ,dbPort )
383
+ needCreds = accessCheck (target ,dbPort , False )
384
384
385
385
if needCreds == 0 :
386
386
conn = pymongo .MongoClient (target ,dbPort )
@@ -1335,32 +1335,61 @@ def stealDBs(myDB):
1335
1335
raw_input ("Something went wrong. Are you sure your MongoDB is running and options are set? Press enter to return..." )
1336
1336
return
1337
1337
1338
- def accessCheck (ip ,port ):
1339
- try :
1340
- conn = pymongo .MongoClient (ip ,port )
1338
+ def accessCheck (ip ,port ,pingIt ):
1339
+
1340
+ if pingIt == True :
1341
+ test = os .system ("ping -w 0.1 -c 1 " + ip + ">/dev/null" )
1342
+
1343
+ if test == 0 :
1344
+ try :
1345
+ conn = pymongo .MongoClient (ip ,port )
1341
1346
1347
+ try :
1348
+ dbList = conn .database_names ()
1349
+ conn .disconnect ()
1350
+ return 0
1351
+
1352
+ except :
1353
+ if str (sys .exc_info ()).find ('need to login' ) != - 1 :
1354
+ conn .disconnect ()
1355
+ return 1
1356
+
1357
+ else :
1358
+ conn .disconnect ()
1359
+ return 2
1360
+
1361
+ except :
1362
+ return 3
1363
+
1364
+ else :
1365
+ return 4
1366
+ else :
1342
1367
try :
1343
- dbList = conn .database_names ()
1344
- conn .disconnect ()
1345
- return 0
1368
+ conn = pymongo .MongoClient (ip ,port )
1346
1369
1347
- except :
1348
- if str ( sys . exc_info ()). find ( 'need to login' ) != - 1 :
1370
+ try :
1371
+ dbList = conn . database_names ()
1349
1372
conn .disconnect ()
1350
- return 1
1373
+ return 0
1374
+
1375
+ except :
1376
+ if str (sys .exc_info ()).find ('need to login' ) != - 1 :
1377
+ conn .disconnect ()
1378
+ return 1
1351
1379
1352
- else :
1353
- conn .disconnect ()
1354
- return 2
1380
+ else :
1381
+ conn .disconnect ()
1382
+ return 2
1355
1383
1356
- except :
1357
- return 3
1358
-
1384
+ except :
1385
+ return 3
1359
1386
1387
+
1360
1388
def massMongo ():
1361
1389
global victim
1362
1390
optCheck = True
1363
1391
loadCheck = False
1392
+ ping = False
1364
1393
success = []
1365
1394
creds = []
1366
1395
ipList = []
@@ -1369,10 +1398,11 @@ def massMongo():
1369
1398
print "=============================="
1370
1399
print "1-Scan a subnet for default MongoDB access"
1371
1400
print "2-Loads IPs to scan from a file"
1401
+ print "3-Enable/disable host pings before attempting connection"
1372
1402
print "x-Return to main menu"
1373
1403
1374
1404
while optCheck :
1375
- loadOpt = raw_input ("Select a scan method : " )
1405
+ loadOpt = raw_input ("Select an option : " )
1376
1406
1377
1407
if loadOpt == "1" :
1378
1408
subnet = raw_input ("Enter subnet to scan: " )
@@ -1396,14 +1426,23 @@ def massMongo():
1396
1426
optCheck = False
1397
1427
except :
1398
1428
print "Couldn't open file."
1429
+
1430
+ if loadOpt == "3" :
1431
+ if ping == False :
1432
+ ping = True
1433
+ print "Scan will ping host before connection attempt."
1434
+
1435
+ elif ping == True :
1436
+ ping = False
1437
+ print "Scan will not ping host before connection attempt."
1399
1438
1400
1439
if loadOpt == "x" :
1401
1440
return
1402
1441
1403
1442
1404
1443
print "\n "
1405
1444
for target in ipList :
1406
- result = accessCheck (target ,27017 )
1445
+ result = accessCheck (target ,27017 , ping )
1407
1446
1408
1447
if result == 0 :
1409
1448
print "Successful default access on " + target + "."
@@ -1419,6 +1458,9 @@ def massMongo():
1419
1458
1420
1459
elif result == 3 :
1421
1460
print "Couldn't connect to " + target + "."
1461
+
1462
+ elif result == 4 :
1463
+ print target + " didn't respond to ping."
1422
1464
1423
1465
1424
1466
print "\n \n "
0 commit comments