diff --git a/monkey/infection_monkey/master/mock_master.py b/monkey/infection_monkey/master/mock_master.py index a7b62b1fd..e7e8e6237 100644 --- a/monkey/infection_monkey/master/mock_master.py +++ b/monkey/infection_monkey/master/mock_master.py @@ -101,44 +101,16 @@ class MockMaster(IMaster): def _exploit(self): logger.info("Exploiting victims") - ( - exploitation_result, - propagation_result, - os, - info, - attempts, - error_message, - ) = self._puppet.exploit_host("PowerShellExploiter", "10.0.0.1", {}, None) - logger.info(f"Attempts for exploiting {attempts}") + result = self._puppet.exploit_host("PowerShellExploiter", "10.0.0.1", {}, None) + logger.info(f"Attempts for exploiting {result.attempts}") self._telemetry_messenger.send_telemetry( - ExploitTelem( - "PowerShellExploiter", - self._hosts["10.0.0.1"], - exploitation_result, - propagation_result, - info, - attempts, - ) + ExploitTelem("PowerShellExploiter", self._hosts["10.0.0.1"], result) ) - ( - exploitation_result, - propagation_result, - os, - info, - attempts, - error_message, - ) = self._puppet.exploit_host("SSHExploiter", "10.0.0.3", {}, None) - logger.info(f"Attempts for exploiting {attempts}") + result = self._puppet.exploit_host("SSHExploiter", "10.0.0.3", {}, None) + logger.info(f"Attempts for exploiting {result.attempts}") self._telemetry_messenger.send_telemetry( - ExploitTelem( - "SSHExploiter", - self._hosts["10.0.0.3"], - exploitation_result, - propagation_result, - info, - attempts, - ) + ExploitTelem("SSHExploiter", self._hosts["10.0.0.3"], result) ) logger.info("Finished exploiting victims") diff --git a/monkey/infection_monkey/master/propagator.py b/monkey/infection_monkey/master/propagator.py index e093c259c..a8437cc94 100644 --- a/monkey/infection_monkey/master/propagator.py +++ b/monkey/infection_monkey/master/propagator.py @@ -165,13 +165,4 @@ class Propagator: f"{result.error_message}" ) - self._telemetry_messenger.send_telemetry( - ExploitTelem( - exploiter_name, - host, - result.exploitation_success, - result.propagation_success, - result.info, - result.attempts, - ) - ) + self._telemetry_messenger.send_telemetry(ExploitTelem(exploiter_name, host, result)) diff --git a/monkey/infection_monkey/telemetry/exploit_telem.py b/monkey/infection_monkey/telemetry/exploit_telem.py index 312a34592..c85dde798 100644 --- a/monkey/infection_monkey/telemetry/exploit_telem.py +++ b/monkey/infection_monkey/telemetry/exploit_telem.py @@ -1,8 +1,9 @@ -from typing import Dict, List +from typing import Dict from common.common_consts.telem_categories import TelemCategoryEnum from infection_monkey.model.host import VictimHost from infection_monkey.telemetry.base_telem import BaseTelem +from monkey.infection_monkey.i_puppet.i_puppet import ExploiterResultData class ExploitTelem(BaseTelem): @@ -10,30 +11,22 @@ class ExploitTelem(BaseTelem): self, name: str, host: VictimHost, - exploitation_result: bool, - propagation_result: bool, - info: Dict, - attempts: List, + result: ExploiterResultData, ): """ Default exploit telemetry constructor :param name: The name of exploiter used :param host: The host machine - :param exploitation_result: The result of the exploitation attempt from the 'exploit_host' - method - :param propagation_result: The result of the propagation attempt from the 'exploit_host' - method - :param info: Information about the exploiter - :param attempts: Information about the exploiter's attempts + :param result: Data about the exploitation attempt (success status, info, attempts, etc) """ super(ExploitTelem, self).__init__() self.name = name self.host = host.__dict__ - self.exploitation_result = exploitation_result - self.propagation_result = propagation_result - self.info = info - self.attempts = attempts + self.exploitation_result = result.exploitation_success + self.propagation_result = result.propagation_success + self.info = result.info + self.attempts = result.attempts telem_category = TelemCategoryEnum.EXPLOIT