forked from p34709852/monkey
Agent: fix a bug in web_rce url building
build_potential_urls was made static and takes IP as first parameter, but the users of this method wasn't changed and only passed ports
This commit is contained in:
parent
e3f9312ff9
commit
52ac7dd295
|
@ -27,7 +27,7 @@ from infection_monkey.utils.commands import build_monkey_commandline
|
||||||
class HadoopExploiter(WebRCE):
|
class HadoopExploiter(WebRCE):
|
||||||
_TARGET_OS_TYPE = ["linux", "windows"]
|
_TARGET_OS_TYPE = ["linux", "windows"]
|
||||||
_EXPLOITED_SERVICE = "Hadoop"
|
_EXPLOITED_SERVICE = "Hadoop"
|
||||||
HADOOP_PORTS = [["8088", False]]
|
HADOOP_PORTS = [("8088", False)]
|
||||||
# How long we have our http server open for downloads in seconds
|
# How long we have our http server open for downloads in seconds
|
||||||
DOWNLOAD_TIMEOUT = 60
|
DOWNLOAD_TIMEOUT = 60
|
||||||
# Random string's length that's used for creating unique app name
|
# Random string's length that's used for creating unique app name
|
||||||
|
@ -38,7 +38,7 @@ class HadoopExploiter(WebRCE):
|
||||||
|
|
||||||
def _exploit_host(self):
|
def _exploit_host(self):
|
||||||
# Try to get exploitable url
|
# Try to get exploitable url
|
||||||
urls = self.build_potential_urls(self.HADOOP_PORTS)
|
urls = self.build_potential_urls(self.host.ip_addr, self.HADOOP_PORTS)
|
||||||
self.add_vulnerable_urls(urls, True)
|
self.add_vulnerable_urls(urls, True)
|
||||||
if not self.vulnerable_urls:
|
if not self.vulnerable_urls:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -77,18 +77,14 @@ class LDAPExploitServer:
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
:param ldap_server_port: The port that the LDAP server will listen on.
|
:param ldap_server_port: The port that the LDAP server will listen on.
|
||||||
:type ldap_server_port: int
|
|
||||||
|
|
||||||
:param http_server_ip: The IP address of the HTTP server that serves the malicious Log4Shell
|
:param http_server_ip: The IP address of the HTTP server that serves the malicious Log4Shell
|
||||||
Java class.
|
Java class.
|
||||||
:type http_server_ip: str
|
|
||||||
|
|
||||||
:param http_server_port: The port the HTTP server is listening on.
|
:param http_server_port: The port the HTTP server is listening on.
|
||||||
:type ldap_server_port: int
|
|
||||||
|
|
||||||
:param storage_dir: A directory where the LDAP server can safely store files it needs during
|
:param storage_dir: A directory where the LDAP server can safely store files it needs during
|
||||||
runtime.
|
runtime.
|
||||||
:type storage_dir: Path
|
|
||||||
"""
|
"""
|
||||||
self._reactor_startup_completed = multiprocessing.Event()
|
self._reactor_startup_completed = multiprocessing.Event()
|
||||||
self._ldap_server_port = ldap_server_port
|
self._ldap_server_port = ldap_server_port
|
||||||
|
@ -173,7 +169,6 @@ class LDAPExploitServer:
|
||||||
argument is None (the default), the method blocks until the LDAP server
|
argument is None (the default), the method blocks until the LDAP server
|
||||||
terminates. If `timeout` is a positive floating point number, this method
|
terminates. If `timeout` is a positive floating point number, this method
|
||||||
blocks for at most `timeout` seconds.
|
blocks for at most `timeout` seconds.
|
||||||
:type timeout: float
|
|
||||||
"""
|
"""
|
||||||
if self._server_process.is_alive():
|
if self._server_process.is_alive():
|
||||||
logger.debug("Stopping LDAP exploit server")
|
logger.debug("Stopping LDAP exploit server")
|
||||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
||||||
import re
|
import re
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from posixpath import join
|
from posixpath import join
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
from common.utils.attack_utils import BITS_UPLOAD_STRING, ScanStatus
|
from common.utils.attack_utils import BITS_UPLOAD_STRING, ScanStatus
|
||||||
from infection_monkey.exploit.consts import WIN_ARCH_32, WIN_ARCH_64
|
from infection_monkey.exploit.consts import WIN_ARCH_32, WIN_ARCH_64
|
||||||
|
@ -100,7 +101,9 @@ class WebRCE(HostExploiter):
|
||||||
if not ports:
|
if not ports:
|
||||||
return False
|
return False
|
||||||
# Get urls to try to exploit
|
# Get urls to try to exploit
|
||||||
potential_urls = self.build_potential_urls(ports, exploit_config["url_extensions"])
|
potential_urls = self.build_potential_urls(
|
||||||
|
self.host.ip_addr, ports, exploit_config["url_extensions"]
|
||||||
|
)
|
||||||
self.add_vulnerable_urls(potential_urls, exploit_config["stop_checking_urls"])
|
self.add_vulnerable_urls(potential_urls, exploit_config["stop_checking_urls"])
|
||||||
|
|
||||||
if not self.are_vulnerable_urls_sufficient():
|
if not self.are_vulnerable_urls_sufficient():
|
||||||
|
@ -220,7 +223,7 @@ class WebRCE(HostExploiter):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_potential_urls(ip: str, ports, extensions=None):
|
def build_potential_urls(ip: str, ports: List[Tuple[str, bool]], extensions=None):
|
||||||
"""
|
"""
|
||||||
Build all possibly-vulnerable URLs on a specific host, based on the relevant ports and
|
Build all possibly-vulnerable URLs on a specific host, based on the relevant ports and
|
||||||
extensions.
|
extensions.
|
||||||
|
|
Loading…
Reference in New Issue