diff --git a/monkey/infection_monkey/master/automated_master.py b/monkey/infection_monkey/master/automated_master.py index f70d90b46..d05f9f5cf 100644 --- a/monkey/infection_monkey/master/automated_master.py +++ b/monkey/infection_monkey/master/automated_master.py @@ -3,6 +3,7 @@ import threading import time from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple +from infection_monkey.credential_store import ICredentialsStore from infection_monkey.i_control_channel import IControlChannel, IslandCommunicationError from infection_monkey.i_master import IMaster from infection_monkey.i_puppet import IPuppet @@ -36,6 +37,7 @@ class AutomatedMaster(IMaster): victim_host_factory: VictimHostFactory, control_channel: IControlChannel, local_network_interfaces: List[NetworkInterface], + credentials_store: ICredentialsStore, ): self._current_depth = current_depth self._puppet = puppet @@ -43,9 +45,8 @@ class AutomatedMaster(IMaster): self._control_channel = control_channel ip_scanner = IPScanner(self._puppet, NUM_SCAN_THREADS) - exploiter = Exploiter( - self._puppet, NUM_EXPLOIT_THREADS, self._control_channel.get_credentials_for_propagation - ) + + exploiter = Exploiter(self._puppet, NUM_EXPLOIT_THREADS, credentials_store.get_credentials) self._propagator = Propagator( self._telemetry_messenger, ip_scanner, diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 9576f76c0..6f12c4b89 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -15,6 +15,7 @@ from infection_monkey.credential_collectors import ( MimikatzCredentialCollector, SSHCredentialCollector, ) +from infection_monkey.credential_store import AggregatingCredentialsStore from infection_monkey.exploit import CachingAgentRepository, ExploiterWrapper from infection_monkey.exploit.hadoop import HadoopExploiter from infection_monkey.exploit.log4shell import Log4ShellExploiter @@ -54,6 +55,9 @@ from infection_monkey.puppet.puppet import Puppet from infection_monkey.system_singleton import SystemSingleton from infection_monkey.telemetry.attack.t1106_telem import T1106Telem from infection_monkey.telemetry.attack.t1107_telem import T1107Telem +from infection_monkey.telemetry.messengers.credentials_intercepting_telemetry_messenger import ( + CredentialsInterceptingTelemetryMessenger, +) from infection_monkey.telemetry.messengers.exploit_intercepting_telemetry_messenger import ( ExploitInterceptingTelemetryMessenger, ) @@ -183,14 +187,25 @@ class InfectionMonkey: telemetry_messenger = ExploitInterceptingTelemetryMessenger( self.telemetry_messenger, self._monkey_inbound_tunnel ) + control_channel = ControlChannel(self._default_server, GUID) + + credentials_store = AggregatingCredentialsStore(control_channel) + + telemetry_messenger = CredentialsInterceptingTelemetryMessenger( + ExploitInterceptingTelemetryMessenger( + self.telemetry_messenger, self._monkey_inbound_tunnel + ), + credentials_store, + ) self._master = AutomatedMaster( self._current_depth, puppet, telemetry_messenger, victim_host_factory, - ControlChannel(self._default_server, GUID), + control_channel, local_network_interfaces, + credentials_store, ) @staticmethod