Island: Simplify T1065.get_tunnel_ports()

This commit is contained in:
Kekoa Kaaikala 2022-09-22 13:38:45 +00:00
parent 38d9ccc9f0
commit 4226d9029f
1 changed files with 4 additions and 9 deletions

View File

@ -1,4 +1,4 @@
from typing import Sequence
from typing import Iterable
from common.network.network_utils import address_to_ip_port
from common.utils.attack_utils import ScanStatus
@ -17,16 +17,11 @@ class T1065(AttackTechnique):
@staticmethod
def get_report_data():
tunneling_ports = T1065.get_tunnel_ports()
non_standard_ports = [*tunneling_ports, str(ISLAND_PORT)]
non_standard_ports = [*T1065.get_tunnel_ports(), str(ISLAND_PORT)]
T1065.used_msg = T1065.message % ", ".join(non_standard_ports)
return T1065.get_base_data_by_status(ScanStatus.USED.value)
@staticmethod
def get_tunnel_ports() -> Sequence[str]:
def get_tunnel_ports() -> Iterable[str]:
telems = Telemetry.objects(telem_category="tunnel", data__proxy__ne=None)
return [
p
for p in (address_to_ip_port(telem["data"]["proxy"])[1] for telem in telems)
if p is not None
]
return filter(None, [address_to_ip_port(telem["data"]["proxy"])[1] for telem in telems])