From f917654f414bf5b35ce3724ee7cb03fecd60e3d9 Mon Sep 17 00:00:00 2001 From: Kekoa Kaaikala Date: Thu, 6 Oct 2022 16:27:57 +0000 Subject: [PATCH] Agent: Report successful propagation if agent ran --- monkey/infection_monkey/exploit/smbexec.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/exploit/smbexec.py b/monkey/infection_monkey/exploit/smbexec.py index e6fc6d85f..fdcd6ee00 100644 --- a/monkey/infection_monkey/exploit/smbexec.py +++ b/monkey/infection_monkey/exploit/smbexec.py @@ -93,7 +93,8 @@ class SMBExploiter(HostExploiter): return self.exploit_result - self._run_agent_on_victim(scmr_rpc, cmdline, timestamp) + if not self._run_agent_on_victim(scmr_rpc, cmdline, timestamp): + return self.exploit_result logger.info( "Executed monkey '%s' on remote victim %r (cmdline=%r)", @@ -220,7 +221,7 @@ class SMBExploiter(HostExploiter): return None - def _run_agent_on_victim(self, scmr_rpc: DCERPC_v5, cmdline: str, start_time: float): + def _run_agent_on_victim(self, scmr_rpc: DCERPC_v5, cmdline: str, start_time: float) -> bool: scmr_rpc.bind(scmr.MSRPC_UUID_SCMR) resp = scmr.hROpenSCManagerW(scmr_rpc) sc_handle = resp["lpScHandle"] @@ -240,7 +241,7 @@ class SMBExploiter(HostExploiter): else: self.exploit_result.error_message = str(err) self._publish_propagation_event(start_time, False, error_message=str(err)) - return + return False service = resp["lpServiceHandle"] try: @@ -255,3 +256,5 @@ class SMBExploiter(HostExploiter): self.telemetry_messenger.send_telemetry(T1035Telem(status, UsageEnum.SMB)) scmr.hRDeleteService(scmr_rpc, service) scmr.hRCloseServiceHandle(scmr_rpc, service) + + return True