From 2d73aeaac6074228d03f0a4e91b17356f26f3b32 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 21:17:40 +0530 Subject: [PATCH 1/7] Common: Remove STARTED_ON_ISLAND config path constant --- monkey/common/config_value_paths.py | 1 - 1 file changed, 1 deletion(-) diff --git a/monkey/common/config_value_paths.py b/monkey/common/config_value_paths.py index db10fb9e1..c998f44fa 100644 --- a/monkey/common/config_value_paths.py +++ b/monkey/common/config_value_paths.py @@ -1,5 +1,4 @@ AWS_KEYS_PATH = ["internal", "monkey", "aws_keys"] -STARTED_ON_ISLAND_PATH = ["internal", "general", "started_on_island"] EXPORT_MONKEY_TELEMS_PATH = ["internal", "testing", "export_monkey_telems"] CURRENT_SERVER_PATH = ["internal", "island_server", "current_server"] SSH_KEYS_PATH = ["internal", "exploits", "exploit_ssh_keys"] From 71344bcab0e41b11aaa860b9a06118be5773b747 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 21:19:24 +0530 Subject: [PATCH 2/7] Agent: Remove started_on_island logic --- monkey/infection_monkey/config.py | 1 - monkey/infection_monkey/control.py | 9 --------- 2 files changed, 10 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 8f4984ba6..1b1ab6612 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -112,7 +112,6 @@ class Configuration(object): # depth of propagation depth = 2 max_depth = None - started_on_island = False current_server = "" # Configuration servers to try to connect to, in this order. diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 71e1fb8f0..c4b4b9555 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -401,12 +401,3 @@ class ControlClient(object): ) except requests.exceptions.RequestException: return False - - @staticmethod - def report_start_on_island(): - requests.post( # noqa: DUO123 - f"https://{WormConfiguration.current_server}/api/monkey_control/started_on_island", - data=json.dumps({"started_on_island": True}), - verify=False, - timeout=MEDIUM_REQUEST_TIMEOUT, - ) From 9791af1d47834045694f273195d224cb0229fe62 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 21:23:30 +0530 Subject: [PATCH 3/7] Island: Remove started_on_island logic --- monkey/monkey_island/cc/app.py | 1 - .../agent_controls/started_on_island.py | 16 ---------------- monkey/monkey_island/cc/services/config.py | 5 ----- .../cc/services/config_schema/internal.py | 7 ------- 4 files changed, 29 deletions(-) delete mode 100644 monkey/monkey_island/cc/resources/agent_controls/started_on_island.py diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index ce223bda4..553803e1e 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -172,7 +172,6 @@ def init_api_resources(api): api.add_resource(PropagationCredentials, "/api/propagation-credentials/") api.add_resource(RemoteRun, "/api/remote-monkey") api.add_resource(VersionUpdate, "/api/version-update") - api.add_resource(StartedOnIsland, "/api/monkey_control/started_on_island") api.add_resource(StopAgentCheck, "/api/monkey_control/needs-to-stop/") api.add_resource(StopAllAgents, "/api/monkey_control/stop-all-agents") api.add_resource(ScoutSuiteAuth, "/api/scoutsuite_auth/") diff --git a/monkey/monkey_island/cc/resources/agent_controls/started_on_island.py b/monkey/monkey_island/cc/resources/agent_controls/started_on_island.py deleted file mode 100644 index f0d7e411f..000000000 --- a/monkey/monkey_island/cc/resources/agent_controls/started_on_island.py +++ /dev/null @@ -1,16 +0,0 @@ -import json - -import flask_restful -from flask import make_response, request - -from monkey_island.cc.services.config import ConfigService - - -class StartedOnIsland(flask_restful.Resource): - - # Used by monkey. can't secure. - def post(self): - data = json.loads(request.data) - if data["started_on_island"]: - ConfigService.set_started_on_island(True) - return make_response({}, 200) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index af9c0a155..1daec8a76 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -15,7 +15,6 @@ from common.config_value_paths import ( PBA_LINUX_FILENAME_PATH, PBA_WINDOWS_FILENAME_PATH, SSH_KEYS_PATH, - STARTED_ON_ISLAND_PATH, USER_LIST_PATH, ) from monkey_island.cc.database import mongo @@ -405,10 +404,6 @@ class ConfigService: def is_test_telem_export_enabled(): return ConfigService.get_config_value(EXPORT_MONKEY_TELEMS_PATH) - @staticmethod - def set_started_on_island(value: bool): - ConfigService.set_config_value(STARTED_ON_ISLAND_PATH, value) - @staticmethod def get_config_propagation_credentials_from_flat_config(config): return { diff --git a/monkey/monkey_island/cc/services/config_schema/internal.py b/monkey/monkey_island/cc/services/config_schema/internal.py index 86318eaf1..a145233f9 100644 --- a/monkey/monkey_island/cc/services/config_schema/internal.py +++ b/monkey/monkey_island/cc/services/config_schema/internal.py @@ -15,13 +15,6 @@ INTERNAL = { "description": "Time to keep tunnel open before going down after last exploit " "(in seconds)", }, - "started_on_island": { - "title": "Started on island", - "type": "boolean", - "default": False, - "description": "Was exploitation started from island" - "(did monkey with max depth ran on island)", - }, }, }, "monkey": { From 9fcca7b9a4296f2a30d7a820b4e7454a0042f7e6 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 21:26:09 +0530 Subject: [PATCH 4/7] Agent: Remove unused get_hop_distance_to_island function --- monkey/infection_monkey/config.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 1b1ab6612..557ecdf0f 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -231,8 +231,5 @@ class Configuration(object): ########################### export_monkey_telems = False - def get_hop_distance_to_island(self): - return self.max_depth - self.depth - WormConfiguration = Configuration() From 03b7be3be167cc803299149ff81db9d26202078c Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 21:31:26 +0530 Subject: [PATCH 5/7] UI: Remove started_on_island option from UiSchema --- .../cc/ui/src/components/configuration-components/UiSchema.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js index 36053ef22..cd24fc040 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js @@ -117,9 +117,6 @@ export default function UiSchema(props) { other_behaviors : {'ui:widget': 'hidden'} }, internal: { - general: { - started_on_island: {'ui:widget': 'hidden'} - }, classes: { finger_classes: { classNames: 'config-template-no-header', From a91d6e1f05dc90375f954114c12f4746bf46f1a7 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 21:33:57 +0530 Subject: [PATCH 6/7] UT: Remove started_on_island from sample configs --- monkey/tests/data_for_tests/monkey_configs/flat_config.json | 1 - .../data_for_tests/monkey_configs/monkey_config_standard.json | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) 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 972f9e947..8f024b9b9 100644 --- a/monkey/tests/data_for_tests/monkey_configs/flat_config.json +++ b/monkey/tests/data_for_tests/monkey_configs/flat_config.json @@ -101,7 +101,6 @@ "skip_exploit_if_file_exist": false, "smb_download_timeout": 300, "smb_service_name": "InfectionMonkey", - "started_on_island": false, "subnet_scan_list": [], "system_info_collector_classes": [ "AwsCollector", 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 112d649d8..ba16a75ae 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 @@ -44,8 +44,7 @@ }, "internal": { "general": { - "keep_tunnel_open_time": 60, - "started_on_island": false + "keep_tunnel_open_time": 60 }, "monkey": { "victims_max_find": 100, From 949b0b78b9db0a31687ec10a1b8ffe6277c38a33 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 8 Dec 2021 22:01:40 +0530 Subject: [PATCH 7/7] Island: Remove leftover started on island logic after rebase --- monkey/monkey_island/cc/app.py | 6 +----- .../monkey_island/cc/resources/agent_controls/__init__.py | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 553803e1e..e90091168 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -8,11 +8,7 @@ from werkzeug.exceptions import NotFound from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH from monkey_island.cc.database import database, mongo -from monkey_island.cc.resources.agent_controls import ( - StartedOnIsland, - StopAgentCheck, - StopAllAgents, -) +from monkey_island.cc.resources.agent_controls import StopAgentCheck, StopAllAgents from monkey_island.cc.resources.attack.attack_report import AttackReport from monkey_island.cc.resources.auth.auth import Authenticate, init_jwt from monkey_island.cc.resources.auth.registration import Registration diff --git a/monkey/monkey_island/cc/resources/agent_controls/__init__.py b/monkey/monkey_island/cc/resources/agent_controls/__init__.py index c4f63322f..211696e4c 100644 --- a/monkey/monkey_island/cc/resources/agent_controls/__init__.py +++ b/monkey/monkey_island/cc/resources/agent_controls/__init__.py @@ -1,3 +1,2 @@ from .stop_all_agents import StopAllAgents -from .started_on_island import StartedOnIsland from .stop_agent_check import StopAgentCheck