8000 Log4Shell: Import twisted reactor at top level by ilija-lazoroski · Pull Request #3457 · guardicore/monkey · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Log4Shell: Import twisted reactor at top level #3457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions monkey/agent_plugins/exploiters/log4shell/src/ldap_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Optional

from ldaptor.protocols.ldap.ldapserver import LDAPServer
from twisted.internet import reactor
from twisted.internet.protocol import ServerFactory

from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
Expand Down Expand Up @@ -134,7 +135,6 @@ def run(self):

def _run_twisted_reactor(self):
# TODO: Try importing reactor at top level when Log4Shell is plugin
from twisted.internet import reactor

logger.debug(f"Starting log4shell LDAP server on port {self._ldap_server_port}")
self._configure_twisted_reactor()
Expand All @@ -149,8 +149,6 @@ def _run_twisted_reactor(self):
logger.debug("Exiting twisted process")

def _check_if_reactor_startup_completed(self):
from twisted.internet import reactor

check_interval_sec = 0.25
num_checks = math.ceil(REACTOR_START_TIMEOUT_SEC / check_interval_sec)

Expand All @@ -166,7 +164,6 @@ def _check_if_reactor_startup_completed(self):
def _configure_twisted_reactor(self):
from ldaptor.interfaces import IConnectedLDAPEntry
from twisted.application import service
from twisted.internet import reactor
from twisted.python.components import registerAdapter

LDAPExploitServer._output_twisted_logs_to_python_logger()
Expand Down Expand Up @@ -200,8 +197,6 @@ def stop(self, timeout: Optional[float] = None):
terminates. If `timeout` is a positive floating point number, this method
blocks for at most `timeout` seconds.
"""
from twisted.internet import reactor

if self._server_thread is None:
return

Expand Down
0