From 947a03c9a1eeb70bb0e926eff100d2defa30f28e Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 22 Jun 2021 16:42:09 +0300 Subject: [PATCH] Refactor ransomware configuration option from flattened to a dict that encompasses any ransomware options --- monkey/infection_monkey/config.py | 3 +-- monkey/infection_monkey/monkey.py | 4 ++-- monkey/monkey_island/cc/services/config.py | 4 ++++ monkey/monkey_island/cc/services/config_schema/ransomware.py | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 5111bae48..f7ec13af6 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -197,8 +197,7 @@ class Configuration(object): # ransomware config ########################### - windows_dir_ransom = "" - linux_dir_ransom = "" + ransomware = "" def get_exploit_user_password_pairs(self): """ diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index e03296570..abd0b3f18 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -19,7 +19,7 @@ from infection_monkey.network.HostFinger import HostFinger from infection_monkey.network.network_scanner import NetworkScanner from infection_monkey.network.tools import get_interface_to_target, is_running_on_island from infection_monkey.post_breach.post_breach_handler import PostBreach -from infection_monkey.ransomware import start_ransomware +from infection_monkey.ransomware.ransomware_payload import RansomewarePayload from infection_monkey.system_info import SystemInfoCollector from infection_monkey.system_singleton import SystemSingleton from infection_monkey.telemetry.attack.t1106_telem import T1106Telem @@ -233,7 +233,7 @@ class InfectionMonkey(object): if not self._keep_running: break - start_ransomware() + RansomewarePayload(WormConfiguration.ransomware).run_payload() if (not is_empty) and (WormConfiguration.max_iterations > iteration_index + 1): time_to_sleep = WormConfiguration.timeout_between_iterations diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 7c7429756..acb12d48a 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -106,6 +106,10 @@ class ConfigService: config_json = ConfigService.get_config(is_initial_config, should_decrypt) flat_config_json = {} for i in config_json: + if i == "ransomware": + # Don't flatten the ransomware because ransomware payload expects a dictionary #1260 + flat_config_json[i] = config_json[i] + continue for j in config_json[i]: for k in config_json[i][j]: if isinstance(config_json[i][j][k], dict): diff --git a/monkey/monkey_island/cc/services/config_schema/ransomware.py b/monkey/monkey_island/cc/services/config_schema/ransomware.py index b5d250f00..74b5d3d67 100644 --- a/monkey/monkey_island/cc/services/config_schema/ransomware.py +++ b/monkey/monkey_island/cc/services/config_schema/ransomware.py @@ -6,14 +6,14 @@ RANSOMWARE = { "title": "Directories to encrypt", "type": "object", "properties": { - "linux_dir_ransom": { + "linux_dir": { "title": "Linux encryptable directory", "type": "string", "default": "", "description": "Files in the specified directory will be encrypted " "using bitflip to simulate ransomware.", }, - "windows_dir_ransom": { + "windows_dir": { "title": "Windows encryptable directory", "type": "string", "default": "",