From 943cb2fa7a0d441f1a301fad0be135304e4b9ade Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Tue, 5 Apr 2022 12:06:52 +0200 Subject: [PATCH] Agent: Use `create_daemon_thread` in ExploitClassHTTPServer --- .../log4shell_utils/exploit_class_http_server.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 8667963b5..ff3a829f2 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 @@ -3,6 +3,8 @@ import logging import threading from typing import Type +from infection_monkey.utils.threading import create_daemon_thread + logger = logging.getLogger(__name__) HTTP_TOO_MANY_REQUESTS_ERROR_CODE = 429 @@ -32,12 +34,10 @@ class ExploitClassHTTPServer: HTTPHandler = _get_new_http_handler_class(java_class, self._class_downloaded) self._server = http.server.HTTPServer((ip, port), HTTPHandler) - # Setting `daemon=True` to save ourselves some trouble when this is merged to the - # agent-refactor branch. - # TODO: Make a call to `create_daemon_thread()` instead of calling the `Thread()` - # constructor directly after merging to the agent-refactor branch. - self._server_thread = threading.Thread( - target=self._server.serve_forever, args=(self._poll_interval,), daemon=True + self._server_thread = create_daemon_thread( + target=self._server.serve_forever, + name="ExploitClassHTTPServerThread", + args=(self._poll_interval,), ) def run(self):