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
This commit is contained in:
vakaris_zilius 2022-03-24 10:31:41 +00:00
parent cbf9544e58
commit dc2a63475b
1 changed files with 3 additions and 3 deletions

View File

@ -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)