forked from p15670423/monkey
Agent: Modify IPuppet interface to take VictimHost instead of object
This commit is contained in:
parent
b17c85cd01
commit
32d618ac92
|
@ -5,6 +5,8 @@ from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, Iterable, List, Mapping, Sequence
|
from typing import Dict, Iterable, List, Mapping, Sequence
|
||||||
|
|
||||||
|
from infection_monkey.model import VictimHost
|
||||||
|
|
||||||
from . import PluginType
|
from . import PluginType
|
||||||
from .credential_collection import Credentials
|
from .credential_collection import Credentials
|
||||||
|
|
||||||
|
@ -110,15 +112,14 @@ class IPuppet(metaclass=abc.ABCMeta):
|
||||||
:rtype: FingerprintData
|
:rtype: FingerprintData
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def exploit_host(
|
def exploit_host(
|
||||||
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
self, name: str, host: VictimHost, options: Dict, interrupt: threading.Event
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
"""
|
"""
|
||||||
Runs an exploiter against a remote host
|
Runs an exploiter against a remote host
|
||||||
:param str name: The name of the exploiter to run
|
:param str name: The name of the exploiter to run
|
||||||
:param object host: The domain name or IP address of a host
|
:param VictimHost host: A VictimHost object representing the target to exploit
|
||||||
:param Dict options: A dictionary containing options that modify the behavior of the
|
:param Dict options: A dictionary containing options that modify the behavior of the
|
||||||
exploiter
|
exploiter
|
||||||
:param threading.Event interrupt: A threading.Event object that signals the exploit to stop
|
:param threading.Event interrupt: A threading.Event object that signals the exploit to stop
|
||||||
|
|
|
@ -14,6 +14,7 @@ from infection_monkey.i_puppet import (
|
||||||
PortStatus,
|
PortStatus,
|
||||||
PostBreachData,
|
PostBreachData,
|
||||||
)
|
)
|
||||||
|
from infection_monkey.model import VictimHost
|
||||||
|
|
||||||
DOT_1 = "10.0.0.1"
|
DOT_1 = "10.0.0.1"
|
||||||
DOT_2 = "10.0.0.2"
|
DOT_2 = "10.0.0.2"
|
||||||
|
@ -136,7 +137,7 @@ class MockPuppet(IPuppet):
|
||||||
|
|
||||||
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
||||||
def exploit_host(
|
def exploit_host(
|
||||||
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
self, name: str, host: VictimHost, options: Dict, interrupt: threading.Event
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
logger.debug(f"exploit_hosts({name}, {host}, {options})")
|
logger.debug(f"exploit_hosts({name}, {host}, {options})")
|
||||||
attempts = [
|
attempts = [
|
||||||
|
|
|
@ -13,6 +13,7 @@ from infection_monkey.i_puppet import (
|
||||||
PortScanData,
|
PortScanData,
|
||||||
PostBreachData,
|
PostBreachData,
|
||||||
)
|
)
|
||||||
|
from infection_monkey.model import VictimHost
|
||||||
|
|
||||||
from ..telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger
|
from ..telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger
|
||||||
from .mock_puppet import MockPuppet
|
from .mock_puppet import MockPuppet
|
||||||
|
@ -58,9 +59,8 @@ class Puppet(IPuppet):
|
||||||
fingerprinter = self._plugin_registry.get_plugin(name, PluginType.FINGERPRINTER)
|
fingerprinter = self._plugin_registry.get_plugin(name, PluginType.FINGERPRINTER)
|
||||||
return fingerprinter.get_host_fingerprint(host, ping_scan_data, port_scan_data, options)
|
return fingerprinter.get_host_fingerprint(host, ping_scan_data, port_scan_data, options)
|
||||||
|
|
||||||
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
|
||||||
def exploit_host(
|
def exploit_host(
|
||||||
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
self, name: str, host: VictimHost, options: Dict, interrupt: threading.Event
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
exploiter = self._plugin_registry.get_plugin(name, PluginType.EXPLOITER)
|
exploiter = self._plugin_registry.get_plugin(name, PluginType.EXPLOITER)
|
||||||
return exploiter.exploit_host(host, self._telemetry_messenger, options)
|
return exploiter.exploit_host(host, self._telemetry_messenger, options)
|
||||||
|
|
Loading…
Reference in New Issue