From 4ecc5283e5ec2ee388449a3b79153e5494337bbf Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 23 Feb 2022 17:11:53 +0530 Subject: [PATCH] Agent: Rename function for returning ExploiterResultData --- monkey/infection_monkey/exploit/HostExploiter.py | 2 +- monkey/infection_monkey/exploit/sshexec.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/monkey/infection_monkey/exploit/HostExploiter.py b/monkey/infection_monkey/exploit/HostExploiter.py index 9c8ddd4d4..46e43c87a 100644 --- a/monkey/infection_monkey/exploit/HostExploiter.py +++ b/monkey/infection_monkey/exploit/HostExploiter.py @@ -127,7 +127,7 @@ class HostExploiter: powershell = True if "powershell" in cmd.lower() else False self.exploit_info["executed_cmds"].append({"cmd": cmd, "powershell": powershell}) - def get_exploit_result_data(self) -> ExploiterResultData: + def return_exploit_result_data(self) -> ExploiterResultData: return ExploiterResultData( self.exploit_result["exploitation_success"], self.exploit_result["propagation_success"], diff --git a/monkey/infection_monkey/exploit/sshexec.py b/monkey/infection_monkey/exploit/sshexec.py index 5b014af7e..95be5af80 100644 --- a/monkey/infection_monkey/exploit/sshexec.py +++ b/monkey/infection_monkey/exploit/sshexec.py @@ -114,7 +114,7 @@ class SSHExploiter(HostExploiter): self.exploit_result["error_message"] = f"SSH port is closed on {self.host}, skipping" logger.info(self.exploit_result["error_message"]) - return self.get_exploit_result_data() + return self.return_exploit_result_data() try: ssh = self.exploit_with_ssh_keys(port) @@ -129,7 +129,7 @@ class SSHExploiter(HostExploiter): self.exploit_result["propagation_success"] = False logger.debug(self.exploit_result["error_message"]) - return self.get_exploit_result_data() + return self.return_exploit_result_data() if not self.host.os.get("type"): try: @@ -143,7 +143,7 @@ class SSHExploiter(HostExploiter): if not uname_os: logger.error(self.exploit_result["error_message"]) - return self.get_exploit_result_data() + return self.return_exploit_result_data() except Exception as exc: self.exploit_result["propagation_success"] = False self.exploit_result[ @@ -151,7 +151,7 @@ class SSHExploiter(HostExploiter): ] = f"Error running uname os command on victim {self.host}: ({exc})" logger.debug(self.exploit_result["error_message"]) - return self.get_exploit_result_data() + return self.return_exploit_result_data() if not self.host.os.get("machine"): try: @@ -174,7 +174,7 @@ class SSHExploiter(HostExploiter): ] = f"Can't find suitable monkey executable for host {self.host}" logger.info(self.exploit_result["error_message"]) - return self.get_exploit_result_data() + return self.return_exploit_result_data() try: ftp = ssh.open_sftp() @@ -211,7 +211,7 @@ class SSHExploiter(HostExploiter): ) ) if status == ScanStatus.SCANNED: - return self.get_exploit_result_data() + return self.return_exploit_result_data() try: cmdline = "%s %s" % (self.options["dropper_target_path_linux"], MONKEY_ARG) @@ -230,7 +230,7 @@ class SSHExploiter(HostExploiter): ssh.close() self.add_executed_cmd(cmdline) - return self.get_exploit_result_data() + return self.return_exploit_result_data() except Exception as exc: self.exploit_result["propagation_success"] = False @@ -239,4 +239,4 @@ class SSHExploiter(HostExploiter): ] = f"Error running monkey on victim {self.host}: ({exc})" logger.error(self.exploit_result["error_message"]) - return self.get_exploit_result_data() + return self.return_exploit_result_data()