2023-08-17 15:32:12 +01:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2023-08-20 18:43:21 +01:00
"# Build a simulation using the Python API\n",
"\n",
"Currently, this notbook manipulates the simulation by directly placing objects inside of the attributes of the network and domain. It should be refactored when proper methods exist for adding these objects.\n"
2023-08-17 15:32:12 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import the Simulation class"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 1,
2023-08-17 15:32:12 +01:00
"metadata": {},
"outputs": [],
"source": [
"from primaite.simulator.sim_container import Simulation\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create an empty simulation. By default this has a network with no nodes or links, and a domain controller with no accounts.\n",
"\n",
"Let's use the simulation's `describe_state()` method to verify that it is empty."
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 2,
2023-08-17 15:32:12 +01:00
"metadata": {},
2024-04-09 13:26:35 +01:00
"outputs": [
{
"data": {
"text/plain": [
2024-04-09 13:34:57 +01:00
"{'uuid': '91c88b2a-caf1-47be-a394-d0c22e5110be',\n",
" 'network': {'uuid': 'a9121808-0401-460c-9833-23d4ba91e9bc',\n",
2024-04-09 13:26:35 +01:00
" 'nodes': {},\n",
" 'links': {}},\n",
2024-04-09 13:34:57 +01:00
" 'domain': {'uuid': '25fbe0e9-76e8-4fd7-ad22-da2d2b5a509d', 'accounts': {}}}"
2024-04-09 13:26:35 +01:00
]
},
2024-04-09 13:34:57 +01:00
"execution_count": 2,
2024-04-09 13:26:35 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
2023-08-17 15:32:12 +01:00
"source": [
"my_sim = Simulation()\n",
2023-08-23 14:41:30 +01:00
"net = my_sim.network\n",
2023-08-17 15:32:12 +01:00
"my_sim.describe_state()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add nodes"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 3,
2023-08-17 15:32:12 +01:00
"metadata": {},
"outputs": [],
"source": [
2024-04-09 13:26:35 +01:00
"from primaite.simulator.network.hardware.nodes.host.computer import Computer\n",
"from primaite.simulator.network.hardware.nodes.host.server import Server"
2023-08-17 15:32:12 +01:00
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 4,
2023-08-17 15:32:12 +01:00
"metadata": {},
2023-08-20 18:43:21 +01:00
"outputs": [],
2023-08-17 15:32:12 +01:00
"source": [
2024-04-09 13:26:35 +01:00
"my_pc = Computer(hostname=\"primaite_pc\", ip_address=\"192.168.1.10\", subnet_mask=\"255.255.255.0\")\n",
2023-08-23 14:41:30 +01:00
"net.add_node(my_pc)\n",
2024-04-09 13:26:35 +01:00
"my_server = Server(hostname=\"google_server\", ip_address=\"192.168.1.11\", subnet_mask=\"255.255.255.0\")\n",
2023-08-23 14:41:30 +01:00
"net.add_node(my_server)\n"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Connect the nodes"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 5,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
2024-04-09 13:26:35 +01:00
"from primaite.simulator.network.hardware.nodes.host.host_node import NIC\n",
"from primaite.simulator.network.hardware.nodes.network.switch import Switch\n"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 6,
2023-08-20 18:38:02 +01:00
"metadata": {},
2024-04-09 13:26:35 +01:00
"outputs": [
{
"data": {
"text/plain": [
2024-04-09 13:34:57 +01:00
"Link(uuid='2bd19485-0a6b-4878-978b-b082a672d9b9', endpoint_a=NIC(ip_address=IPv4Address('130.1.1.2'), subnet_mask=IPv4Address('255.255.255.0'), uuid='8a628493-83fb-44bf-a1b0-ef19e362ae5f', mac_address='44:89:a5:ce:7f:6f', speed=100, mtu=1500, enabled=False, port_num=2, port_name=None, pcap=None, nmne={}, wake_on_lan=False, gateway='130.1.1.255'), endpoint_b=SwitchPort(uuid='a049bb8f-53d3-4575-b325-dfb55516edcd', mac_address='aa:45:88:e1:13:e5', speed=100, mtu=1500, enabled=False, port_num=2, port_name=None, pcap=None, nmne={}), bandwidth=100.0, current_load=0.0)"
2024-04-09 13:26:35 +01:00
]
},
2024-04-09 13:34:57 +01:00
"execution_count": 6,
2024-04-09 13:26:35 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
2023-08-20 18:38:02 +01:00
"source": [
2024-04-09 13:26:35 +01:00
"my_switch = Switch(hostname=\"switch1\", num_ports=12)\n",
"net.add_node(my_switch)\n",
2023-08-20 18:38:02 +01:00
"\n",
"pc_nic = NIC(ip_address=\"130.1.1.1\", gateway=\"130.1.1.255\", subnet_mask=\"255.255.255.0\")\n",
"my_pc.connect_nic(pc_nic)\n",
"\n",
"server_nic = NIC(ip_address=\"130.1.1.2\", gateway=\"130.1.1.255\", subnet_mask=\"255.255.255.0\")\n",
"my_server.connect_nic(server_nic)\n",
"\n",
2024-04-09 13:26:35 +01:00
"net.connect(pc_nic, my_switch.network_interface[1])\n",
"net.connect(server_nic, my_switch.network_interface[2])\n"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add files and folders to nodes\n"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 7,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
2023-09-06 11:35:41 +01:00
"from primaite.simulator.file_system.file_type import FileType\n",
2024-04-09 13:26:35 +01:00
"from primaite.simulator.file_system.file_system import File\n",
"from primaite.simulator.system.core.sys_log import SysLog"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 8,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
"my_pc_downloads_folder = my_pc.file_system.create_folder(\"downloads\")\n",
2024-04-09 13:26:35 +01:00
"my_pc_downloads_folder.add_file(File(name=\"firefox_installer.zip\",folder_id=\"Test\", folder_name=\"downloads\" ,file_type=FileType.ZIP, sys_log=SysLog(hostname=\"Test\")))"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 9,
2023-08-20 18:38:02 +01:00
"metadata": {},
2024-04-09 13:26:35 +01:00
"outputs": [
{
"data": {
"text/plain": [
2024-04-09 13:34:57 +01:00
"File(uuid='3ceeded4-77b9-4a86-949c-73188d5f4c34', name='favicon.ico', health_status=<FileSystemItemHealthStatus.GOOD: 1>, visible_health_status=<FileSystemItemHealthStatus.GOOD: 1>, previous_hash=None, revealed_to_red=False, sys_log=<primaite.simulator.system.core.sys_log.SysLog object at 0x000002CCE8EDB790>, deleted=False, folder_id='cbbd3631-a915-400d-bc02-f31f72447ce5', folder_name='root', file_type=<FileType.UNKNOWN: 0>, sim_size=0, real=False, sim_path=None, sim_root=WindowsPath('C:/Projects/PrimAITE/simulation_output/2024-04-09_13-24-30/google_server/fs'), num_access=0, folder=Folder(uuid='cbbd3631-a915-400d-bc02-f31f72447ce5', name='root', health_status=<FileSystemItemHealthStatus.GOOD: 1>, visible_health_status=<FileSystemItemHealthStatus.GOOD: 1>, previous_hash=None, revealed_to_red=False, sys_log=<primaite.simulator.system.core.sys_log.SysLog object at 0x000002CCE8EDB790>, deleted=False, files={'3ceeded4-77b9-4a86-949c-73188d5f4c34': File(uuid='3ceeded4-77b9-4a86-949c-73188d5f4c34', name='favicon.ico', health_status=<FileSystemItemHealthStatus.GOOD: 1>, visible_health_status=<FileSystemItemHealthStatus.GOOD: 1>, previous_hash=None, revealed_to_red=False, sys_log=<primaite.simulator.system.core.sys_log.SysLog object at 0x000002CCE8EDB790>, deleted=False, folder_id='cbbd3631-a915-400d-bc02-f31f72447ce5', folder_name='root', file_type=<FileType.UNKNOWN: 0>, sim_size=0, real=False, sim_path=None, sim_root=WindowsPath('C:/Projects/PrimAITE/simulation_output/2024-04-09_13-24-30/google_server/fs'), num_access=0, folder=Folder(uuid='cbbd3631-a915-400d-bc02-f31f72447ce5', name='root', health_status=<FileSystemItemHealthStatus.GOOD: 1>, visible_health_status=<FileSystemItemHealthStatus.GOOD: 1>, previous_hash=None, revealed_to_red=False, sys_log=<primaite.simulator.system.core.sys_log.SysLog object at 0x000002CCE8EDB790>, deleted=False, files={...}, deleted_files={}, scan_duration=3, scan_countdown=0, red_scan_duration=3, red_scan_countdown=0, restore_duration=3, restore_countdown=0))}, deleted_files={}, scan_duration=3, scan_countdown=0, red_scan_duration=3, red_scan_countdown=0, restore_duration=3, restore_countdown=0))"
2024-04-09 13:26:35 +01:00
]
},
2024-04-09 13:34:57 +01:00
"execution_count": 9,
2024-04-09 13:26:35 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
2023-08-20 18:38:02 +01:00
"source": [
"my_server_folder = my_server.file_system.create_folder(\"static\")\n",
2023-09-06 11:35:41 +01:00
"my_server.file_system.create_file(\"favicon.ico\", file_type=FileType.PNG)"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add applications to nodes"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 10,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
2024-04-09 13:34:57 +01:00
"from pathlib import Path\n",
2023-08-20 18:38:02 +01:00
"from primaite.simulator.system.applications.application import Application, ApplicationOperatingState\n",
"from primaite.simulator.system.software import SoftwareHealthState, SoftwareCriticality\n",
"from primaite.simulator.network.transmission.transport_layer import Port\n",
2024-04-09 13:26:35 +01:00
"from primaite.simulator.network.transmission.network_layer import IPProtocol\n",
"from primaite.simulator.file_system.file_system import FileSystem\n",
2023-08-20 18:38:02 +01:00
"\n",
2023-08-20 18:43:21 +01:00
"# no applications exist yet so we will create our own.\n",
2023-08-20 18:38:02 +01:00
"class MSPaint(Application):\n",
" def describe_state(self):\n",
" return super().describe_state()"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 11,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
2024-04-09 13:26:35 +01:00
"mspaint = MSPaint(name = \"mspaint\", health_state_actual=SoftwareHealthState.GOOD, health_state_visible=SoftwareHealthState.GOOD, criticality=SoftwareCriticality.MEDIUM, port=Port.HTTP, protocol = IPProtocol.NONE,operating_state=ApplicationOperatingState.RUNNING,execution_control_status='manual', file_system=FileSystem(sys_log=SysLog(hostname=\"Test\"), sim_root=Path(__name__).parent),)"
2023-08-20 18:38:02 +01:00
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 12,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
"my_pc.applications[mspaint.uuid] = mspaint"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create a domain account"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 13,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
"from primaite.simulator.domain.account import Account, AccountType\n"
]
},
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 14,
2023-08-20 18:38:02 +01:00
"metadata": {},
"outputs": [],
"source": [
"acct = Account(username=\"admin\", password=\"admin12\", account_type=AccountType.USER)\n",
"my_sim.domain.accounts[acct.uuid] = acct"
]
},
2023-08-20 18:43:21 +01:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Verify that the state dictionary contains no non-serialisable objects."
]
},
2023-08-20 18:38:02 +01:00
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 15,
2023-08-20 18:38:02 +01:00
"metadata": {},
2024-04-09 13:26:35 +01:00
"outputs": [
{
"data": {
"text/plain": [
2024-04-09 13:34:57 +01:00
"{'uuid': '91c88b2a-caf1-47be-a394-d0c22e5110be',\n",
" 'network': {'uuid': 'a9121808-0401-460c-9833-23d4ba91e9bc',\n",
" 'nodes': {'primaite_pc': {'uuid': 'dd0e95be-2491-4d5b-8388-df3975a19e8a',\n",
2024-04-09 13:26:35 +01:00
" 'hostname': 'primaite_pc',\n",
" 'operating_state': 2,\n",
2024-04-09 13:34:57 +01:00
" 'NICs': {1: {'uuid': '279e2645-b680-4d2e-b13c-66d5cfacbd38',\n",
" 'mac_address': 'bd:76:20:24:cf:04',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {},\n",
" 'ip_address': '192.168.1.10',\n",
" 'subnet_mask': '255.255.255.0',\n",
" 'wake_on_lan': False},\n",
2024-04-09 13:34:57 +01:00
" 2: {'uuid': '40c0db02-4d14-4826-b49b-e6a521941cec',\n",
" 'mac_address': 'd8:b2:0c:af:3f:83',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {},\n",
" 'ip_address': '130.1.1.1',\n",
" 'subnet_mask': '255.255.255.0',\n",
" 'wake_on_lan': False}},\n",
2024-04-09 13:34:57 +01:00
" 'file_system': {'uuid': '91d3aed7-53c6-471f-b903-9889396be280',\n",
" 'folders': {'root': {'uuid': '81bdc04e-9a0d-4306-9a9c-ee926fff6df8',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'root',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
" 'files': {},\n",
" 'deleted_files': {}},\n",
2024-04-09 13:34:57 +01:00
" 'downloads': {'uuid': '56abdf27-b8d4-42f4-9b09-b7912db1c4f3',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'downloads',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
2024-04-09 13:34:57 +01:00
" 'files': {'firefox_installer.zip': {'uuid': '02236b61-14bb-46aa-9fd5-7174c0d7d730',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'firefox_installer.zip',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
" 'size': 1024000,\n",
" 'file_type': 'ZIP',\n",
" 'num_access': 0}},\n",
" 'deleted_files': {}}},\n",
" 'deleted_folders': {},\n",
" 'num_file_creations': 0,\n",
" 'num_file_deletions': 0},\n",
2024-04-09 13:34:57 +01:00
" 'applications': {'WebBrowser': {'uuid': 'a6a12776-e307-4d71-9e7a-d9ca97ecd6b0',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 80,\n",
" 'operating_state': 2,\n",
" 'execution_control_status': 'manual',\n",
" 'num_executions': 0,\n",
" 'groups': [],\n",
" 'history': []},\n",
2024-04-09 13:34:57 +01:00
" 'mspaint': {'uuid': 'efd34549-cc92-4474-80ab-5fb6c3159ff6',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 1,\n",
" 'health_state_visible': 1,\n",
" 'criticality': 3,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 80,\n",
" 'operating_state': 1,\n",
" 'execution_control_status': 'manual',\n",
" 'num_executions': 0,\n",
" 'groups': []}},\n",
2024-04-09 13:34:57 +01:00
" 'services': {'ARP': {'uuid': 'e61c25ff-a6c2-4eec-b031-131eaf33490c',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 219,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'ICMP': {'uuid': '74debeed-b758-41cb-bea2-51ac283e6ae2',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 0,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'DNSClient': {'uuid': '6680efc0-e005-41e8-bb49-39a0d9c4b118',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 53,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'FTPClient': {'uuid': '21b05ac9-e9b4-4c5c-a812-f6748e14d8c3',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 21,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'NTPClient': {'uuid': '7ab7c911-5037-4e82-b00c-be4f72c13aa7',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 123,\n",
" 'operating_state': 2}},\n",
" 'process': {},\n",
" 'revealed_to_red': False},\n",
2024-04-09 13:34:57 +01:00
" 'google_server': {'uuid': '42d61d8d-2493-4b8a-944f-7962abc9d20b',\n",
2024-04-09 13:26:35 +01:00
" 'hostname': 'google_server',\n",
" 'operating_state': 2,\n",
2024-04-09 13:34:57 +01:00
" 'NICs': {1: {'uuid': 'e384a4fc-754f-44a4-9158-c63f72f52f76',\n",
" 'mac_address': 'ea:5d:4f:10:b2:27',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {},\n",
" 'ip_address': '192.168.1.11',\n",
" 'subnet_mask': '255.255.255.0',\n",
" 'wake_on_lan': False},\n",
2024-04-09 13:34:57 +01:00
" 2: {'uuid': '8a628493-83fb-44bf-a1b0-ef19e362ae5f',\n",
" 'mac_address': '44:89:a5:ce:7f:6f',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {},\n",
" 'ip_address': '130.1.1.2',\n",
" 'subnet_mask': '255.255.255.0',\n",
" 'wake_on_lan': False}},\n",
2024-04-09 13:34:57 +01:00
" 'file_system': {'uuid': 'f25cee1f-2ebe-4fd3-8d5c-649b0d342b61',\n",
" 'folders': {'root': {'uuid': 'cbbd3631-a915-400d-bc02-f31f72447ce5',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'root',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
2024-04-09 13:34:57 +01:00
" 'files': {'favicon.ico': {'uuid': '3ceeded4-77b9-4a86-949c-73188d5f4c34',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'favicon.ico',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
" 'size': 0,\n",
" 'file_type': 'UNKNOWN',\n",
" 'num_access': 0}},\n",
" 'deleted_files': {}},\n",
2024-04-09 13:34:57 +01:00
" 'static': {'uuid': 'd8241ce0-f55e-43ec-bd68-741b79a9a565',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'static',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
" 'files': {},\n",
" 'deleted_files': {}}},\n",
" 'deleted_folders': {},\n",
" 'num_file_creations': 1,\n",
" 'num_file_deletions': 0},\n",
2024-04-09 13:34:57 +01:00
" 'applications': {'WebBrowser': {'uuid': '957d0049-e703-4882-8e57-b2ab4c79d458',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 80,\n",
" 'operating_state': 2,\n",
" 'execution_control_status': 'manual',\n",
" 'num_executions': 0,\n",
" 'groups': [],\n",
" 'history': []}},\n",
2024-04-09 13:34:57 +01:00
" 'services': {'ARP': {'uuid': '82ea1bcf-a0fe-418d-873e-5f075ebb4d3b',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 219,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'ICMP': {'uuid': 'bc084dc4-0a7d-4954-9e6e-54bed797e837',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 0,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'DNSClient': {'uuid': '5a9ecc18-71c0-4728-a9c6-e31b33529581',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 53,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'FTPClient': {'uuid': 'f0a411eb-5423-4c98-8689-d94af57deefc',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 21,\n",
" 'operating_state': 2},\n",
2024-04-09 13:34:57 +01:00
" 'NTPClient': {'uuid': 'd36f2c4f-af30-4618-ae8e-fe68c98e1382',\n",
2024-04-09 13:26:35 +01:00
" 'health_state_actual': 0,\n",
" 'health_state_visible': 0,\n",
" 'criticality': 1,\n",
" 'fixing_count': 0,\n",
" 'scanning_count': 0,\n",
" 'revealed_to_red': False,\n",
" 'installing_count': 0,\n",
" 'max_sessions': 100,\n",
" 'tcp': True,\n",
" 'udp': True,\n",
" 'port': 123,\n",
" 'operating_state': 2}},\n",
" 'process': {},\n",
" 'revealed_to_red': False},\n",
2024-04-09 13:34:57 +01:00
" 'switch1': {'uuid': 'a9e08b28-d1f4-4c34-b410-71333cd6b42b',\n",
2024-04-09 13:26:35 +01:00
" 'hostname': 'switch1',\n",
" 'operating_state': 2,\n",
2024-04-09 13:34:57 +01:00
" 'NICs': {1: {'uuid': '3546e960-30f8-49ee-95b9-57570b228333',\n",
" 'mac_address': '8d:d9:3e:f3:a3:ce',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 2: {'uuid': 'a049bb8f-53d3-4575-b325-dfb55516edcd',\n",
" 'mac_address': 'aa:45:88:e1:13:e5',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 3: {'uuid': '179c030c-d8fe-474b-a9d1-6c6bd6e6ca63',\n",
" 'mac_address': '10:d7:bc:39:4d:9d',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 4: {'uuid': '56f84a14-0a98-4bc5-983b-31900fc9a2c5',\n",
" 'mac_address': '61:62:18:cf:2a:ea',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 5: {'uuid': '0ff4b64e-be4c-473e-8dcd-b7a0078ff890',\n",
" 'mac_address': '21:5e:6b:1b:d0:bf',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 6: {'uuid': '0edf239b-bbb8-4076-ba85-cb07c65722d5',\n",
" 'mac_address': '40:58:ac:11:9c:1a',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 7: {'uuid': 'a7f578e5-a6f5-4cf8-abca-207e483637c2',\n",
" 'mac_address': 'e0:ef:90:e2:ce:b4',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 8: {'uuid': 'dc2069dd-ef3c-4e0b-81cb-a73caba917a8',\n",
" 'mac_address': '2c:2a:27:d6:9a:a8',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 9: {'uuid': 'afbc1a01-efdb-424c-9a7d-b3c3165f6d78',\n",
" 'mac_address': 'e0:f5:79:04:4f:2a',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 10: {'uuid': 'bdd805f4-a3dc-4a94-ba67-3a62b138f41c',\n",
" 'mac_address': '9a:20:3d:cb:a0:98',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 11: {'uuid': '19f6f871-cba9-423a-a1a5-6a0e347e98cb',\n",
" 'mac_address': '69:d9:8c:1d:a9:75',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 12: {'uuid': '5c2aa6f5-12ce-466b-b46b-95ec519a5f47',\n",
" 'mac_address': 'db:7e:8c:91:1b:3f',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}}},\n",
2024-04-09 13:34:57 +01:00
" 'file_system': {'uuid': '91dea1d3-3947-49b9-a691-750bc25bbb9c',\n",
" 'folders': {'root': {'uuid': 'b7ebbf43-d86f-43d3-bbc7-f6b197af40b9',\n",
2024-04-09 13:26:35 +01:00
" 'name': 'root',\n",
" 'health_status': 1,\n",
" 'visible_status': 1,\n",
" 'previous_hash': None,\n",
" 'revealed_to_red': False,\n",
" 'files': {},\n",
" 'deleted_files': {}}},\n",
" 'deleted_folders': {},\n",
" 'num_file_creations': 0,\n",
" 'num_file_deletions': 0},\n",
" 'applications': {},\n",
" 'services': {},\n",
" 'process': {},\n",
" 'revealed_to_red': False,\n",
2024-04-09 13:34:57 +01:00
" 'ports': {1: {'uuid': '3546e960-30f8-49ee-95b9-57570b228333',\n",
" 'mac_address': '8d:d9:3e:f3:a3:ce',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 2: {'uuid': 'a049bb8f-53d3-4575-b325-dfb55516edcd',\n",
" 'mac_address': 'aa:45:88:e1:13:e5',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 3: {'uuid': '179c030c-d8fe-474b-a9d1-6c6bd6e6ca63',\n",
" 'mac_address': '10:d7:bc:39:4d:9d',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 4: {'uuid': '56f84a14-0a98-4bc5-983b-31900fc9a2c5',\n",
" 'mac_address': '61:62:18:cf:2a:ea',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 5: {'uuid': '0ff4b64e-be4c-473e-8dcd-b7a0078ff890',\n",
" 'mac_address': '21:5e:6b:1b:d0:bf',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 6: {'uuid': '0edf239b-bbb8-4076-ba85-cb07c65722d5',\n",
" 'mac_address': '40:58:ac:11:9c:1a',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 7: {'uuid': 'a7f578e5-a6f5-4cf8-abca-207e483637c2',\n",
" 'mac_address': 'e0:ef:90:e2:ce:b4',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 8: {'uuid': 'dc2069dd-ef3c-4e0b-81cb-a73caba917a8',\n",
" 'mac_address': '2c:2a:27:d6:9a:a8',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 9: {'uuid': 'afbc1a01-efdb-424c-9a7d-b3c3165f6d78',\n",
" 'mac_address': 'e0:f5:79:04:4f:2a',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 10: {'uuid': 'bdd805f4-a3dc-4a94-ba67-3a62b138f41c',\n",
" 'mac_address': '9a:20:3d:cb:a0:98',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 11: {'uuid': '19f6f871-cba9-423a-a1a5-6a0e347e98cb',\n",
" 'mac_address': '69:d9:8c:1d:a9:75',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}},\n",
2024-04-09 13:34:57 +01:00
" 12: {'uuid': '5c2aa6f5-12ce-466b-b46b-95ec519a5f47',\n",
" 'mac_address': 'db:7e:8c:91:1b:3f',\n",
2024-04-09 13:26:35 +01:00
" 'speed': 100,\n",
" 'mtu': 1500,\n",
" 'enabled': False,\n",
" 'nmne': {}}},\n",
" 'num_ports': 12,\n",
" 'mac_address_table': {}}},\n",
2024-04-09 13:34:57 +01:00
" 'links': {'primaite_pc:eth-2<->switch1:eth-1': {'uuid': '405f3032-6f5d-427f-b42e-5eee4cdc3a7c',\n",
" 'endpoint_a': '40c0db02-4d14-4826-b49b-e6a521941cec',\n",
" 'endpoint_b': '3546e960-30f8-49ee-95b9-57570b228333',\n",
2024-04-09 13:26:35 +01:00
" 'bandwidth': 100.0,\n",
" 'current_load': 0.0,\n",
" 'hostname_a': 'primaite_pc',\n",
" 'hostname_b': 'switch1',\n",
" 'port_a': 2,\n",
" 'port_b': 1},\n",
2024-04-09 13:34:57 +01:00
" 'google_server:eth-2<->switch1:eth-2': {'uuid': '2bd19485-0a6b-4878-978b-b082a672d9b9',\n",
" 'endpoint_a': '8a628493-83fb-44bf-a1b0-ef19e362ae5f',\n",
" 'endpoint_b': 'a049bb8f-53d3-4575-b325-dfb55516edcd',\n",
2024-04-09 13:26:35 +01:00
" 'bandwidth': 100.0,\n",
" 'current_load': 0.0,\n",
" 'hostname_a': 'google_server',\n",
" 'hostname_b': 'switch1',\n",
" 'port_a': 2,\n",
" 'port_b': 2}}},\n",
2024-04-09 13:34:57 +01:00
" 'domain': {'uuid': '25fbe0e9-76e8-4fd7-ad22-da2d2b5a509d',\n",
" 'accounts': {'admin': {'uuid': '78783f13-6149-47b3-9b9d-f98d658bf54a',\n",
2024-04-09 13:26:35 +01:00
" 'num_logons': 0,\n",
" 'num_logoffs': 0,\n",
" 'num_group_changes': 0,\n",
" 'username': 'admin',\n",
" 'password': 'admin12',\n",
" 'account_type': 2,\n",
" 'enabled': True}}}}"
]
},
2024-04-09 13:34:57 +01:00
"execution_count": 15,
2024-04-09 13:26:35 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
2023-08-20 18:38:02 +01:00
"source": [
2023-08-17 15:32:12 +01:00
"my_sim.describe_state()"
]
},
2023-08-20 18:38:02 +01:00
{
"cell_type": "code",
2024-04-09 13:34:57 +01:00
"execution_count": 16,
2023-08-20 18:38:02 +01:00
"metadata": {},
2024-04-09 13:26:35 +01:00
"outputs": [
{
"data": {
"text/plain": [
2024-04-09 13:34:57 +01:00
"'{\"uuid\": \"91c88b2a-caf1-47be-a394-d0c22e5110be\", \"network\": {\"uuid\": \"a9121808-0401-460c-9833-23d4ba91e9bc\", \"nodes\": {\"primaite_pc\": {\"uuid\": \"dd0e95be-2491-4d5b-8388-df3975a19e8a\", \"hostname\": \"primaite_pc\", \"operating_state\": 2, \"NICs\": {\"1\": {\"uuid\": \"279e2645-b680-4d2e-b13c-66d5cfacbd38\", \"mac_address\": \"bd:76:20:24:cf:04\", \"speed\": 100, \"mtu\": 1500, \"enabled\": false, \"nmne\": {}, \"ip_address\": \"192.168.1.10\", \"subnet_mask\": \"255.255.255.0\", \"wake_on_lan\": false}, \"2\": {\"uuid\": \"40c0db02-4d14-4826-b49b-e6a521941cec\", \"mac_address\": \"d8:b2:0c:af:3f:83\", \"speed\": 100, \"mtu\": 1500, \"enabled\": false, \"nmne\": {}, \"ip_address\": \"130.1.1.1\", \"subnet_mask\": \"255.255.255.0\", \"wake_on_lan\": false}}, \"file_system\": {\"uuid\": \"91d3aed7-53c6-471f-b903-9889396be280\", \"folders\": {\"root\": {\"uuid\": \"81bdc04e-9a0d-4306-9a9c-ee926fff6df8\", \"name\": \"root\", \"health_status\": 1, \"visible_status\": 1, \"previous_hash\": null, \"revealed_to_red\": false, \"files\": {}, \"deleted_files\": {}}, \"downloads\": {\"uuid\": \"56abdf27-b8d4-42f4-9b09-b7912db1c4f3\", \"name\": \"downloads\", \"health_status\": 1, \"visible_status\": 1, \"previous_hash\": null, \"revealed_to_red\": false, \"files\": {\"firefox_installer.zip\": {\"uuid\": \"02236b61-14bb-46aa-9fd5-7174c0d7d730\", \"name\": \"firefox_installer.zip\", \"health_status\": 1, \"visible_status\": 1, \"previous_hash\": null, \"revealed_to_red\": false, \"size\": 1024000, \"file_type\": \"ZIP\", \"num_access\": 0}}, \"deleted_files\": {}}}, \"deleted_folders\": {}, \"num_file_creations\": 0, \"num_file_deletions\": 0}, \"applications\": {\"WebBrowser\": {\"uuid\": \"a6a12776-e307-4d71-9e7a-d9ca97ecd6b0\", \"health_state_actual\": 0, \"health_state_visible\": 0, \"criticality\": 1, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 100, \"tcp\": true, \"udp\": true, \"port\": 80, \"operating_state\": 2, \"execution_control_status\": \"manual\", \"num_executions\": 0, \"groups\": [], \"history\": []}, \"mspaint\": {\"uuid\": \"efd34549-cc92-4474-80ab-5fb6c3159ff6\", \"health_state_actual\": 1, \"health_state_visible\": 1, \"criticality\": 3, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 100, \"tcp\": true, \"udp\": true, \"port\": 80, \"operating_state\": 1, \"execution_control_status\": \"manual\", \"num_executions\": 0, \"groups\": []}}, \"services\": {\"ARP\": {\"uuid\": \"e61c25ff-a6c2-4eec-b031-131eaf33490c\", \"health_state_actual\": 0, \"health_state_visible\": 0, \"criticality\": 1, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 100, \"tcp\": true, \"udp\": true, \"port\": 219, \"operating_state\": 2}, \"ICMP\": {\"uuid\": \"74debeed-b758-41cb-bea2-51ac283e6ae2\", \"health_state_actual\": 0, \"health_state_visible\": 0, \"criticality\": 1, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 100, \"tcp\": true, \"udp\": true, \"port\": 0, \"operating_state\": 2}, \"DNSClient\": {\"uuid\": \"6680efc0-e005-41e8-bb49-39a0d9c4b118\", \"health_state_actual\": 0, \"health_state_visible\": 0, \"criticality\": 1, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 100, \"tcp\": true, \"udp\": true, \"port\": 53, \"operating_state\": 2}, \"FTPClient\": {\"uuid\": \"21b05ac9-e9b4-4c5c-a812-f6748e14d8c3\", \"health_state_actual\": 0, \"health_state_visible\": 0, \"criticality\": 1, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 100, \"tcp\": true, \"udp\": true, \"port\": 21, \"operating_state\": 2}, \"NTPClient\": {\"uuid\": \"7ab7c911-5037-4e82-b00c-be4f72c13aa7\", \"health_state_actual\": 0, \"health_state_visible\": 0, \"criticality\": 1, \"fixing_count\": 0, \"scanning_count\": 0, \"revealed_to_r
2024-04-09 13:26:35 +01:00
]
},
2024-04-09 13:34:57 +01:00
"execution_count": 16,
2024-04-09 13:26:35 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
2023-08-20 18:38:02 +01:00
"source": [
2023-08-20 18:43:21 +01:00
"import json\n",
"json.dumps(my_sim.describe_state())"
2023-08-20 18:38:02 +01:00
]
2023-08-17 15:32:12 +01:00
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2024-04-09 13:26:35 +01:00
"version": "3.10.11"
2023-08-17 15:32:12 +01:00
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}