Agent: Extract method _set_interrupted() from is_interrupted()

This commit is contained in:
Mike Salvatore 2022-03-21 09:09:15 -04:00
parent b0f03179c1
commit 7a1fcced2f
4 changed files with 12 additions and 8 deletions

View File

@ -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()

View File

@ -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:

View File

@ -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:

View File

@ -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(