added config.py; refactored masscan a bit

This commit is contained in:
epi
2019-09-04 05:35:35 -05:00
parent d5fcd64289
commit a548ebc13c
2 changed files with 17 additions and 5 deletions

2
recon/config.py Normal file

File diff suppressed because one or more lines are too long

View File

@@ -5,6 +5,7 @@ from luigi.util import inherits
from luigi.contrib.external_program import ExternalProgramTask
from recon.targets import TargetList
from recon.config import top_tcp_ports, top_udp_ports
@inherits(TargetList)
@@ -19,15 +20,24 @@ class Masscan(ExternalProgramTask):
self.masscan_output = f"masscan.{self.target_file}.json"
def requires(self):
if self.ports and self.top_ports:
logging.error("Only --ports or --top-ports is permitted, not both.")
raise SystemExit
return {"target_list": TargetList(target_file=self.target_file)}
def output(self):
return luigi.LocalTarget(self.masscan_output)
def program_args(self):
if self.ports and self.top_ports:
logging.error("Only --ports or --top-ports is permitted, not both.")
raise SystemExit
if self.top_ports:
# if --top-ports used, format the top_*_ports lists as strings and then into a proper masscan --ports option
top_tcp_ports_str = ",".join(str(x) for x in top_tcp_ports)
top_udp_ports_str = ",".join(str(x) for x in top_udp_ports)
self.ports = f"{top_tcp_ports_str},U:{top_udp_ports_str}"
self.top_ports = ""
command = [
"masscan",
"-v",
@@ -39,8 +49,8 @@ class Masscan(ExternalProgramTask):
self.interface,
"-oJ",
self.masscan_output,
"--top-ports",
self.top_ports,
"--ports",
self.ports,
"-iL",
self.input().get("target_list").path,
]