From a8ebe6ae769d877b238340de0770f4b14e541dfb Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 22 Jun 2021 13:31:20 -0400 Subject: [PATCH] agent: Replace self.config with self.target_dir in RansomewarePayload --- .../ransomware/ransomware_payload.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/monkey/infection_monkey/ransomware/ransomware_payload.py b/monkey/infection_monkey/ransomware/ransomware_payload.py index a47e3ba18..c09c35ab9 100644 --- a/monkey/infection_monkey/ransomware/ransomware_payload.py +++ b/monkey/infection_monkey/ransomware/ransomware_payload.py @@ -14,25 +14,17 @@ LOG = logging.getLogger(__name__) class RansomewarePayload: def __init__(self, config: dict): - self.config = config + LOG.info(f"Windows dir configured for encryption is " f"{config['windows_dir']}") + LOG.info(f"Linux dir configured for encryption is " f"{config['linux_dir']}") + + self.target_dir = Path(config["windows_dir"] if is_windows_os() else config["linux_dir"]) def run_payload(self): - LOG.info( - f"Windows dir configured for encryption is " f"{self.config['windows_dir_ransom']}" - ) - LOG.info(f"Linux dir configured for encryption is " f"{self.config['linux_dir_ransom']}") - file_list = self._find_files() self._encrypt_files(file_list) def _find_files(self): - dir_path = ( - self.config["windows_dir_ransom"] - if is_windows_os() - else self.config["linux_dir_ransom"] - ) - - all_files = get_all_files_in_directory(Path(dir_path)) + all_files = get_all_files_in_directory(self.target_dir) return filter_files(all_files, file_extension_filter(VALID_FILE_EXTENSIONS_FOR_ENCRYPTION)) def _encrypt_files(self, file_list):