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:
vakarisz 2022-01-18 12:09:30 +02:00
parent e3f9312ff9
commit 52ac7dd295
3 changed files with 7 additions and 9 deletions

View File

@ -27,7 +27,7 @@ from infection_monkey.utils.commands import build_monkey_commandline
class HadoopExploiter(WebRCE):
_TARGET_OS_TYPE = ["linux", "windows"]
_EXPLOITED_SERVICE = "Hadoop"
HADOOP_PORTS = [["8088", False]]
HADOOP_PORTS = [("8088", False)]
# How long we have our http server open for downloads in seconds
DOWNLOAD_TIMEOUT = 60
# Random string's length that's used for creating unique app name
@ -38,7 +38,7 @@ class HadoopExploiter(WebRCE):
def _exploit_host(self):
# 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)
if not self.vulnerable_urls:
return False

View File

@ -77,18 +77,14 @@ class LDAPExploitServer:
):
"""
: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
Java class.
:type http_server_ip: str
: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
runtime.
:type storage_dir: Path
"""
self._reactor_startup_completed = multiprocessing.Event()
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
terminates. If `timeout` is a positive floating point number, this method
blocks for at most `timeout` seconds.
:type timeout: float
"""
if self._server_process.is_alive():
logger.debug("Stopping LDAP exploit server")

View File

@ -2,6 +2,7 @@ import logging
import re
from abc import abstractmethod
from posixpath import join
from typing import List, Tuple
from common.utils.attack_utils import BITS_UPLOAD_STRING, ScanStatus
from infection_monkey.exploit.consts import WIN_ARCH_32, WIN_ARCH_64
@ -100,7 +101,9 @@ class WebRCE(HostExploiter):
if not ports:
return False
# 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"])
if not self.are_vulnerable_urls_sufficient():
@ -220,7 +223,7 @@ class WebRCE(HostExploiter):
return False
@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
extensions.