From 49654d4dfe5e358d407ae086eeb3a9a1c3e9ca9e Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 30 May 2022 15:14:58 +0200 Subject: [PATCH] Island, Agent: Move dropper option from WormConfiguration to consts * Remove dropper_set_date, dropper_date_reference_path_windows dropper_date_reference_path_linux from internal config in the Island * Remove all references to these options from data for tests --- monkey/infection_monkey/config.py | 8 ------- monkey/infection_monkey/dropper.py | 22 ++++++----------- .../cc/services/config_schema/internal.py | 24 ------------------- .../automated_master_config.json | 1 - .../monkey_configs/flat_config.json | 3 --- .../monkey_config_standard.json | 3 --- 6 files changed, 7 insertions(+), 54 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 1f8c46311..5b5ce3722 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -65,14 +65,6 @@ class Configuration(object): return result - ########################### - # dropper config - ########################### - - dropper_set_date = True - dropper_date_reference_path_windows = r"%windir%\system32\kernel32.dll" - dropper_date_reference_path_linux = "/bin/sh" - ########################### # monkey config ########################### diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 4bbc272ea..57259950f 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -10,7 +10,6 @@ import time from pathlib import WindowsPath from common.utils.attack_utils import UsageEnum -from infection_monkey.config import WormConfiguration from infection_monkey.utils.commands import ( build_monkey_commandline_explicitly, get_monkey_commandline_linux, @@ -35,6 +34,8 @@ except NameError: logger = logging.getLogger(__name__) MOVEFILE_DELAY_UNTIL_REBOOT = 4 +DATE_REFERENCE_PATH_WINDOWS = r"%windir%\system32\kernel32.dll" +DATE_REFERENCE_PATH_LINUX = "/bin/sh" class MonkeyDrops(object): @@ -110,27 +111,18 @@ class MonkeyDrops(object): return False - if WormConfiguration.dropper_set_date: - if sys.platform == "win32": - dropper_date_reference_path = os.path.expandvars( - WormConfiguration.dropper_date_reference_path_windows - ) - else: - dropper_date_reference_path = WormConfiguration.dropper_date_reference_path_linux + if sys.platform == "win32": + dropper_date_reference_path = os.path.expandvars(DATE_REFERENCE_PATH_WINDOWS) + else: + dropper_date_reference_path = DATE_REFERENCE_PATH_LINUX try: ref_stat = os.stat(dropper_date_reference_path) + os.utime(self._config["destination_path"], (ref_stat.st_atime, ref_stat.st_mtime)) except OSError: logger.warning( "Cannot set reference date using '%s', file not found", dropper_date_reference_path, ) - else: - try: - os.utime( - self._config["destination_path"], (ref_stat.st_atime, ref_stat.st_mtime) - ) - except OSError: - logger.warning("Cannot set reference date to destination file") monkey_options = build_monkey_commandline_explicitly( parent=self.opts.parent, diff --git a/monkey/monkey_island/cc/services/config_schema/internal.py b/monkey/monkey_island/cc/services/config_schema/internal.py index 86a0089ec..1b684b31f 100644 --- a/monkey/monkey_island/cc/services/config_schema/internal.py +++ b/monkey/monkey_island/cc/services/config_schema/internal.py @@ -144,30 +144,6 @@ INTERNAL = { "title": "Dropper", "type": "object", "properties": { - "dropper_set_date": { - "title": "Dropper sets date", - "type": "boolean", - "default": True, - "description": "Determines whether the dropper should set the monkey's file " - "date to be the same as" - " another file", - }, - "dropper_date_reference_path_windows": { - "title": "Dropper date reference path (Windows)", - "type": "string", - "default": "%windir%\\system32\\kernel32.dll", - "description": "Determines which file the dropper should copy the date from if " - "it's configured to do" - " so on Windows (use fullpath)", - }, - "dropper_date_reference_path_linux": { - "title": "Dropper date reference path (Linux)", - "type": "string", - "default": "/bin/sh", - "description": "Determines which file the dropper should copy the date from if " - "it's configured to do" - " so on Linux (use fullpath)", - }, "dropper_target_path_linux": { "title": "Dropper target path on Linux", "type": "string", diff --git a/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json b/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json index 8ed5eb8b8..eb61845cf 100644 --- a/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json +++ b/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json @@ -69,7 +69,6 @@ "windows_command": "" }, "depth": 2, - "dropper_set_date": true, "exploit_lm_hash_list": ["DEADBEEF", "FACADE"], "exploit_ntlm_hash_list": ["BEADED", "ACCEDE", "DECADE"], "exploit_password_list": ["p1", "p2", "p3"], 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 2f48f30a6..7faa69069 100644 --- a/monkey/tests/data_for_tests/monkey_configs/flat_config.json +++ b/monkey/tests/data_for_tests/monkey_configs/flat_config.json @@ -21,9 +21,6 @@ "custom_PBA_linux_cmd": "bash test.sh", "custom_PBA_windows_cmd": "powershell test.ps1", "depth": 2, - "dropper_date_reference_path_linux": "/bin/sh", - "dropper_date_reference_path_windows": "%windir%\\system32\\kernel32.dll", - "dropper_set_date": true, "dropper_target_path_linux": "/tmp/monkey", "dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe", "exploit_lm_hash_list": ["lm_hash_1", "lm_hash_2"], diff --git a/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json b/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json index 1ffce78cf..31a2beace 100644 --- a/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json +++ b/monkey/tests/data_for_tests/monkey_configs/monkey_config_standard.json @@ -97,9 +97,6 @@ ] }, "dropper": { - "dropper_set_date": true, - "dropper_date_reference_path_windows": "%windir%\\system32\\kernel32.dll", - "dropper_date_reference_path_linux": "/bin/sh", "dropper_target_path_linux": "/tmp/monkey", "dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe" },