From cecf131528b543c4a024374d77315fa08b3c3dbf Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Fri, 18 Feb 2022 20:04:24 +0100 Subject: [PATCH] Island: Modify config to add exploiters and exploit options --- monkey/monkey_island/cc/services/config.py | 17 +++++++++-- .../monkey_island/cc/services/test_config.py | 29 +++++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 6cb895ead..19a2a4497 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -602,7 +602,20 @@ class ConfigService: "WmiExploiter", } - formatted_exploiters_config = {"brute_force": [], "vulnerability": []} + exploit_options = {} + + for dropper_target in [ + "dropper_target_path_linux", + "dropper_target_path_win_32", + "dropper_target_path_win_64", + ]: + exploit_options[dropper_target] = config.get(dropper_target, "") + + formatted_exploiters_config = { + "options": exploit_options, + "brute_force": [], + "vulnerability": [], + } for exploiter in sorted(config[flat_config_exploiter_classes_field]): category = ( @@ -611,7 +624,7 @@ class ConfigService: else vulnerability_category ) - formatted_exploiters_config[category].append({"name": exploiter}) + formatted_exploiters_config[category].append({"name": exploiter, "options": {}}) config.pop(flat_config_exploiter_classes_field, None) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py index 60dd4e464..9bc86bb7f 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py @@ -171,21 +171,26 @@ def test_format_config_for_agent__network_scan(flat_monkey_config): def test_format_config_for_agent__exploiters(flat_monkey_config): expected_exploiters_config = { + "options": { + "dropper_target_path_linux": "/tmp/monkey", + "dropper_target_path_win_32": r"C:\Windows\temp\monkey32.exe", + "dropper_target_path_win_64": r"C:\Windows\temp\monkey64.exe", + }, "brute_force": [ - {"name": "MSSQLExploiter"}, - {"name": "PowerShellExploiter"}, - {"name": "SSHExploiter"}, - {"name": "SmbExploiter"}, - {"name": "WmiExploiter"}, + {"name": "MSSQLExploiter", "options": {}}, + {"name": "PowerShellExploiter", "options": {}}, + {"name": "SSHExploiter", "options": {}}, + {"name": "SmbExploiter", "options": {}}, + {"name": "WmiExploiter", "options": {}}, ], "vulnerability": [ - {"name": "DrupalExploiter"}, - {"name": "ElasticGroovyExploiter"}, - {"name": "HadoopExploiter"}, - {"name": "ShellShockExploiter"}, - {"name": "Struts2Exploiter"}, - {"name": "WebLogicExploiter"}, - {"name": "ZerologonExploiter"}, + {"name": "DrupalExploiter", "options": {}}, + {"name": "ElasticGroovyExploiter", "options": {}}, + {"name": "HadoopExploiter", "options": {}}, + {"name": "ShellShockExploiter", "options": {}}, + {"name": "Struts2Exploiter", "options": {}}, + {"name": "WebLogicExploiter", "options": {}}, + {"name": "ZerologonExploiter", "options": {}}, ], } ConfigService.format_flat_config_for_agent(flat_monkey_config)