From e76b46c8ca4326538efa77e877554edb9c9395b7 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 8 Mar 2022 15:13:00 -0500 Subject: [PATCH] Island: Add smb_download_timeout to SMB and WMI exploiter options --- monkey/monkey_island/cc/services/config.py | 16 +++++++++++++++- .../monkey_island/cc/services/test_config.py | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 94c4e96ec..f90df6847 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -629,4 +629,18 @@ class ConfigService: config.pop(flat_config_exploiter_classes_field, None) - return formatted_exploiters_config + return ConfigService._add_smb_download_timeout_to_exploiters( + config, formatted_exploiters_config + ) + + @staticmethod + def _add_smb_download_timeout_to_exploiters( + flat_config: Dict, formatted_config: Dict + ) -> Dict[str, List[Dict[str, Any]]]: + new_config = copy.deepcopy(formatted_config) + uses_smb_timeout = {"SmbExploiter", "WmiExploiter"} + + for exploiter in filter(lambda e: e["name"] in uses_smb_timeout, new_config["brute_force"]): + exploiter["options"]["smb_download_timeout"] = flat_config["smb_download_timeout"] + + return new_config 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 d8391717e..72dafd168 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 @@ -180,8 +180,8 @@ def test_format_config_for_agent__exploiters(flat_monkey_config): {"name": "MSSQLExploiter", "options": {}}, {"name": "PowerShellExploiter", "options": {}}, {"name": "SSHExploiter", "options": {}}, - {"name": "SmbExploiter", "options": {}}, - {"name": "WmiExploiter", "options": {}}, + {"name": "SmbExploiter", "options": {"smb_download_timeout": 300}}, + {"name": "WmiExploiter", "options": {"smb_download_timeout": 300}}, ], "vulnerability": [ {"name": "DrupalExploiter", "options": {}},