From 13e5c03cf92d05362758be79cb034d0cc3452cd0 Mon Sep 17 00:00:00 2001
From: vakarisz <vakarisz@yahoo.com>
Date: Fri, 18 Mar 2022 14:14:22 +0200
Subject: [PATCH] Agent: Add interrupt check before/after agent upload in
 wmiexec.py

---
 monkey/infection_monkey/exploit/wmiexec.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/monkey/infection_monkey/exploit/wmiexec.py b/monkey/infection_monkey/exploit/wmiexec.py
index 69eab12dd..b50e0830d 100644
--- a/monkey/infection_monkey/exploit/wmiexec.py
+++ b/monkey/infection_monkey/exploit/wmiexec.py
@@ -70,6 +70,9 @@ class WmiExploiter(HostExploiter):
 
             downloaded_agent = self.agent_repository.get_agent_binary(self.host.os["type"])
 
+            if self.is_interrupted():
+                return self.exploit_result
+
             remote_full_path = SmbTools.copy_file(
                 self.host,
                 downloaded_agent,
@@ -81,6 +84,9 @@ class WmiExploiter(HostExploiter):
                 self.options["smb_download_timeout"],
             )
 
+            if self.is_interrupted():
+                return self.exploit_result
+
             if not remote_full_path:
                 wmi_connection.close()
                 return self.exploit_result