diff --git a/monkey/infection_monkey/exploit/powershell.py b/monkey/infection_monkey/exploit/powershell.py index 4e48df891..c4e2885e3 100644 --- a/monkey/infection_monkey/exploit/powershell.py +++ b/monkey/infection_monkey/exploit/powershell.py @@ -161,7 +161,7 @@ class PowerShellExploiter(HostExploiter): def _copy_monkey_binary_to_victim(self, monkey_path_on_victim) -> bool: try: - self._write_virtual_file_to_local_path() + self._create_local_agent_file() logger.info(f"Attempting to copy the monkey agent binary to {self.host.ip_addr}") is_monkey_copy_successful = self._client.copy_file( @@ -175,6 +175,11 @@ class PowerShellExploiter(HostExploiter): return is_monkey_copy_successful + def _create_local_agent_file(self): + agent_binary_bytes = self.agent_repository.get_agent_binary("windows") + with open(TEMP_MONKEY_BINARY_FILEPATH, "wb") as f: + f.write(agent_binary_bytes.getvalue()) + def _write_virtual_file_to_local_path(self) -> None: """ # TODO: monkeyfs has been removed. Fix this in issue #1740.