2023-03-28 17:33:34 +01:00
|
|
|
# Crown Copyright (C) Dstl 2022. DEFCON 703. Shared in confidence.
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Enumerations for APE."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-06-19 20:27:08 +01:00
|
|
|
from enum import Enum, IntEnum
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class NodeType(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Node type enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
CCTV = 1
|
|
|
|
|
SWITCH = 2
|
|
|
|
|
COMPUTER = 3
|
|
|
|
|
LINK = 4
|
|
|
|
|
MONITOR = 5
|
|
|
|
|
PRINTER = 6
|
|
|
|
|
LOP = 7
|
|
|
|
|
RTU = 8
|
|
|
|
|
ACTUATOR = 9
|
|
|
|
|
SERVER = 10
|
|
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class Priority(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Node priority enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
P1 = 1
|
|
|
|
|
P2 = 2
|
|
|
|
|
P3 = 3
|
|
|
|
|
P4 = 4
|
|
|
|
|
P5 = 5
|
|
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class HardwareState(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Node hardware state enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-06-20 16:06:55 +01:00
|
|
|
NONE = 0
|
2023-03-28 17:33:34 +01:00
|
|
|
ON = 1
|
|
|
|
|
OFF = 2
|
|
|
|
|
RESETTING = 3
|
2023-06-02 14:54:23 +01:00
|
|
|
SHUTTING_DOWN = 4
|
|
|
|
|
BOOTING = 5
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class SoftwareState(Enum):
|
|
|
|
|
"""Software or Service state enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-06-20 16:06:55 +01:00
|
|
|
NONE = 0
|
2023-03-28 17:33:34 +01:00
|
|
|
GOOD = 1
|
|
|
|
|
PATCHING = 2
|
|
|
|
|
COMPROMISED = 3
|
|
|
|
|
OVERWHELMED = 4
|
|
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class NodePOLType(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Node Pattern of Life type enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-05-26 14:29:02 +01:00
|
|
|
NONE = 0
|
2023-03-28 17:33:34 +01:00
|
|
|
OPERATING = 1
|
|
|
|
|
OS = 2
|
|
|
|
|
SERVICE = 3
|
2023-04-06 11:04:09 +01:00
|
|
|
FILE = 4
|
|
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class NodePOLInitiator(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Node Pattern of Life initiator enumeration."""
|
2023-04-06 11:04:09 +01:00
|
|
|
|
|
|
|
|
DIRECT = 1
|
|
|
|
|
IER = 2
|
|
|
|
|
SERVICE = 3
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class Protocol(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Service protocol enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
LDAP = 0
|
|
|
|
|
FTP = 1
|
|
|
|
|
HTTPS = 2
|
|
|
|
|
SMTP = 3
|
|
|
|
|
RTP = 4
|
|
|
|
|
IPP = 5
|
|
|
|
|
TCP = 6
|
|
|
|
|
NONE = 7
|
|
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-06-13 09:42:54 +01:00
|
|
|
class SessionType(Enum):
|
2023-06-19 21:53:25 +01:00
|
|
|
"""The type of PrimAITE Session to be run."""
|
2023-06-30 09:08:13 +01:00
|
|
|
|
2023-06-28 12:01:01 +01:00
|
|
|
TRAIN = 1
|
|
|
|
|
"Train an agent"
|
|
|
|
|
EVAL = 2
|
|
|
|
|
"Evaluate an agent"
|
|
|
|
|
TRAIN_EVAL = 3
|
|
|
|
|
"Train then evaluate an agent"
|
2023-06-13 09:42:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AgentFramework(Enum):
|
2023-06-20 16:06:55 +01:00
|
|
|
"""The agent algorithm framework/package."""
|
2023-06-30 09:08:13 +01:00
|
|
|
|
2023-06-20 16:06:55 +01:00
|
|
|
CUSTOM = 0
|
2023-06-18 22:40:56 +01:00
|
|
|
"Custom Agent"
|
2023-06-13 09:42:54 +01:00
|
|
|
SB3 = 1
|
2023-06-18 22:40:56 +01:00
|
|
|
"Stable Baselines3"
|
2023-06-13 09:42:54 +01:00
|
|
|
RLLIB = 2
|
2023-06-18 22:40:56 +01:00
|
|
|
"Ray RLlib"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeepLearningFramework(Enum):
|
2023-06-20 16:06:55 +01:00
|
|
|
"""The deep learning framework."""
|
2023-06-30 09:08:13 +01:00
|
|
|
|
2023-06-18 22:40:56 +01:00
|
|
|
TF = "tf"
|
|
|
|
|
"Tensorflow"
|
|
|
|
|
TF2 = "tf2"
|
|
|
|
|
"Tensorflow 2.x"
|
|
|
|
|
TORCH = "torch"
|
|
|
|
|
"PyTorch"
|
2023-06-13 09:42:54 +01:00
|
|
|
|
|
|
|
|
|
2023-06-20 16:06:55 +01:00
|
|
|
class AgentIdentifier(Enum):
|
|
|
|
|
"""The Red Agent algo/class."""
|
2023-06-30 09:08:13 +01:00
|
|
|
|
2023-06-13 09:42:54 +01:00
|
|
|
A2C = 1
|
2023-06-18 22:40:56 +01:00
|
|
|
"Advantage Actor Critic"
|
2023-06-13 09:42:54 +01:00
|
|
|
PPO = 2
|
2023-06-18 22:40:56 +01:00
|
|
|
"Proximal Policy Optimization"
|
2023-06-13 09:42:54 +01:00
|
|
|
HARDCODED = 3
|
2023-06-20 16:06:55 +01:00
|
|
|
"The Hardcoded agents"
|
|
|
|
|
DO_NOTHING = 4
|
|
|
|
|
"The DoNothing agents"
|
|
|
|
|
RANDOM = 5
|
|
|
|
|
"The RandomAgent"
|
|
|
|
|
DUMMY = 6
|
|
|
|
|
"The DummyAgent"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HardCodedAgentView(Enum):
|
|
|
|
|
"""The view the deterministic hard-coded agent has of the environment."""
|
2023-06-30 09:08:13 +01:00
|
|
|
|
2023-06-20 16:06:55 +01:00
|
|
|
BASIC = 1
|
|
|
|
|
"The current observation space only"
|
|
|
|
|
FULL = 2
|
|
|
|
|
"Full environment view with actions taken and reward feedback"
|
2023-06-13 09:42:54 +01:00
|
|
|
|
|
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class ActionType(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""Action type enumeration."""
|
2023-03-28 17:33:34 +01:00
|
|
|
|
|
|
|
|
NODE = 0
|
|
|
|
|
ACL = 1
|
2023-06-02 09:51:15 +01:00
|
|
|
ANY = 2
|
2023-03-28 17:33:34 +01:00
|
|
|
|
2023-05-25 11:42:19 +01:00
|
|
|
|
2023-05-30 15:11:41 +01:00
|
|
|
class ObservationType(Enum):
|
|
|
|
|
"""Observation type enumeration."""
|
|
|
|
|
|
|
|
|
|
BOX = 0
|
|
|
|
|
MULTIDISCRETE = 1
|
|
|
|
|
|
|
|
|
|
|
2023-05-25 21:03:11 +01:00
|
|
|
class FileSystemState(Enum):
|
2023-05-25 11:42:19 +01:00
|
|
|
"""File System State."""
|
2023-04-06 11:04:09 +01:00
|
|
|
|
|
|
|
|
GOOD = 1
|
|
|
|
|
CORRUPT = 2
|
|
|
|
|
DESTROYED = 3
|
|
|
|
|
REPAIRING = 4
|
|
|
|
|
RESTORING = 5
|
2023-05-26 10:17:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class NodeHardwareAction(Enum):
|
|
|
|
|
"""Node hardware action."""
|
|
|
|
|
|
|
|
|
|
NONE = 0
|
|
|
|
|
ON = 1
|
|
|
|
|
OFF = 2
|
|
|
|
|
RESET = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NodeSoftwareAction(Enum):
|
|
|
|
|
"""Node software action."""
|
|
|
|
|
|
|
|
|
|
NONE = 0
|
|
|
|
|
PATCHING = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LinkStatus(Enum):
|
|
|
|
|
"""Link traffic status."""
|
|
|
|
|
|
|
|
|
|
NONE = 0
|
|
|
|
|
LOW = 1
|
|
|
|
|
MEDIUM = 2
|
|
|
|
|
HIGH = 3
|
|
|
|
|
OVERLOAD = 4
|
2023-06-09 15:17:20 +01:00
|
|
|
|
|
|
|
|
|
2023-06-30 17:09:50 +01:00
|
|
|
class SB3OutputVerboseLevel(IntEnum):
|
|
|
|
|
"""The Stable Baselines3 learn/eval output verbosity level."""
|
2023-06-30 09:08:13 +01:00
|
|
|
|
2023-06-19 20:27:08 +01:00
|
|
|
NONE = 0
|
|
|
|
|
INFO = 1
|
2023-06-30 17:09:50 +01:00
|
|
|
DEBUG = 2
|
2023-07-05 11:34:15 +01:00
|
|
|
|
|
|
|
|
|
2023-06-09 15:45:13 +01:00
|
|
|
class RulePermissionType(Enum):
|
2023-07-05 09:08:03 +01:00
|
|
|
"""Any firewall rule type."""
|
2023-06-09 15:17:20 +01:00
|
|
|
|
2023-07-05 09:08:03 +01:00
|
|
|
NA = 0
|
|
|
|
|
DENY = 1
|
|
|
|
|
ALLOW = 2
|