diff --git a/monkey/infection_monkey/exploit/HostExploiter.py b/monkey/infection_monkey/exploit/HostExploiter.py index f791e7a9c..17bbee2a3 100644 --- a/monkey/infection_monkey/exploit/HostExploiter.py +++ b/monkey/infection_monkey/exploit/HostExploiter.py @@ -94,14 +94,15 @@ class HostExploiter: ) self.set_start_time() - def is_interrupted(self): + def _is_interrupted(self): + return self.interrupt.is_set() + + def _set_interrupted(self): # This method should be refactored to raise an exception to reduce duplication in the # "if is_interrupted: return self.exploitation_results" # Ideally the user should only do "check_for_interrupt()" - if self.interrupt.is_set(): - logger.info("Exploiter has been interrupted") - self.exploit_result.interrupted = True - return self.interrupt.is_set() + logger.info("Exploiter has been interrupted") + self.exploit_result.interrupted = True def post_exploit(self): self.set_finish_time() diff --git a/monkey/infection_monkey/exploit/mssqlexec.py b/monkey/infection_monkey/exploit/mssqlexec.py index 9a9bfef7a..eae4f33dd 100644 --- a/monkey/infection_monkey/exploit/mssqlexec.py +++ b/monkey/infection_monkey/exploit/mssqlexec.py @@ -73,7 +73,8 @@ class MSSQLExploiter(HostExploiter): ) return self.exploit_result - if self.is_interrupted(): + if self._is_interrupted(): + self._set_interrupted() return self.exploit_result try: diff --git a/monkey/infection_monkey/exploit/powershell.py b/monkey/infection_monkey/exploit/powershell.py index b097630d7..868c31c97 100644 --- a/monkey/infection_monkey/exploit/powershell.py +++ b/monkey/infection_monkey/exploit/powershell.py @@ -70,7 +70,8 @@ class PowerShellExploiter(HostExploiter): self._client = self._authenticate_via_brute_force(credentials, auth_options) - if self.is_interrupted(): + if self._is_interrupted(): + self._set_interrupted() return self.exploit_result if not self._client: diff --git a/monkey/infection_monkey/exploit/wmiexec.py b/monkey/infection_monkey/exploit/wmiexec.py index 7b7c9ad1e..9bfcb3d14 100644 --- a/monkey/infection_monkey/exploit/wmiexec.py +++ b/monkey/infection_monkey/exploit/wmiexec.py @@ -70,7 +70,8 @@ class WmiExploiter(HostExploiter): downloaded_agent = self.agent_repository.get_agent_binary(self.host.os["type"]) - if self.is_interrupted(): + if self._is_interrupted(): + self._set_interrupted() return self.exploit_result remote_full_path = SmbTools.copy_file(