forked from p15670423/monkey
Merge pull request #1309 from guardicore/1287/ransomware-readme-config-dirs
Ransomware README with configurable directories
This commit is contained in:
commit
af739b6c99
|
@ -56,12 +56,17 @@ class RansomwarePayload:
|
|||
return None
|
||||
|
||||
def run_payload(self):
|
||||
if self._encryption_enabled and self._target_dir:
|
||||
LOG.info("Running ransomware payload")
|
||||
if not self._target_dir:
|
||||
return
|
||||
|
||||
LOG.info("Running ransomware payload")
|
||||
|
||||
if self._encryption_enabled:
|
||||
file_list = self._find_files()
|
||||
self._encrypt_files(file_list)
|
||||
|
||||
self._leave_readme()
|
||||
if self._readme_enabled:
|
||||
self._leave_readme()
|
||||
|
||||
def _find_files(self) -> List[Path]:
|
||||
LOG.info(f"Collecting files in {self._target_dir}")
|
||||
|
@ -92,8 +97,6 @@ class RansomwarePayload:
|
|||
self._telemetry_messenger.send_telemetry(encryption_attempt)
|
||||
|
||||
def _leave_readme(self):
|
||||
if not self._readme_enabled:
|
||||
return
|
||||
|
||||
readme_dest_path = self._target_dir / README_DEST
|
||||
|
||||
|
|
|
@ -49,6 +49,12 @@ RANSOMWARE = {
|
|||
},
|
||||
},
|
||||
},
|
||||
"readme_note": {
|
||||
"title": "",
|
||||
"type": "object",
|
||||
"description": "Note: A README.txt will be left in the specified target "
|
||||
"directory.",
|
||||
},
|
||||
},
|
||||
},
|
||||
"other_behaviors": {
|
||||
|
|
|
@ -75,8 +75,10 @@ export default function UiSchema(props) {
|
|||
encryption: {
|
||||
directories: {
|
||||
// Directory inputs are dynamically hidden
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled: {'ui:widget': 'hidden'}
|
||||
},
|
||||
other_behaviors : {'ui:widget': 'hidden'}
|
||||
},
|
||||
internal: {
|
||||
general: {
|
||||
|
|
|
@ -244,3 +244,20 @@ def test_readme_already_exists(
|
|||
).run_payload()
|
||||
|
||||
mock_copy_file.assert_not_called()
|
||||
|
||||
|
||||
def test_no_readme_if_no_directory(
|
||||
monkeypatch, ransomware_payload_config, telemetry_messenger_spy, ransomware_target
|
||||
):
|
||||
monkeypatch.setattr(ransomware_payload_module, "TARGETED_FILE_EXTENSIONS", set()),
|
||||
mock_copy_file = MagicMock()
|
||||
|
||||
ransomware_payload_config["encryption"]["directories"]["linux_target_dir"] = ""
|
||||
ransomware_payload_config["encryption"]["directories"]["windows_target_dir"] = ""
|
||||
ransomware_payload_config["other_behaviors"]["readme"] = True
|
||||
|
||||
RansomwarePayload(
|
||||
ransomware_payload_config, telemetry_messenger_spy, mock_copy_file
|
||||
).run_payload()
|
||||
|
||||
mock_copy_file.assert_not_called()
|
||||
|
|
Loading…
Reference in New Issue