forked from p15670423/monkey
Common: Create CustomPBAConfiguration using pydantic
This commit is contained in:
parent
765ce858fb
commit
554a180fbd
|
@ -1,6 +1,12 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Dict, Tuple
|
from typing import Dict, Tuple
|
||||||
|
|
||||||
|
from pydantic import validator
|
||||||
|
|
||||||
|
from common.base_models import MutableInfectionMonkeyBaseModel
|
||||||
|
|
||||||
|
from .validators import validate_linux_filename, validate_windows_filename
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class CustomPBAConfiguration:
|
class CustomPBAConfiguration:
|
||||||
|
@ -25,6 +31,38 @@ class CustomPBAConfiguration:
|
||||||
windows_filename: str
|
windows_filename: str
|
||||||
|
|
||||||
|
|
||||||
|
class Pydantic___CustomPBAConfiguration(MutableInfectionMonkeyBaseModel):
|
||||||
|
"""
|
||||||
|
A configuration for custom post-breach actions
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
:param linux_command: Command to run on Linux victim machines. If a file is uploaded,
|
||||||
|
use this field to change its permissions, execute it, and/or delete it
|
||||||
|
Example: `chmod +x file.sh; ./file.sh; rm file.sh`
|
||||||
|
:param linux_filename: Name of the file to upload on Linux victim machines
|
||||||
|
:param windows_command: Command to run on Windows victim machines. If a file is uploaded,
|
||||||
|
use this field to change its permissions, execute it, and/or delete
|
||||||
|
it
|
||||||
|
Example: `file.bat & del file.bat`
|
||||||
|
:param windows_filename: Name of the file to upload on Windows victim machines
|
||||||
|
"""
|
||||||
|
|
||||||
|
linux_command: str
|
||||||
|
linux_filename: str
|
||||||
|
windows_command: str
|
||||||
|
windows_filename: str
|
||||||
|
|
||||||
|
@validator("linux_filename")
|
||||||
|
def linux_filename_valid(cls, filename):
|
||||||
|
validate_linux_filename(filename)
|
||||||
|
return filename
|
||||||
|
|
||||||
|
@validator("windows_filename")
|
||||||
|
def windows_filename_valid(cls, filename):
|
||||||
|
validate_windows_filename(filename)
|
||||||
|
return filename
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class PluginConfiguration:
|
class PluginConfiguration:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue