forked from p34709852/monkey
Agent: Replace ExploiterConfig with PluginConfig
ExploiterConfig was exact match of PluginConfig, so they got merged
This commit is contained in:
parent
44a6197422
commit
4ef17ccc9b
|
@ -7,7 +7,6 @@ from .agent_sub_configurations import (
|
|||
TCPScanConfiguration,
|
||||
NetworkScanConfiguration,
|
||||
ExploitationOptionsConfiguration,
|
||||
ExploiterConfiguration,
|
||||
ExploitationConfiguration,
|
||||
PropagationConfiguration,
|
||||
)
|
||||
|
|
|
@ -4,7 +4,6 @@ from .agent_sub_configurations import (
|
|||
CustomPBAConfiguration,
|
||||
ExploitationConfiguration,
|
||||
ExploitationOptionsConfiguration,
|
||||
ExploiterConfiguration,
|
||||
ICMPScanConfiguration,
|
||||
NetworkScanConfiguration,
|
||||
PluginConfiguration,
|
||||
|
@ -81,19 +80,10 @@ class ExploitationOptionsConfigurationSchema(Schema):
|
|||
return ExploitationOptionsConfiguration(**data)
|
||||
|
||||
|
||||
class ExploiterConfigurationSchema(Schema):
|
||||
name = fields.Str()
|
||||
options = fields.Mapping()
|
||||
|
||||
@post_load
|
||||
def _make_exploiter_configuration(self, data, **kwargs):
|
||||
return ExploiterConfiguration(**data)
|
||||
|
||||
|
||||
class ExploitationConfigurationSchema(Schema):
|
||||
options = fields.Nested(ExploitationOptionsConfigurationSchema)
|
||||
brute_force = fields.List(fields.Nested(ExploiterConfigurationSchema))
|
||||
vulnerability = fields.List(fields.Nested(ExploiterConfigurationSchema))
|
||||
brute_force = fields.List(fields.Nested(PluginConfigurationSchema))
|
||||
vulnerability = fields.List(fields.Nested(PluginConfigurationSchema))
|
||||
|
||||
@post_load
|
||||
def _make_exploitation_options_configuration(self, data, **kwargs):
|
||||
|
|
|
@ -48,17 +48,11 @@ class ExploitationOptionsConfiguration:
|
|||
http_ports: List[int]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ExploiterConfiguration:
|
||||
name: str
|
||||
options: Dict
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ExploitationConfiguration:
|
||||
options: ExploitationOptionsConfiguration
|
||||
brute_force: List[ExploiterConfiguration]
|
||||
vulnerability: List[ExploiterConfiguration]
|
||||
brute_force: List[PluginConfiguration]
|
||||
vulnerability: List[PluginConfiguration]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
|
|
@ -3,7 +3,6 @@ from .agent_sub_configurations import (
|
|||
CustomPBAConfiguration,
|
||||
ExploitationConfiguration,
|
||||
ExploitationOptionsConfiguration,
|
||||
ExploiterConfiguration,
|
||||
ICMPScanConfiguration,
|
||||
NetworkScanConfiguration,
|
||||
PluginConfiguration,
|
||||
|
@ -83,16 +82,16 @@ NETWORK_SCAN_CONFIGURATION = NetworkScanConfiguration(
|
|||
|
||||
EXPLOITATION_OPTIONS_CONFIGURATION = ExploitationOptionsConfiguration(HTTP_PORTS)
|
||||
BRUTE_FORCE_EXPLOITERS = [
|
||||
ExploiterConfiguration("MSSQLExploiter", {}),
|
||||
ExploiterConfiguration("PowerShellExploiter", {}),
|
||||
ExploiterConfiguration("SSHExploiter", {}),
|
||||
ExploiterConfiguration("SmbExploiter", {"smb_download_timeout": 30}),
|
||||
ExploiterConfiguration("WmiExploiter", {"smb_download_timeout": 30}),
|
||||
PluginConfiguration("MSSQLExploiter", {}),
|
||||
PluginConfiguration("PowerShellExploiter", {}),
|
||||
PluginConfiguration("SSHExploiter", {}),
|
||||
PluginConfiguration("SmbExploiter", {"smb_download_timeout": 30}),
|
||||
PluginConfiguration("WmiExploiter", {"smb_download_timeout": 30}),
|
||||
]
|
||||
|
||||
VULNERABILITY_EXPLOITERS = [
|
||||
ExploiterConfiguration("Log4ShellExploiter", {}),
|
||||
ExploiterConfiguration("HadoopExploiter", {}),
|
||||
PluginConfiguration("Log4ShellExploiter", {}),
|
||||
PluginConfiguration("HadoopExploiter", {}),
|
||||
]
|
||||
|
||||
EXPLOITATION_CONFIGURATION = ExploitationConfiguration(
|
||||
|
|
|
@ -10,7 +10,7 @@ from typing import Callable, Dict, Sequence
|
|||
from common import OperatingSystems
|
||||
from common.configuration.agent_sub_configurations import (
|
||||
ExploitationConfiguration,
|
||||
ExploiterConfiguration,
|
||||
PluginConfiguration,
|
||||
)
|
||||
from infection_monkey.custom_types import PropagationCredentials
|
||||
from infection_monkey.i_puppet import ExploiterResultData, IPuppet
|
||||
|
@ -81,7 +81,7 @@ class Exploiter:
|
|||
@staticmethod
|
||||
def _process_exploiter_config(
|
||||
exploiter_config: ExploitationConfiguration,
|
||||
) -> Sequence[ExploiterConfiguration]:
|
||||
) -> Sequence[PluginConfiguration]:
|
||||
# Run vulnerability exploiters before brute force exploiters to minimize the effect of
|
||||
# account lockout due to invalid credentials
|
||||
ordered_exploiters = chain(exploiter_config.vulnerability, exploiter_config.brute_force)
|
||||
|
@ -92,13 +92,13 @@ class Exploiter:
|
|||
# This order allows exploiter-specific options to
|
||||
# override general options for all exploiters.
|
||||
options = {**exploiter_config.options.__dict__, **exploiter.options}
|
||||
extended_exploiters.append(ExploiterConfiguration(exploiter.name, options))
|
||||
extended_exploiters.append(PluginConfiguration(exploiter.name, options))
|
||||
|
||||
return extended_exploiters
|
||||
|
||||
def _exploit_hosts_on_queue(
|
||||
self,
|
||||
exploiters_to_run: Sequence[ExploiterConfiguration],
|
||||
exploiters_to_run: Sequence[PluginConfiguration],
|
||||
hosts_to_exploit: Queue,
|
||||
current_depth: int,
|
||||
results_callback: Callback,
|
||||
|
@ -125,7 +125,7 @@ class Exploiter:
|
|||
|
||||
def _run_all_exploiters(
|
||||
self,
|
||||
exploiters_to_run: Sequence[ExploiterConfiguration],
|
||||
exploiters_to_run: Sequence[PluginConfiguration],
|
||||
victim_host: VictimHost,
|
||||
current_depth: int,
|
||||
results_callback: Callback,
|
||||
|
|
|
@ -33,7 +33,6 @@ from common.configuration.agent_sub_configuration_schemas import (
|
|||
CustomPBAConfigurationSchema,
|
||||
ExploitationConfigurationSchema,
|
||||
ExploitationOptionsConfigurationSchema,
|
||||
ExploiterConfigurationSchema,
|
||||
ICMPScanConfigurationSchema,
|
||||
NetworkScanConfigurationSchema,
|
||||
PluginConfigurationSchema,
|
||||
|
@ -126,7 +125,7 @@ def test_exploitation_options_configuration_schema():
|
|||
def test_exploiter_configuration_schema():
|
||||
name = "bond"
|
||||
options = {"gun": "Walther PPK", "car": "Aston Martin DB5"}
|
||||
schema = ExploiterConfigurationSchema()
|
||||
schema = PluginConfigurationSchema()
|
||||
|
||||
config = schema.load({"name": name, "options": options})
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from tests.unit_tests.infection_monkey.master.mock_puppet import MockPuppet
|
|||
from common import OperatingSystems
|
||||
from common.configuration.agent_sub_configurations import (
|
||||
ExploitationConfiguration,
|
||||
ExploiterConfiguration,
|
||||
PluginConfiguration,
|
||||
)
|
||||
from infection_monkey.master import Exploiter
|
||||
from infection_monkey.model import VictimHost
|
||||
|
@ -41,11 +41,11 @@ def callback():
|
|||
@pytest.fixture
|
||||
def exploiter_config(default_agent_configuration):
|
||||
brute_force = [
|
||||
ExploiterConfiguration(name="MSSQLExploiter", options={"timeout": 10}),
|
||||
ExploiterConfiguration(name="SSHExploiter", options={}),
|
||||
ExploiterConfiguration(name="WmiExploiter", options={"timeout": 10}),
|
||||
PluginConfiguration(name="MSSQLExploiter", options={"timeout": 10}),
|
||||
PluginConfiguration(name="SSHExploiter", options={}),
|
||||
PluginConfiguration(name="WmiExploiter", options={"timeout": 10}),
|
||||
]
|
||||
vulnerability = [ExploiterConfiguration(name="ZerologonExploiter", options={})]
|
||||
vulnerability = [PluginConfiguration(name="ZerologonExploiter", options={})]
|
||||
return ExploitationConfiguration(
|
||||
options=default_agent_configuration.propagation.exploitation.options,
|
||||
brute_force=brute_force,
|
||||
|
|
Loading…
Reference in New Issue