forked from p15670423/monkey
Island: Reformat "payloads" in config before sending to agent
Allow the configuration to contain multiple payloads that can be run by the agent.
This commit is contained in:
parent
2455d34c7f
commit
44055b32f9
|
@ -430,6 +430,7 @@ class ConfigService:
|
|||
@staticmethod
|
||||
def format_flat_config_for_agent(config: Dict):
|
||||
ConfigService._remove_credentials_from_flat_config(config)
|
||||
ConfigService._format_payloads_from_flat_config(config)
|
||||
|
||||
@staticmethod
|
||||
def _remove_credentials_from_flat_config(config: Dict):
|
||||
|
@ -443,3 +444,8 @@ class ConfigService:
|
|||
|
||||
for field in fields_to_remove:
|
||||
config.pop(field, None)
|
||||
|
||||
@staticmethod
|
||||
def _format_payloads_from_flat_config(config: Dict):
|
||||
config.setdefault("payloads", {})["ransomware"] = config["ransomware"]
|
||||
config.pop("ransomware", None)
|
||||
|
|
|
@ -93,8 +93,8 @@
|
|||
"encryption": {
|
||||
"enabled": true,
|
||||
"directories": {
|
||||
"linux_target_dir": "",
|
||||
"windows_target_dir": ""
|
||||
"linux_target_dir": "/tmp/ransomware-target",
|
||||
"windows_target_dir": "C:\\windows\\temp\\ransomware-target"
|
||||
}
|
||||
},
|
||||
"other_behaviors": {
|
||||
|
|
|
@ -33,3 +33,25 @@ def test_format_config_for_agent__credentials_removed(flat_monkey_config):
|
|||
assert "exploit_password_list" not in flat_monkey_config
|
||||
assert "exploit_ssh_keys" not in flat_monkey_config
|
||||
assert "exploit_user_list" not in flat_monkey_config
|
||||
|
||||
|
||||
def test_format_config_for_agent__ransomware_payload(flat_monkey_config):
|
||||
expected_ransomware_config = {
|
||||
"ransomware": {
|
||||
"encryption": {
|
||||
"enabled": True,
|
||||
"directories": {
|
||||
"linux_target_dir": "/tmp/ransomware-target",
|
||||
"windows_target_dir": "C:\\windows\\temp\\ransomware-target",
|
||||
},
|
||||
},
|
||||
"other_behaviors": {"readme": True},
|
||||
}
|
||||
}
|
||||
|
||||
ConfigService.format_flat_config_for_agent(flat_monkey_config)
|
||||
|
||||
assert "payloads" in flat_monkey_config
|
||||
assert flat_monkey_config["payloads"] == expected_ransomware_config
|
||||
|
||||
assert "ransomware" not in flat_monkey_config
|
||||
|
|
Loading…
Reference in New Issue