forked from p15670423/monkey
Agent: Remove duplicate functionality that checked for open port
This commit is contained in:
parent
44479ef49e
commit
b28f330e8f
|
@ -60,7 +60,7 @@ class IPScanner:
|
||||||
port_scan_data = self._scan_tcp_ports(ip, tcp_ports, tcp_timeout, stop)
|
port_scan_data = self._scan_tcp_ports(ip, tcp_ports, tcp_timeout, stop)
|
||||||
|
|
||||||
fingerprint_data = {}
|
fingerprint_data = {}
|
||||||
if IPScanner._found_open_port(port_scan_data):
|
if IPScanner.port_scan_found_open_port(port_scan_data):
|
||||||
fingerprinters = options["fingerprinters"]
|
fingerprinters = options["fingerprinters"]
|
||||||
fingerprint_data = self._run_fingerprinters(
|
fingerprint_data = self._run_fingerprinters(
|
||||||
ip, fingerprinters, ping_scan_data, port_scan_data, stop
|
ip, fingerprinters, ping_scan_data, port_scan_data, stop
|
||||||
|
@ -92,12 +92,8 @@ class IPScanner:
|
||||||
return port_scan_data
|
return port_scan_data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _found_open_port(port_scan_data: Dict[int, PortScanData]):
|
def port_scan_found_open_port(port_scan_data: Dict[int, PortScanData]):
|
||||||
for psd in port_scan_data.values():
|
return any(psd.status == PortStatus.OPEN for psd in port_scan_data.values())
|
||||||
if psd.status == PortStatus.OPEN:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _run_fingerprinters(
|
def _run_fingerprinters(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -55,12 +55,10 @@ class Propagator:
|
||||||
victim_host = VictimHost(ip)
|
victim_host = VictimHost(ip)
|
||||||
|
|
||||||
Propagator._process_ping_scan_results(victim_host, scan_results.ping_scan_data)
|
Propagator._process_ping_scan_results(victim_host, scan_results.ping_scan_data)
|
||||||
has_open_port = Propagator._process_tcp_scan_results(
|
Propagator._process_tcp_scan_results(victim_host, scan_results.port_scan_data)
|
||||||
victim_host, scan_results.port_scan_data
|
|
||||||
)
|
|
||||||
Propagator._process_fingerprinter_results(victim_host, scan_results.fingerprint_data)
|
Propagator._process_fingerprinter_results(victim_host, scan_results.fingerprint_data)
|
||||||
|
|
||||||
if has_open_port:
|
if IPScanner.port_scan_found_open_port(scan_results.port_scan_data):
|
||||||
self._hosts_to_exploit.put(victim_host)
|
self._hosts_to_exploit.put(victim_host)
|
||||||
|
|
||||||
self._telemetry_messenger.send_telemetry(ScanTelem(victim_host))
|
self._telemetry_messenger.send_telemetry(ScanTelem(victim_host))
|
||||||
|
@ -73,20 +71,14 @@ class Propagator:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_tcp_scan_results(victim_host: VictimHost, port_scan_data: PortScanData) -> bool:
|
def _process_tcp_scan_results(victim_host: VictimHost, port_scan_data: PortScanData) -> bool:
|
||||||
has_open_port = False
|
|
||||||
|
|
||||||
for psd in port_scan_data.values():
|
for psd in port_scan_data.values():
|
||||||
if psd.status == PortStatus.OPEN:
|
if psd.status == PortStatus.OPEN:
|
||||||
has_open_port = True
|
|
||||||
|
|
||||||
victim_host.services[psd.service] = {}
|
victim_host.services[psd.service] = {}
|
||||||
victim_host.services[psd.service]["display_name"] = "unknown(TCP)"
|
victim_host.services[psd.service]["display_name"] = "unknown(TCP)"
|
||||||
victim_host.services[psd.service]["port"] = psd.port
|
victim_host.services[psd.service]["port"] = psd.port
|
||||||
if psd.banner is not None:
|
if psd.banner is not None:
|
||||||
victim_host.services[psd.service]["banner"] = psd.banner
|
victim_host.services[psd.service]["banner"] = psd.banner
|
||||||
|
|
||||||
return has_open_port
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_fingerprinter_results(victim_host: VictimHost, fingerprint_data: FingerprintData):
|
def _process_fingerprinter_results(victim_host: VictimHost, fingerprint_data: FingerprintData):
|
||||||
for fd in fingerprint_data.values():
|
for fd in fingerprint_data.values():
|
||||||
|
|
Loading…
Reference in New Issue