Fix a bug in ransomware directories that caused environmental variables to not be expanded

This commit is contained in:
VakarisZ 2021-07-02 15:11:30 +03:00
parent f698c889e3
commit 8ef6a50180
2 changed files with 4 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import logging import logging
import os
import shutil import shutil
from pathlib import Path from pathlib import Path
from pprint import pformat from pprint import pformat
@ -55,7 +56,7 @@ class RansomwarePayload:
return [] return []
return select_production_safe_target_files( return select_production_safe_target_files(
Path(self._target_dir), self._valid_file_extensions_for_encryption Path(os.path.expandvars(self._target_dir)), self._valid_file_extensions_for_encryption
) )
def _encrypt_files(self, file_list: List[Path]) -> List[Tuple[Path, Optional[Exception]]]: def _encrypt_files(self, file_list: List[Path]) -> List[Tuple[Path, Optional[Exception]]]:
@ -84,7 +85,7 @@ class RansomwarePayload:
def _leave_readme(self): def _leave_readme(self):
if self._readme_enabled: if self._readme_enabled:
readme_dest_path = Path(self._target_dir) / README_DEST readme_dest_path = Path(os.path.expandvars(self._target_dir)) / README_DEST
LOG.info(f"Leaving a ransomware README file at {readme_dest_path}") LOG.info(f"Leaving a ransomware README file at {readme_dest_path}")
try: try:

View File

@ -1,5 +1,3 @@
from pathlib import Path
from common.common_consts.telem_categories import TelemCategoryEnum from common.common_consts.telem_categories import TelemCategoryEnum
from infection_monkey.telemetry.base_telem import BaseTelem from infection_monkey.telemetry.base_telem import BaseTelem
from infection_monkey.telemetry.batchable_telem_mixin import BatchableTelemMixin from infection_monkey.telemetry.batchable_telem_mixin import BatchableTelemMixin
@ -7,7 +5,7 @@ from infection_monkey.telemetry.i_batchable_telem import IBatchableTelem
class FileEncryptionTelem(BatchableTelemMixin, IBatchableTelem, BaseTelem): class FileEncryptionTelem(BatchableTelemMixin, IBatchableTelem, BaseTelem):
def __init__(self, filepath: Path, success: bool, error: str): def __init__(self, filepath: str, success: bool, error: str):
""" """
File Encryption telemetry constructor File Encryption telemetry constructor
:param filepath: The path to the file that monkey attempted to encrypt :param filepath: The path to the file that monkey attempted to encrypt