diff --git a/monkey/infection_monkey/master/exploiter.py b/monkey/infection_monkey/master/exploiter.py index 0c743674c..501e46e9a 100644 --- a/monkey/infection_monkey/master/exploiter.py +++ b/monkey/infection_monkey/master/exploiter.py @@ -53,6 +53,7 @@ class Exploiter: exploitation_config: ExploitationConfiguration, hosts_to_exploit: Queue, current_depth: int, + servers: Sequence[str], results_callback: Callback, scan_completed: Event, stop: Event, @@ -67,6 +68,7 @@ class Exploiter: exploiters_to_run, hosts_to_exploit, current_depth, + servers, results_callback, scan_completed, stop, @@ -103,6 +105,7 @@ class Exploiter: exploiters_to_run: Sequence[PluginConfiguration], hosts_to_exploit: Queue, current_depth: int, + servers: Sequence[str], results_callback: Callback, scan_completed: Event, stop: Event, @@ -113,7 +116,7 @@ class Exploiter: try: victim_host = hosts_to_exploit.get(timeout=QUEUE_TIMEOUT) self._run_all_exploiters( - exploiters_to_run, victim_host, current_depth, results_callback, stop + exploiters_to_run, victim_host, current_depth, servers, results_callback, stop ) except queue.Empty: if _all_hosts_have_been_processed(scan_completed, hosts_to_exploit): @@ -130,6 +133,7 @@ class Exploiter: exploiters_to_run: Sequence[PluginConfiguration], victim_host: VictimHost, current_depth: int, + servers: Sequence[str], results_callback: Callback, stop: Event, ): @@ -147,7 +151,7 @@ class Exploiter: continue exploiter_results = self._run_exploiter( - exploiter_name, exploiter.options, victim_host, current_depth, stop + exploiter_name, exploiter.options, victim_host, current_depth, servers, stop ) results_callback(exploiter_name, victim_host, exploiter_results) @@ -160,6 +164,7 @@ class Exploiter: options: Dict, victim_host: VictimHost, current_depth: int, + servers: Sequence[str], stop: Event, ) -> ExploiterResultData: logger.debug(f"Attempting to use {exploiter_name} on {victim_host.ip_addr}") @@ -169,7 +174,7 @@ class Exploiter: try: return self._puppet.exploit_host( - exploiter_name, victim_host, current_depth, options, stop + exploiter_name, victim_host, current_depth, servers, options, stop ) except Exception as ex: msg = ( diff --git a/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py b/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py index 45288fbb7..d8e5ef6b1 100644 --- a/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py +++ b/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py @@ -85,6 +85,7 @@ def get_host_exploit_combos_from_call_args_list(call_args_list): CREDENTIALS_FOR_PROPAGATION = {"usernames": ["m0nk3y", "user"], "passwords": ["1234", "pword"]} +SERVERS = ["127.0.0.1:5000", "10.10.10.10:5007"] def get_credentials_for_propagation(): @@ -98,7 +99,7 @@ def run_exploiters(exploiter_config, hosts_to_exploit, callback, scan_completed, scan_completed.set() e = Exploiter(puppet, num_workers, get_credentials_for_propagation) - e.exploit_hosts(exploiter_config, hosts, 1, callback, scan_completed, stop) + e.exploit_hosts(exploiter_config, hosts, 1, SERVERS, callback, scan_completed, stop) return inner @@ -143,7 +144,9 @@ def test_stop_after_callback(exploiter_config, callback, scan_completed, stop, h # Intentionally NOT setting scan_completed.set(); _callback() will set stop e = Exploiter(MockPuppet(), callback_barrier_count + 2, get_credentials_for_propagation) - e.exploit_hosts(exploiter_config, hosts_to_exploit, 1, stoppable_callback, scan_completed, stop) + e.exploit_hosts( + exploiter_config, hosts_to_exploit, 1, SERVERS, stoppable_callback, scan_completed, stop + ) assert stoppable_callback.call_count == 2