From 8eace7c7360a039c757925ed7ea697f77fb52b62 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 18 Mar 2022 10:50:55 -0400 Subject: [PATCH] Agent: Return ExploitResultData from SMBExploiter --- monkey/infection_monkey/exploit/smbexec.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/monkey/infection_monkey/exploit/smbexec.py b/monkey/infection_monkey/exploit/smbexec.py index 4d5623a13..28671167d 100644 --- a/monkey/infection_monkey/exploit/smbexec.py +++ b/monkey/infection_monkey/exploit/smbexec.py @@ -32,7 +32,6 @@ class SMBExploiter(HostExploiter): dest_path = get_agent_dest_path(self.host, self.options) creds = generate_brute_force_combinations(self.options["credentials"]) - exploited = False for user, password, lm_hash, ntlm_hash in creds: try: # copy the file remotely using SMB @@ -59,7 +58,7 @@ class SMBExploiter(HostExploiter): SMBExploiter.KNOWN_PROTOCOLS["445/SMB"][1], ) ) - exploited = True + self.exploit_result.exploitation_success = True break else: # failed exploiting with this user/pass @@ -72,9 +71,9 @@ class SMBExploiter(HostExploiter): ) continue - if not exploited: + if not self.exploit_result.exploitation_success: logger.debug("Exploiter SmbExec is giving up...") - return False + return self.exploit_result # execute the remote dropper in case the path isn't final if remote_full_path.lower() != dest_path.lower(): @@ -117,7 +116,12 @@ class SMBExploiter(HostExploiter): break if not smb_conn: - return False + msg = "Failed to establish an RPC connection over SMB" + + logger.warning(msg) + self.exploit_result.error_message = msg + + return self.exploit_result # TODO: We DO want to deal with timeouts # We don't wanna deal with timeouts from now on. @@ -151,6 +155,7 @@ class SMBExploiter(HostExploiter): self.host, cmdline, ) + self.exploit_result.propagation_success = True self.add_vuln_port( "%s or %s" @@ -159,4 +164,4 @@ class SMBExploiter(HostExploiter): SMBExploiter.KNOWN_PROTOCOLS["445/SMB"][1], ) ) - return True + return self.exploit_result