From d8fca72f28044752773b17d8e9c1ba9d93d378a4 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 6 Oct 2022 16:41:20 -0400 Subject: [PATCH] Agent: Publish all prop/exploit events from _wait_for_victim() --- monkey/infection_monkey/exploit/log4shell.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/exploit/log4shell.py b/monkey/infection_monkey/exploit/log4shell.py index 780665047..4bb2c2777 100644 --- a/monkey/infection_monkey/exploit/log4shell.py +++ b/monkey/infection_monkey/exploit/log4shell.py @@ -181,7 +181,9 @@ class Log4ShellExploiter(WebRCE): victim_called_back = self._wait_for_victim_to_download_java_bytecode() if victim_called_back: self._publish_exploitation_event(timestamp, True) - self._wait_for_victim_to_download_agent() + + victim_downloaded_agent = self._wait_for_victim_to_download_agent() + self._publish_propagation_event(success=victim_downloaded_agent) else: error_message = "Timed out while waiting for victim to download the java bytecode" logger.debug(error_message) @@ -202,15 +204,16 @@ class Log4ShellExploiter(WebRCE): return False - def _wait_for_victim_to_download_agent(self): + def _wait_for_victim_to_download_agent(self) -> bool: timer = Timer() timer.set(LONG_REQUEST_TIMEOUT) while not timer.is_expired(): if self._agent_http_server_thread.downloads > 0: - self._publish_propagation_event(success=True) self.exploit_result.propagation_success = True - break + return True # TODO: if the http server got an error we're waiting for nothing here time.sleep(1) + + return False