forked from p15670423/monkey
Agent: Change powershell client to work with Path not str
This commit is contained in:
parent
7c504d220d
commit
7001977a88
|
@ -191,7 +191,7 @@ class PowerShellExploiter(HostExploiter):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.info(f"Attempting to copy the monkey agent binary to {self.host.ip_addr}")
|
logger.info(f"Attempting to copy the monkey agent binary to {self.host.ip_addr}")
|
||||||
self._client.copy_file(temp_monkey_binary_filepath, str(monkey_path_on_victim))
|
self._client.copy_file(temp_monkey_binary_filepath, monkey_path_on_victim)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise RemoteAgentCopyError(f"Failed to copy the agent binary to the victim: {ex}")
|
raise RemoteAgentCopyError(f"Failed to copy the agent binary to the victim: {ex}")
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import abc
|
import abc
|
||||||
import logging
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import pypsrp
|
import pypsrp
|
||||||
|
@ -63,7 +64,7 @@ class IPowerShellClient(Protocol, metaclass=abc.ABCMeta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def copy_file(self, src: str, dest: str) -> bool:
|
def copy_file(self, src: str, dest: Path) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -101,7 +102,8 @@ class PowerShellClient(IPowerShellClient):
|
||||||
output, _, _ = self._client.execute_cmd(cmd)
|
output, _, _ = self._client.execute_cmd(cmd)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def copy_file(self, src: str, dest: str):
|
def copy_file(self, src: str, dest: Path):
|
||||||
|
dest = str(dest)
|
||||||
try:
|
try:
|
||||||
self._client.copy(src, dest)
|
self._client.copy(src, dest)
|
||||||
logger.debug(f"Successfully copied {src} to {dest} on {self._ip_addr}")
|
logger.debug(f"Successfully copied {src} to {dest} on {self._ip_addr}")
|
||||||
|
|
Loading…
Reference in New Issue