From 87332873d2ad0d52a0e88c21dfb682a43ee3f9dd Mon Sep 17 00:00:00 2001 From: Archer Bowen Date: Fri, 16 Aug 2024 15:47:41 +0100 Subject: [PATCH] #2689 Fixed issues with .rst (fixed terminal as well) --- .../system/applications/c2_suite.rst | 46 +++++++++++-------- .../system/services/terminal.rst | 17 +++---- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/docs/source/simulation_components/system/applications/c2_suite.rst b/docs/source/simulation_components/system/applications/c2_suite.rst index 1fa05466..034158d7 100644 --- a/docs/source/simulation_components/system/applications/c2_suite.rst +++ b/docs/source/simulation_components/system/applications/c2_suite.rst @@ -18,7 +18,7 @@ These two new classes give red agents a cyber realistic way of leveraging the ca For a more in-depth look at the command and control applications then please refer to the ``C2-E2E-Notebook``. ``C2 Server`` -"""""""""""" +""""""""""""" The C2 Server application is intended to represent the malicious infrastructure already under the control of an adversary. @@ -101,8 +101,8 @@ However, each host implements it's own receive methods. The sequence diagram below clarifies the functionality of both applications: -.. image:: ../_static/c2_sequence.png - :width: 500 +.. image:: ../../../../_static/c2_sequence.png + :width: 1000 :align: center @@ -114,38 +114,45 @@ Examples Python """""" .. code-block:: python - from primaite.simulator.system.applications.red_applications.c2.c2_beacon import C2Beacon - from primaite.simulator.system.applications.red_applications.c2.c2_server import C2Server - from primaite.simulator.system.applications.red_applications.c2.c2_server import C2Command + + from primaite.simulator.network.container import Network from primaite.simulator.network.hardware.nodes.host.computer import Computer - from primaite.simulator.system.services.database.database_service import DatabaseService + from primaite.simulator.network.hardware.nodes.network.switch import Switch from primaite.simulator.system.applications.database_client import DatabaseClient + from primaite.simulator.system.applications.red_applications.ransomware_script import RansomwareScript + from primaite.simulator.system.services.database.database_service import DatabaseService + from primaite.simulator.system.applications.red_applications.c2.c2_server import C2Command, C2Server + from primaite.simulator.system.applications.red_applications.c2.c2_beacon import C2Beacon + # Network Setup + network = Network() + switch = Switch(hostname="switch", start_up_duration=0, num_ports=4) switch.power_on() node_a = Computer(hostname="node_a", ip_address="192.168.0.10", subnet_mask="255.255.255.0", start_up_duration=0) node_a.power_on() - node_a.software_manager.install(software_class=C2Server) network.connect(node_a.network_interface[1], switch.network_interface[1]) node_b = Computer(hostname="node_b", ip_address="192.168.0.11", subnet_mask="255.255.255.0", start_up_duration=0) node_b.power_on() - node_b.software_manager.install(software_class=C2Beacon) - node_b.software_manager.install(software_class=DatabaseClient) + network.connect(node_b.network_interface[1], switch.network_interface[2]) node_c = Computer(hostname="node_c", ip_address="192.168.0.12", subnet_mask="255.255.255.0", start_up_duration=0) node_c.power_on() - node_c.software_manager.install(software_class=DatabaseServer) network.connect(node_c.network_interface[1], switch.network_interface[3]) + node_c.software_manager.install(software_class=DatabaseService) + node_b.software_manager.install(software_class=DatabaseClient) + node_b.software_manager.install(software_class=RansomwareScript) + node_a.software_manager.install(software_class=C2Server) + # C2 Application objects - c2_server_host: computer = simulation_testing_network.get_node_by_hostname("node_a") - c2_beacon_host: computer = simulation_testing_network.get_node_by_hostname("node_b") - + c2_server_host: Computer = network.get_node_by_hostname("node_a") + c2_beacon_host: Computer = network.get_node_by_hostname("node_b") c2_server: C2Server = c2_server_host.software_manager.software["C2Server"] c2_beacon: C2Beacon = c2_beacon_host.software_manager.software["C2Beacon"] @@ -182,7 +189,7 @@ Python "password": "admin", "ip_address": None, } - c2_server.send_command(given_command=C2Command.TERMINAL, command_options=ransomware_config) + c2_server.send_command(given_command=C2Command.TERMINAL, command_options=ransomware_installation_command) ransomware_config = {"server_ip_address": "192.168.0.12"} @@ -197,9 +204,8 @@ Python "password": "admin", "ip_address": None, "target_ip_address": "192.168.0.12", - "target_file_name": "database.db" - "target_folder_name": "database" - "exfiltration_folder_name": + "target_file_name": "database.db", + "target_folder_name": "database", } c2_server.send_command(given_command=C2Command.DATA_EXFILTRATION, command_options=data_exfil_options) @@ -254,7 +260,7 @@ C2 Beacon Configuration .. |SOFTWARE_NAME_BACKTICK| replace:: ``C2Beacon`` ``c2_server_ip_address`` -""""""""""""""""""""""" +"""""""""""""""""""""""" IP address of the ``C2Server`` that the C2 Beacon will use to establish connection. @@ -262,7 +268,7 @@ This must be a valid octet i.e. in the range of ``0.0.0.0`` and ``255.255.255.25 ``Keep Alive Frequency`` -""""""""""""""""""""""" +"""""""""""""""""""""""" How often should the C2 Beacon confirm it's connection in timesteps. diff --git a/docs/source/simulation_components/system/services/terminal.rst b/docs/source/simulation_components/system/services/terminal.rst index 5097f213..f982145d 100644 --- a/docs/source/simulation_components/system/services/terminal.rst +++ b/docs/source/simulation_components/system/services/terminal.rst @@ -5,26 +5,26 @@ .. _Terminal: Terminal -======== +######## The ``Terminal.py`` class provides a generic terminal simulation, by extending the base Service class within PrimAITE. The aim of this is to act as the primary entrypoint for Nodes within the environment. Overview --------- +======== The Terminal service uses Secure Socket (SSH) as the communication method between terminals. They operate on port 22, and are part of the services automatically installed on Nodes when they are instantiated. Key capabilities -================ +"""""""""""""""" - Ensures packets are matched to an existing session - Simulates common Terminal processes/commands. - Leverages the Service base class for install/uninstall, status tracking etc. Usage -===== +""""" - Pre-Installs on any `Node` (component with the exception of `Switches`). - Terminal Clients connect, execute commands and disconnect from remote nodes. @@ -32,7 +32,7 @@ Usage - Service runs on SSH port 22 by default. Implementation -============== +"""""""""""""" - Manages remote connections in a dictionary by session ID. - Processes commands, forwarding to the ``RequestManager`` or ``SessionManager`` where appropriate. @@ -67,7 +67,7 @@ Python terminal: Terminal = client.software_manager.software.get("Terminal") Creating Remote Terminal Connection -""""""""""""""""""""""""""" +""""""""""""""""""""""""""""""""""" .. code-block:: python @@ -93,7 +93,7 @@ Creating Remote Terminal Connection Executing a basic application install command -""""""""""""""""""""""""""""""""" +""""""""""""""""""""""""""""""""""""""""""""" .. code-block:: python @@ -121,7 +121,7 @@ Executing a basic application install command Creating a folder on a remote node -"""""""""""""""""""""""""""""""" +"""""""""""""""""""""""""""""""""" .. code-block:: python @@ -148,6 +148,7 @@ Creating a folder on a remote node Disconnect from Remote Node +""""""""""""""""""""""""""" .. code-block:: python