forked from p15670423/monkey
Agent: Integrate scan configuration with network scanning thread
This commit is contained in:
parent
8c47d113c3
commit
25410716d3
|
@ -160,7 +160,7 @@ class AutomatedMaster(IMaster):
|
||||||
hosts_to_exploit = Queue()
|
hosts_to_exploit = Queue()
|
||||||
|
|
||||||
scan_thread = _create_daemon_thread(
|
scan_thread = _create_daemon_thread(
|
||||||
target=self._scan_network, args=(config, hosts_to_exploit)
|
target=self._scan_network, args=(config["network_scan"], hosts_to_exploit)
|
||||||
)
|
)
|
||||||
exploit_thread = _create_daemon_thread(
|
exploit_thread = _create_daemon_thread(
|
||||||
target=self._exploit_targets, args=(hosts_to_exploit, scan_thread)
|
target=self._exploit_targets, args=(hosts_to_exploit, scan_thread)
|
||||||
|
@ -208,11 +208,8 @@ class AutomatedMaster(IMaster):
|
||||||
|
|
||||||
victim_host = VictimHost(ip)
|
victim_host = VictimHost(ip)
|
||||||
|
|
||||||
self._ping_ip(ip, victim_host)
|
self._ping_ip(ip, victim_host, scan_config["icmp"])
|
||||||
|
self._scan_tcp_ports(ip, victim_host, scan_config["tcp"])
|
||||||
# TODO: get ports from config
|
|
||||||
ports = [22, 445, 3389, 8008]
|
|
||||||
self._scan_tcp_ports(ip, ports, victim_host)
|
|
||||||
|
|
||||||
hosts_to_exploit.put(hosts_to_exploit)
|
hosts_to_exploit.put(hosts_to_exploit)
|
||||||
self._telemetry_messenger.send_telemetry(ScanTelem(victim_host))
|
self._telemetry_messenger.send_telemetry(ScanTelem(victim_host))
|
||||||
|
@ -224,19 +221,20 @@ class AutomatedMaster(IMaster):
|
||||||
|
|
||||||
logger.debug(f"Detected the stop signal, scanning thread {threading.get_ident()} exiting")
|
logger.debug(f"Detected the stop signal, scanning thread {threading.get_ident()} exiting")
|
||||||
|
|
||||||
def _ping_ip(self, ip: str, victim_host: VictimHost):
|
def _ping_ip(self, ip: str, victim_host: VictimHost, options: Dict):
|
||||||
(response_received, os) = self._puppet.ping(ip)
|
(response_received, os) = self._puppet.ping(ip, options)
|
||||||
|
|
||||||
victim_host.icmp = response_received
|
victim_host.icmp = response_received
|
||||||
if os is not None:
|
if os is not None:
|
||||||
victim_host.os["type"] = os
|
victim_host.os["type"] = os
|
||||||
|
|
||||||
def _scan_tcp_ports(self, ip: str, ports: List[int], victim_host: VictimHost):
|
def _scan_tcp_ports(self, ip: str, victim_host: VictimHost, options: Dict):
|
||||||
for p in ports:
|
for p in options["ports"]:
|
||||||
if self._stop.is_set():
|
if self._stop.is_set():
|
||||||
break
|
break
|
||||||
|
|
||||||
port_scan_data = self._puppet.scan_tcp_port(ip, p)
|
# TODO: check units of timeout
|
||||||
|
port_scan_data = self._puppet.scan_tcp_port(ip, p, options["timeout"])
|
||||||
if port_scan_data.status == PortStatus.OPEN:
|
if port_scan_data.status == PortStatus.OPEN:
|
||||||
victim_host.services[port_scan_data.service] = {}
|
victim_host.services[port_scan_data.service] = {}
|
||||||
victim_host.services[port_scan_data.service]["display_name"] = "unknown(TCP)"
|
victim_host.services[port_scan_data.service]["display_name"] = "unknown(TCP)"
|
||||||
|
|
Loading…
Reference in New Issue