Agent: Remove dependency on threading from LDAPExploitServer

This commit is contained in:
Mike Salvatore 2022-01-10 08:50:09 -05:00
parent 67ade141a0
commit 30c41592fb
2 changed files with 8 additions and 5 deletions

View File

@ -95,8 +95,12 @@ class Log4ShellExploiter(WebRCE):
http_server_port=self.class_http_server_port,
storage_dir=get_monkey_dir_path(),
)
ldap_thread = self.ldap_server.get_run_thread()
self.ldap_server_thread = ldap_thread
# 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.ldap_server_thread = Thread(target=self.ldap_server.run, daemon=True)
self.ldap_server_thread.start()
def stop_servers(self):

View File

@ -1,6 +1,5 @@
import tempfile
from pathlib import Path
from threading import Thread
from ldaptor.interfaces import IConnectedLDAPEntry
from ldaptor.ldiftree import LDIFTreeEntry
@ -84,8 +83,8 @@ class LDAPExploitServer:
log_observer = log.PythonLoggingObserver()
log_observer.start()
def get_run_thread(self) -> Thread:
return Thread(target=reactor.run, args=[None])
def run(self):
reactor.run()
def stop(self):
reactor.stop()