From 4226d9029fce527aa86a7470129c753c7d109896 Mon Sep 17 00:00:00 2001 From: Kekoa Kaaikala Date: Thu, 22 Sep 2022 13:38:45 +0000 Subject: [PATCH] Island: Simplify T1065.get_tunnel_ports() --- .../cc/services/attack/technique_reports/T1065.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/monkey/monkey_island/cc/services/attack/technique_reports/T1065.py b/monkey/monkey_island/cc/services/attack/technique_reports/T1065.py index 9c273cca0..b6bfd0acb 100644 --- a/monkey/monkey_island/cc/services/attack/technique_reports/T1065.py +++ b/monkey/monkey_island/cc/services/attack/technique_reports/T1065.py @@ -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])