From 093e2c79dc3030baeec33aabd37f6c6ee2f90b6c Mon Sep 17 00:00:00 2001 From: Kekoa Kaaikala Date: Thu, 8 Sep 2022 20:42:19 +0000 Subject: [PATCH] Agent: Add relay to servers list for exploited hosts --- monkey/infection_monkey/monkey.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 9015d5c7f..5deb5e966 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -40,7 +40,7 @@ from infection_monkey.master import AutomatedMaster from infection_monkey.master.control_channel import ControlChannel from infection_monkey.model import VictimHostFactory from infection_monkey.network.firewall import app as firewall -from infection_monkey.network.info import get_free_tcp_port, get_network_interfaces +from infection_monkey.network.info import get_free_tcp_port, get_network_interfaces, local_ips from infection_monkey.network.relay import TCPRelay from infection_monkey.network.relay.utils import ( find_server, @@ -189,17 +189,18 @@ class InfectionMonkey: self._cmd_island_port, client_disconnect_timeout=config.keep_tunnel_open_time, ) + relay_servers = [f"{ip}:{relay_port}" for ip in local_ips()] if not maximum_depth_reached(config.propagation.maximum_depth, self._current_depth): self._relay.start() StateTelem(is_done=False, version=get_version()).send() - self._build_master() + self._build_master(relay_servers) register_signal_handlers(self._master) - def _build_master(self): + def _build_master(self, relay_servers: List[str]): local_network_interfaces = InfectionMonkey._get_local_network_interfaces() # TODO control_channel and control_client have same responsibilities, merge them @@ -221,7 +222,7 @@ class InfectionMonkey: self._master = AutomatedMaster( self._current_depth, - self._opts.servers, + self._opts.servers + relay_servers, puppet, telemetry_messenger, victim_host_factory,