-
Notifications
You must be signed in to change notification settings - Fork 2
/
hostWork.py
50 lines (44 loc) · 1.69 KB
/
hostWork.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import re
import ast
import configparser
import os
import dbQueue
from utils.helper import whine
from utils.osWork import muxER
from dbWork import db_runner
def discoverHosts(network):
whine( "Welcome to discoverHosts: " + network, "info")
#network should equal 10.10.10.10/24
#fping -a -I eth0 -R -g network
#netdiscover -i eth0 -P -r network
#arp-scan --interface=eth0 network
def msfSafeChecks(network,output):
whine( "Welcome to MSF Safe Checks: " + '\033[95m' + network + '\033[0m', "info")
config = configparser.ConfigParser()
msfCFG = os.path.abspath(os.path.dirname(__file__)) + "/utils/msf.ini"
whine( "Loading Safe Checks from: " + msfCFG, "debug")
config.read(msfCFG)
MSF = ast.literal_eval(config.get("MSF-SAFE", "msfLIST"))
conn = dbQueue.conn
host = network.split('/', 1)[0]
DBselect = "SELECT host, port, serviceID FROM results WHERE host='" + host + "'"
whine( "Gathering ports : " + host, "debug")
r = db_runner(conn, DBselect)
if not r: return
serviceSET = set(r)
for i in serviceSET:
port = i[1]
service = i[2]
whine( "Identifying MSF Safe Checks for Port: " + port + " Service: " + service, "debug" )
regEX = ".*" + service
r = re.compile(regEX)
msfLIST = list(filter(r.match, MSF))
for module in msfLIST:
m = module.rsplit('/', 1)[-1]
# At this point we already did HTTP so lets skip them. That might change tho
if "http" in module: continue
whine( "Running Metasploit Module: " + module, "debug")
f = output + "_Metasploit_" + m + ".txt"
cmd = "msfconsole -x \"use " + module + ";set rhosts " + host + ";set rport " + port + "; run; exit\" > " + f
muxER(cmd)
whine( "Done with MSF Safe Checks: " + '\033[95m' + network + '\033[0m', "info")