forked from p15670423/monkey
Agent: Ensure temp file is removed by PowerShellExploiter
This commit is contained in:
parent
8144a3334e
commit
936074605f
|
@ -144,14 +144,18 @@ class PowerShellExploiter(HostExploiter):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _copy_monkey_binary_to_victim(self, monkey_path_on_victim) -> bool:
|
def _copy_monkey_binary_to_victim(self, monkey_path_on_victim) -> bool:
|
||||||
self._write_virtual_file_to_local_path()
|
try:
|
||||||
|
self._write_virtual_file_to_local_path()
|
||||||
|
|
||||||
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}")
|
||||||
is_monkey_copy_successful = self._client.copy_file(
|
is_monkey_copy_successful = self._client.copy_file(
|
||||||
TEMP_MONKEY_BINARY_FILEPATH, monkey_path_on_victim
|
TEMP_MONKEY_BINARY_FILEPATH, monkey_path_on_victim
|
||||||
)
|
)
|
||||||
|
except Exception as ex:
|
||||||
os.remove(TEMP_MONKEY_BINARY_FILEPATH)
|
raise ex
|
||||||
|
finally:
|
||||||
|
if os.path.isfile(TEMP_MONKEY_BINARY_FILEPATH):
|
||||||
|
os.remove(TEMP_MONKEY_BINARY_FILEPATH)
|
||||||
|
|
||||||
return is_monkey_copy_successful
|
return is_monkey_copy_successful
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue