forked from p15670423/monkey
Island: Add Machine.island field
This commit is contained in:
parent
aed9022a7a
commit
a323441ffe
|
@ -20,6 +20,9 @@ class Machine(MutableInfectionMonkeyBaseModel):
|
|||
hardware_id: Optional[HardwareID]
|
||||
"""An identifier generated by the agent that uniquely identifies a machine"""
|
||||
|
||||
island: bool = Field(default=False, allow_mutation=False)
|
||||
"""Whether or not the machine is an island (C&C server)"""
|
||||
|
||||
network_interfaces: Sequence[IPv4Interface] = tuple()
|
||||
"""The machine's networking interfaces"""
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ MACHINE_OBJECT_DICT = MappingProxyType(
|
|||
{
|
||||
"id": 1,
|
||||
"hardware_id": uuid.getnode(),
|
||||
"island": True,
|
||||
"network_interfaces": [IPv4Interface("10.0.0.1/24"), IPv4Interface("192.168.5.32/16")],
|
||||
"operating_system": OperatingSystem.WINDOWS,
|
||||
"operating_system_version": "eXtra Problems",
|
||||
|
@ -23,6 +24,7 @@ MACHINE_SIMPLE_DICT = MappingProxyType(
|
|||
{
|
||||
"id": 1,
|
||||
"hardware_id": uuid.getnode(),
|
||||
"island": True,
|
||||
"network_interfaces": ["10.0.0.1/24", "192.168.5.32/16"],
|
||||
"operating_system": "windows",
|
||||
"operating_system_version": "eXtra Problems",
|
||||
|
@ -52,6 +54,7 @@ def test_to_dict():
|
|||
[
|
||||
("id", "not-an-int"),
|
||||
("hardware_id", "not-an-int"),
|
||||
("island", "not-a-bool"),
|
||||
("network_interfaces", "not-a-list"),
|
||||
("operating_system", 2.1),
|
||||
("operating_system", "bsd"),
|
||||
|
@ -130,6 +133,21 @@ def test_hardware_id_default():
|
|||
assert m.hardware_id is None
|
||||
|
||||
|
||||
def test_island_immutable():
|
||||
m = Machine(**MACHINE_OBJECT_DICT)
|
||||
with pytest.raises(TypeError):
|
||||
m.island = True
|
||||
|
||||
|
||||
def test_island_default():
|
||||
missing_island_dict = MACHINE_OBJECT_DICT.copy()
|
||||
del missing_island_dict["island"]
|
||||
|
||||
m = Machine(**missing_island_dict)
|
||||
|
||||
assert m.island is False
|
||||
|
||||
|
||||
def test_network_interfaces_set_valid_value():
|
||||
m = Machine(**MACHINE_OBJECT_DICT)
|
||||
|
||||
|
|
Loading…
Reference in New Issue