Common: Add ExploitationConfiguration

This commit is contained in:
Mike Salvatore 2022-06-16 20:17:22 -04:00
parent db9d57a526
commit 4065bc23fb
3 changed files with 52 additions and 0 deletions

View File

@ -7,4 +7,6 @@ from .agent_configuration import (
ExploitationOptionsConfigurationSchema,
ExploiterConfiguration,
ExploiterConfigurationSchema,
ExploitationConfiguration,
ExploitationConfigurationSchema,
)

View File

@ -69,3 +69,20 @@ class ExploiterConfigurationSchema(Schema):
@post_load
def make_exploiter_configuration(self, data, **kwargs):
return ExploiterConfiguration(**data)
@dataclass(frozen=True)
class ExploitationConfiguration:
options: ExploitationOptionsConfiguration
brute_force: List[ExploiterConfiguration]
vulnerability: List[ExploiterConfiguration]
class ExploitationConfigurationSchema(Schema):
options = fields.Nested(ExploitationOptionsConfigurationSchema)
brute_force = fields.List(fields.Nested(ExploiterConfigurationSchema))
vulnerability = fields.List(fields.Nested(ExploiterConfigurationSchema))
@post_load
def make_exploitation_options_configuration(self, data, **kwargs):
return ExploitationConfiguration(**data)

View File

@ -1,6 +1,8 @@
from common import OperatingSystems
from common.configuration import (
CustomPBAConfigurationSchema,
ExploitationConfiguration,
ExploitationConfigurationSchema,
ExploitationOptionsConfigurationSchema,
ExploiterConfigurationSchema,
PluginConfigurationSchema,
@ -62,3 +64,34 @@ def test_exploiter_configuration_schema():
assert config.name == name
assert config.options == options
assert config.supported_os == supported_os
def test_exploitation_configuration():
ports = [1, 2, 3]
brute_force = [
{"name": "ex1", "options": {}, "supported_os": ["LINUX"]},
{
"name": "ex2",
"options": {"smb_download_timeout": 10},
"supported_os": ["LINUX", "WINDOWS"],
},
]
vulnerability = [
{
"name": "ex3",
"options": {"smb_download_timeout": 10},
"supported_os": ["WINDOWS"],
},
]
exploitation_config = {
"options": {"http_ports": ports},
"brute_force": brute_force,
"vulnerability": vulnerability,
}
schema = ExploitationConfigurationSchema()
config = schema.load(exploitation_config)
config_dict = schema.dump(config)
assert isinstance(config, ExploitationConfiguration)
assert config_dict == exploitation_config