forked from p15670423/monkey
Agent: Change return type of IPuppet.run_payload() to None
At the moment, we don't expect payloads to return any values. This may be reevaluated as development proceeds or when telemetry is refactored.
This commit is contained in:
parent
3adb1d5b07
commit
c18af3c3fb
|
@ -2,7 +2,7 @@ import abc
|
||||||
import threading
|
import threading
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, Tuple
|
from typing import Dict
|
||||||
|
|
||||||
from infection_monkey.puppet.plugin_type import PluginType
|
from infection_monkey.puppet.plugin_type import PluginType
|
||||||
|
|
||||||
|
@ -107,13 +107,13 @@ class IPuppet(metaclass=abc.ABCMeta):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def run_payload(
|
def run_payload(self, name: str, options: Dict, interrupt: threading.Event):
|
||||||
self, name: str, options: Dict, interrupt: threading.Event
|
|
||||||
) -> Tuple[None, bool, str]:
|
|
||||||
"""
|
"""
|
||||||
Runs a payload
|
Runs a payload
|
||||||
:param str name: The name of the payload to run
|
:param str name: The name of the payload to run
|
||||||
:param Dict options: A dictionary containing options that modify the behavior of the payload
|
:param Dict options: A dictionary containing options that modify the behavior of the payload
|
||||||
|
:param threading.Event interrupt: A threading.Event object that signals the payload to stop
|
||||||
|
executing and clean itself up.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
|
|
@ -4,7 +4,6 @@ from infection_monkey.i_master import IMaster
|
||||||
from infection_monkey.i_puppet import IPuppet, PortStatus
|
from infection_monkey.i_puppet import IPuppet, PortStatus
|
||||||
from infection_monkey.model.host import VictimHost
|
from infection_monkey.model.host import VictimHost
|
||||||
from infection_monkey.telemetry.exploit_telem import ExploitTelem
|
from infection_monkey.telemetry.exploit_telem import ExploitTelem
|
||||||
from infection_monkey.telemetry.file_encryption_telem import FileEncryptionTelem
|
|
||||||
from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger
|
from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger
|
||||||
from infection_monkey.telemetry.post_breach_telem import PostBreachTelem
|
from infection_monkey.telemetry.post_breach_telem import PostBreachTelem
|
||||||
from infection_monkey.telemetry.scan_telem import ScanTelem
|
from infection_monkey.telemetry.scan_telem import ScanTelem
|
||||||
|
@ -119,9 +118,7 @@ class MockMaster(IMaster):
|
||||||
|
|
||||||
def _run_payload(self):
|
def _run_payload(self):
|
||||||
logger.info("Running payloads")
|
logger.info("Running payloads")
|
||||||
# TODO: modify what FileEncryptionTelem gets
|
self._puppet.run_payload("RansomwarePayload", {}, None)
|
||||||
path, success, error = self._puppet.run_payload("RansomwarePayload", {}, None)
|
|
||||||
self._telemetry_messenger.send_telemetry(FileEncryptionTelem(path, success, error))
|
|
||||||
logger.info("Finished running payloads")
|
logger.info("Finished running payloads")
|
||||||
|
|
||||||
def terminate(self, block: bool = False) -> None:
|
def terminate(self, block: bool = False) -> None:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Dict, Tuple
|
from typing import Dict
|
||||||
|
|
||||||
from infection_monkey.i_puppet import (
|
from infection_monkey.i_puppet import (
|
||||||
ExploiterResultData,
|
ExploiterResultData,
|
||||||
|
@ -299,11 +299,8 @@ class MockPuppet(IPuppet):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return ExploiterResultData(False, {}, [], f"{name} failed for host {host}")
|
return ExploiterResultData(False, {}, [], f"{name} failed for host {host}")
|
||||||
|
|
||||||
def run_payload(
|
def run_payload(self, name: str, options: Dict, interrupt: threading.Event):
|
||||||
self, name: str, options: Dict, interrupt: threading.Event
|
|
||||||
) -> Tuple[None, bool, str]:
|
|
||||||
logger.debug(f"run_payload({name}, {options})")
|
logger.debug(f"run_payload({name}, {options})")
|
||||||
return (None, True, "")
|
|
||||||
|
|
||||||
def cleanup(self) -> None:
|
def cleanup(self) -> None:
|
||||||
print("Cleanup called!")
|
print("Cleanup called!")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Dict, Tuple
|
from typing import Dict
|
||||||
|
|
||||||
from infection_monkey.i_puppet import (
|
from infection_monkey.i_puppet import (
|
||||||
ExploiterResultData,
|
ExploiterResultData,
|
||||||
|
@ -45,9 +45,7 @@ class Puppet(IPuppet):
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run_payload(
|
def run_payload(self, name: str, options: Dict, interrupt: threading.Event):
|
||||||
self, name: str, options: Dict, interrupt: threading.Event
|
|
||||||
) -> Tuple[None, bool, str]:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def cleanup(self) -> None:
|
def cleanup(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue