From 5e59160698bcd4d677fb8ffcf9bbe64e0449611e Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 9 Jun 2022 16:35:31 -0700 Subject: [PATCH 1/4] Island: Remove `smb_download_timeout` from config schema --- .../cc/services/config_schema/internal.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/monkey/monkey_island/cc/services/config_schema/internal.py b/monkey/monkey_island/cc/services/config_schema/internal.py index 906f7520f..9c28425f3 100644 --- a/monkey/monkey_island/cc/services/config_schema/internal.py +++ b/monkey/monkey_island/cc/services/config_schema/internal.py @@ -165,19 +165,6 @@ INTERNAL = { "items": {"type": "string"}, "description": "List of SSH key pairs to use, when trying to ssh into servers", }, - "smb_service": { - "title": "SMB service", - "type": "object", - "properties": { - "smb_download_timeout": { - "title": "SMB download timeout", - "type": "integer", - "default": 30, - "description": "Timeout (in seconds) for SMB download operation (used " - "in various exploits using SMB)", - }, - }, - }, }, }, "testing": { From 8af267248b8983756f3cdda83e2220d926d67535 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 9 Jun 2022 16:37:41 -0700 Subject: [PATCH 2/4] Island: Create `SMB_DOWNLOAD_TIMEOUT` and pass in exploiter options --- monkey/monkey_island/cc/services/config.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index afc4742ba..87f949ce8 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -52,6 +52,8 @@ SENSITIVE_SSH_KEY_FIELDS = [ SensitiveField(path="public_key", field_encryptor=StringEncryptor), ] +SMB_DOWNLOAD_TIMEOUT = 30 + class ConfigService: default_config = None @@ -584,19 +586,19 @@ class ConfigService: config.pop(flat_config_exploiter_classes_field, None) formatted_exploiters_config = ConfigService._add_smb_download_timeout_to_exploiters( - config, formatted_exploiters_config + formatted_exploiters_config ) return ConfigService._add_supported_os_to_exploiters(formatted_exploiters_config) @staticmethod def _add_smb_download_timeout_to_exploiters( - flat_config: Dict, formatted_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"] + exploiter["options"]["smb_download_timeout"] = SMB_DOWNLOAD_TIMEOUT return new_config From 4c2e33bc5eee4ade6b85cc12eeedfbc88425868d Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 9 Jun 2022 16:38:12 -0700 Subject: [PATCH 3/4] UT: Remove `smb_download_timeout` from config in data for tests --- monkey/tests/data_for_tests/monkey_configs/flat_config.json | 1 - 1 file changed, 1 deletion(-) diff --git a/monkey/tests/data_for_tests/monkey_configs/flat_config.json b/monkey/tests/data_for_tests/monkey_configs/flat_config.json index c1b924439..18d849e16 100644 --- a/monkey/tests/data_for_tests/monkey_configs/flat_config.json +++ b/monkey/tests/data_for_tests/monkey_configs/flat_config.json @@ -82,7 +82,6 @@ "readme": true } }, - "smb_download_timeout": 300, "subnet_scan_list": ["192.168.1.50", "192.168.56.0/24", "10.0.33.0/30"], "system_info_collector_classes": [ "MimikatzCollector" From 42df8ee7578f24a915f645e6abb3c3e347537a08 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 9 Jun 2022 21:00:15 -0700 Subject: [PATCH 4/4] UT: Fix tests' `smb_download_timeout` from 300 to 30 --- .../tests/unit_tests/monkey_island/cc/services/test_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 41c78cb8c..bc804c68a 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 @@ -195,12 +195,12 @@ def test_format_config_for_agent__exploiters(): { "name": "SmbExploiter", "supported_os": ["windows"], - "options": {"smb_download_timeout": 300}, + "options": {"smb_download_timeout": 30}, }, { "name": "WmiExploiter", "supported_os": ["windows"], - "options": {"smb_download_timeout": 300}, + "options": {"smb_download_timeout": 30}, }, ], "vulnerability": [