From 5162d973d77f216976817f6d5f1149bbbb60f96f Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 15 Nov 2021 11:28:34 +0100 Subject: [PATCH 1/4] Agent: Always try to move the dropper first --- monkey/infection_monkey/config.py | 1 - monkey/infection_monkey/dropper.py | 11 ++++------- monkey/infection_monkey/example.conf | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 8fb4b2cb9..2c6e4b678 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -86,7 +86,6 @@ class Configuration(object): # dropper config ########################### - dropper_try_move_first = True dropper_set_date = True dropper_date_reference_path_windows = r"%windir%\system32\kernel32.dll" dropper_date_reference_path_linux = "/bin/sh" diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 67ceaa708..6919acc8e 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -72,8 +72,8 @@ class MonkeyDrops(object): if not file_moved and os.path.exists(self._config["destination_path"]): os.remove(self._config["destination_path"]) - # first try to move the file - if not file_moved and WormConfiguration.dropper_try_move_first: + # always try to move the file first + if not file_moved: try: shutil.move(self._config["source_path"], self._config["destination_path"]) @@ -187,11 +187,8 @@ class MonkeyDrops(object): logger.info("Cleaning up the dropper") try: - if ( - (self._config["source_path"].lower() != self._config["destination_path"].lower()) - and os.path.exists(self._config["source_path"]) - and WormConfiguration.dropper_try_move_first - ): + if self._config["source_path"].lower() != self._config["destination_path"].lower() \ + and os.path.exists(self._config["source_path"]): # try removing the file first try: diff --git a/monkey/infection_monkey/example.conf b/monkey/infection_monkey/example.conf index 5fce5aca5..de6965a6e 100644 --- a/monkey/infection_monkey/example.conf +++ b/monkey/infection_monkey/example.conf @@ -26,7 +26,6 @@ "monkey_dir_name": "monkey_dir", - "dropper_try_move_first": true, "exploiter_classes": [ "SSHExploiter", "SmbExploiter", From 8e4df65c2f24f65ee5a6b1b3ab5da562e39bf648 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 15 Nov 2021 11:29:49 +0100 Subject: [PATCH 2/4] Island: Remove checkbox to try move the dropper --- .../monkey_island/cc/services/config_schema/internal.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/monkey/monkey_island/cc/services/config_schema/internal.py b/monkey/monkey_island/cc/services/config_schema/internal.py index 3e9144539..981ccdaab 100644 --- a/monkey/monkey_island/cc/services/config_schema/internal.py +++ b/monkey/monkey_island/cc/services/config_schema/internal.py @@ -246,14 +246,6 @@ INTERNAL = { "Windows machine " "(64 bit)", }, - "dropper_try_move_first": { - "title": "Try to move first", - "type": "boolean", - "default": True, - "description": "Determines whether the dropper should try to move itself " - "instead of copying itself" - " to target path", - }, }, }, "logging": { From fd4bcb88ea227124a4c8ed912e4bbc7df6e3d096 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 15 Nov 2021 11:30:43 +0100 Subject: [PATCH 3/4] UT: Remove try to move dropper config --- .../data_for_tests/monkey_configs/monkey_config_standard.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 0f562c8d9..a90773aa7 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 @@ -116,8 +116,7 @@ "dropper_date_reference_path_linux": "/bin/sh", "dropper_target_path_linux": "/tmp/monkey", "dropper_target_path_win_32": "C:\\Windows\\temp\\monkey32.exe", - "dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe", - "dropper_try_move_first": true + "dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe" }, "logging": { "dropper_log_path_linux": "/tmp/user-1562", From de0fff9fbb73cfc612382bb03aa10325f8e12232 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 15 Nov 2021 11:31:32 +0100 Subject: [PATCH 4/4] Changelog: Remove checkbox to try move the dropper --- CHANGELOG.md | 1 + monkey/infection_monkey/dropper.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ad66f126..ac9093b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - Checkbox for self deleting a monkey agent on cleanup. #1537 - Checkbox for file logging. #1537 - Remove serialization of config. #1537 +- Checkbox that gave the option to not try to first move the dropper file. #1537 ### Fixed - A bug in network map page that caused delay of telemetry log loading. #1545 diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 6919acc8e..f74767cef 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -187,8 +187,9 @@ class MonkeyDrops(object): logger.info("Cleaning up the dropper") try: - if self._config["source_path"].lower() != self._config["destination_path"].lower() \ - and os.path.exists(self._config["source_path"]): + if self._config["source_path"].lower() != self._config[ + "destination_path" + ].lower() and os.path.exists(self._config["source_path"]): # try removing the file first try: