From dc2a63475b26428dff550181f58f9c25c2248e03 Mon Sep 17 00:00:00 2001 From: vakaris_zilius Date: Thu, 24 Mar 2022 10:31:41 +0000 Subject: [PATCH] Agent: Fix incorrect monkey destination path bug This bug happened because Path will always cast path to current OS path and if target OS is different the path won't work. By explicitly casting the path to target OS type we get a path for target OS --- monkey/infection_monkey/exploit/tools/helpers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index 87f5636eb..c287b0dbb 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 +from pathlib import Path, PurePosixPath, PureWindowsPath from typing import Any, Mapping from infection_monkey.model import VictimHost @@ -20,9 +20,9 @@ def get_random_file_suffix() -> str: def get_agent_dest_path(host: VictimHost, options: Mapping[str, Any]) -> Path: if host.os["type"] == "windows": - path = Path(options["dropper_target_path_win_64"]) + path = PureWindowsPath(options["dropper_target_path_win_64"]) else: - path = Path(options["dropper_target_path_linux"]) + path = PurePosixPath(options["dropper_target_path_linux"]) return _add_random_suffix(path)