forked from p15670423/monkey
Agent: Add file extension to RansomwareOptions
This commit is contained in:
parent
4f776f0102
commit
ae1fbb7cc5
|
@ -9,6 +9,7 @@ logger = logging.getLogger(__name__)
|
||||||
class RansomwareOptions:
|
class RansomwareOptions:
|
||||||
def __init__(self, options: dict):
|
def __init__(self, options: dict):
|
||||||
self.encryption_enabled = options["encryption"]["enabled"]
|
self.encryption_enabled = options["encryption"]["enabled"]
|
||||||
|
self.file_extension = options["encryption"]["file_extension"]
|
||||||
self.readme_enabled = options["other_behaviors"]["readme"]
|
self.readme_enabled = options["other_behaviors"]["readme"]
|
||||||
|
|
||||||
self.target_directory = None
|
self.target_directory = None
|
||||||
|
|
|
@ -7,6 +7,7 @@ from common.utils.file_utils import InvalidPath
|
||||||
from infection_monkey.payload.ransomware import ransomware_options
|
from infection_monkey.payload.ransomware import ransomware_options
|
||||||
from infection_monkey.payload.ransomware.ransomware_options import RansomwareOptions
|
from infection_monkey.payload.ransomware.ransomware_options import RansomwareOptions
|
||||||
|
|
||||||
|
EXTENSION = ".testext"
|
||||||
LINUX_DIR = "/tmp/test"
|
LINUX_DIR = "/tmp/test"
|
||||||
WINDOWS_DIR = "C:\\tmp\\test"
|
WINDOWS_DIR = "C:\\tmp\\test"
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ def options_from_island():
|
||||||
return {
|
return {
|
||||||
"encryption": {
|
"encryption": {
|
||||||
"enabled": None,
|
"enabled": None,
|
||||||
|
"file_extension": EXTENSION,
|
||||||
"directories": {
|
"directories": {
|
||||||
"linux_target_dir": LINUX_DIR,
|
"linux_target_dir": LINUX_DIR,
|
||||||
"windows_target_dir": WINDOWS_DIR,
|
"windows_target_dir": WINDOWS_DIR,
|
||||||
|
@ -41,6 +43,12 @@ def test_readme_enabled(enabled, options_from_island):
|
||||||
assert options.readme_enabled == enabled
|
assert options.readme_enabled == enabled
|
||||||
|
|
||||||
|
|
||||||
|
def test_file_extension(options_from_island):
|
||||||
|
options = RansomwareOptions(options_from_island)
|
||||||
|
|
||||||
|
assert options.file_extension == EXTENSION
|
||||||
|
|
||||||
|
|
||||||
def test_linux_target_dir(monkeypatch, options_from_island):
|
def test_linux_target_dir(monkeypatch, options_from_island):
|
||||||
monkeypatch.setattr(ransomware_options, "is_windows_os", lambda: False)
|
monkeypatch.setattr(ransomware_options, "is_windows_os", lambda: False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue