From b79bf9635967c2b473becb6506d2ccd4e37403ef Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 11 Jan 2022 12:53:20 -0500 Subject: [PATCH] Agent: Don't install signal handlers in LDAPExploitServer This avoids exceptions that are raised when the LDAPExploitServer is not started on the main thread. --- .../infection_monkey/exploit/log4shell_utils/ldap_server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/exploit/log4shell_utils/ldap_server.py b/monkey/infection_monkey/exploit/log4shell_utils/ldap_server.py index f575f20cc..e6efac5ff 100644 --- a/monkey/infection_monkey/exploit/log4shell_utils/ldap_server.py +++ b/monkey/infection_monkey/exploit/log4shell_utils/ldap_server.py @@ -84,7 +84,9 @@ class LDAPExploitServer: log_observer.start() def run(self): - reactor.run() + # For an explaination of installSignalHandlers=0, see + # https://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Igetexceptions.ValueError:signalonlyworksinmainthreadwhenItrytorunmyTwistedprogramWhatswrong + reactor.run(installSignalHandlers=0) def stop(self): reactor.stop()