forked from p15670423/monkey
Common: Add ExploitationConfiguration
This commit is contained in:
parent
db9d57a526
commit
4065bc23fb
|
@ -7,4 +7,6 @@ from .agent_configuration import (
|
|||
ExploitationOptionsConfigurationSchema,
|
||||
ExploiterConfiguration,
|
||||
ExploiterConfigurationSchema,
|
||||
ExploitationConfiguration,
|
||||
ExploitationConfigurationSchema,
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue