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
|
||||
|
||||
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}")
|
||||
is_monkey_copy_successful = self._client.copy_file(
|
||||
TEMP_MONKEY_BINARY_FILEPATH, monkey_path_on_victim
|
||||
)
|
||||
|
||||
os.remove(TEMP_MONKEY_BINARY_FILEPATH)
|
||||
logger.info(f"Attempting to copy the monkey agent binary to {self.host.ip_addr}")
|
||||
is_monkey_copy_successful = self._client.copy_file(
|
||||
TEMP_MONKEY_BINARY_FILEPATH, monkey_path_on_victim
|
||||
)
|
||||
except Exception as ex:
|
||||
raise ex
|
||||
finally:
|
||||
if os.path.isfile(TEMP_MONKEY_BINARY_FILEPATH):
|
||||
os.remove(TEMP_MONKEY_BINARY_FILEPATH)
|
||||
|
||||
return is_monkey_copy_successful
|
||||
|
||||
|
|
Loading…
Reference in New Issue