Agent: Use agent repository in PowerShell exploiter

And create a temporary local file for the agent binary so that
pypsrp.Client can copy it to the victim
This commit is contained in:
Shreya Malviya 2022-03-11 22:04:53 +05:30 committed by Ilija Lazoroski
parent 399a344619
commit 7d2f9251e7
1 changed files with 6 additions and 1 deletions

View File

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