From 6fa1d20e6aa680f1e0969adf3f685f6370e7d087 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 12 Jan 2022 19:27:51 -0500 Subject: [PATCH] Agent: Add _initialize_http_handler() to ExploitClassHTTPServer --- .../log4shell_utils/exploit_class_http_server.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/exploit/log4shell_utils/exploit_class_http_server.py b/monkey/infection_monkey/exploit/log4shell_utils/exploit_class_http_server.py index ba72412b4..cabfb74ff 100644 --- a/monkey/infection_monkey/exploit/log4shell_utils/exploit_class_http_server.py +++ b/monkey/infection_monkey/exploit/log4shell_utils/exploit_class_http_server.py @@ -31,13 +31,17 @@ class HTTPHandler(http.server.BaseHTTPRequestHandler): class ExploitClassHTTPServer: def __init__(self, ip: str, port: int, java_class: bytes, poll_interval: float = 0.5): logger.debug(f"The Java Exploit class will be served at {ip}:{port}") - self._class_downloaded = threading.Event() - HTTPHandler.java_class = java_class - HTTPHandler.class_downloaded = self._class_downloaded + self._class_downloaded = threading.Event() + self._poll_interval = poll_interval + + self._initialize_http_handler(java_class) self._server = http.server.HTTPServer((ip, port), HTTPHandler) - self._poll_interval = poll_interval + + def _initialize_http_handler(self, java_class: bytes): + HTTPHandler.java_class = java_class + HTTPHandler.class_downloaded = self._class_downloaded def run(self): logger.debug("Starting ExploitClassHTTPServer")