|
|
|
|
@@ -38,7 +38,7 @@
|
|
|
|
|
"\n",
|
|
|
|
|
"This notebook uses the same network setup as UC2. Please refer to the main [UC2-E2E-Demo notebook for further reference](./Data-Manipulation-E2E-Demonstration.ipynb).\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"However, this notebook will replaces with the red agent used in UC2 with a custom proxy red agent built for this notebook."
|
|
|
|
|
"However, this notebook replaces the red agent used in UC2 with a custom proxy red agent built for this notebook."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -188,11 +188,10 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"## **Notebook Setup** | Network Prerequisites\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Before the Red Agent is able to perform any C2 specific actions, the C2 Server needs to be installed and run before the episode begins.\n",
|
|
|
|
|
"Before the Red Agent is able to perform any C2 specific actions, the C2 Server needs to be installed and run before the Red Agent can perform any C2 specific action.\n",
|
|
|
|
|
"This is because in higher fidelity environments (and the real-world) a C2 server would not be accessible by a private network blue agent and the C2 Server would already be in place before the an adversary (Red Agent) starts.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is because higher fidelity environments (and the real-world) a C2 server would not be accessible by private network blue agent and the C2 Server would already be in place before the an adversary (Red Agent) before the narrative of the use case.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The cells below installs and runs the C2 Server on the client_1 directly via the simulation API."
|
|
|
|
|
"The cells below install and runs the C2 Server on client_1 directly via the simulation API."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -214,9 +213,9 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"## **Command and Control** | C2 Beacon Actions\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Before any C2 Server commands is able to accept any commands, it must first establish connection with a C2 beacon.\n",
|
|
|
|
|
"Before a C2 Server can accept any commands it must first establish connection with a C2 Beacon.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"A red agent is able to install, configure and establish a C2 beacon at any point of an episode. The code cells below demonstrate what actions and option parameters are needed to perform this."
|
|
|
|
|
"A red agent is able to install, configure and establish a C2 beacon at any point in an episode. The code cells below demonstrate the actions and option parameters that are needed to perform this."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -225,7 +224,7 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Beacon Actions | NODE_APPLICATION_INSTALL\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The custom proxy red agent defined at the start of this notebook has been configured to install the C2 Beacon as action ``1`` on it's action map. \n",
|
|
|
|
|
"The custom proxy red agent defined at the start of this notebook has been configured to install the C2 Beacon as action ``1`` in it's action map. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
@@ -268,9 +267,9 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Beacon Actions | CONFIGURE_C2_BEACON \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The custom proxy red agent defined at the start of this notebook can configure the C2 Beacon via action ``2`` on it's action map. \n",
|
|
|
|
|
"The custom proxy red agent defined at the start of this notebook can configure the C2 Beacon via action ``2`` in it's action map. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action:\n",
|
|
|
|
|
"The yaml snippet below shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"```yaml\n",
|
|
|
|
|
" action_space:\n",
|
|
|
|
|
@@ -315,9 +314,9 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Beacon Actions | NODE_APPLICATION_EXECUTE\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The final action is ``NODE_APPLICATION_EXECUTE`` which is used to establish connection for the C2 application. This action can be called by the Red Agent via action ``3`` on it's action map. \n",
|
|
|
|
|
"The final action is ``NODE_APPLICATION_EXECUTE`` which is used to establish a connection for the C2 application. This action can be called by the Red Agent via action ``3`` in it's action map. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action:\n",
|
|
|
|
|
"The yaml snippet below shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"```yaml\n",
|
|
|
|
|
" action_space:\n",
|
|
|
|
|
@@ -370,7 +369,7 @@
|
|
|
|
|
"Once the C2 suite has been successfully established, the C2 Server based actions become available to the Red Agent. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This next section will demonstrate the different actions that become available to a red agent after establishing C2 connection:"
|
|
|
|
|
"This next section will demonstrate the different actions that become available to a red agent after establishing a C2 connection:"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -379,15 +378,15 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Server Actions | C2_SERVER_TERMINAL_COMMAND\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The C2 Server's terminal action is indexed at ``4`` on the custom red agent action map. \n",
|
|
|
|
|
"The C2 Server's terminal action: ``C2_SERVER_TERMINAL_COMMAND`` is indexed at ``4`` in it's action map. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This action leverages the terminal service that is installed by default on all nodes to grant red agents a lot more configurability. If you're unfamiliar with terminals then it's recommended that you refer to the ``Terminal Processing`` notebook.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"It's worth noting that an additional benefit that a red agent has when using terminal via the C2 Server is that you can execute multiple commands in one action. \n",
|
|
|
|
|
"It's worth noting that an additional benefit a red agent has when using the terminal service via the C2 Server is that you can execute multiple commands in one action. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"In this notebook, the ``C2_SERVER_TERMINAL_COMMAND`` is used to install a RansomwareScript application on the ``web_server`` node.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action:\n",
|
|
|
|
|
"The yaml snippet below shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"``` yaml\n",
|
|
|
|
|
" action_space:\n",
|
|
|
|
|
@@ -444,11 +443,11 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Server Actions | C2_SERVER_RANSOMWARE_CONFIGURE\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Another action that the C2 Server grants is the ability for a Red Agent to configure ransomware via the C2 Server. \n",
|
|
|
|
|
"Another action the C2 Server grants is the ability for a Red Agent to configure the RansomwareScript via the C2 Server rather than the note directly.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This action is indexed as action ``5``.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action:\n",
|
|
|
|
|
"The yaml snippet below shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"``` yaml\n",
|
|
|
|
|
" action_space:\n",
|
|
|
|
|
@@ -500,11 +499,11 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Server Actions | C2_SERVER_DATA_EXFILTRATE\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The second to last action available is the ``C2_SERVER_DATA_EXFILTRATE`` which can be used to exfiltrate a target file on a remote node to the C2 Beacon & Server's host file system via the ``FTP`` services.\n",
|
|
|
|
|
"The second to last action available is the ``C2_SERVER_DATA_EXFILTRATE`` which is indexed as action ``6`` in the action map.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This action is indexed as action ``6``..\n",
|
|
|
|
|
"This action can be used to exfiltrate a target file on a remote node to the C2 Beacon and the C2 Server's host file system via the ``FTP`` services.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"``` yaml\n",
|
|
|
|
|
" action_space:\n",
|
|
|
|
|
@@ -532,8 +531,7 @@
|
|
|
|
|
" username: \"admin\",\n",
|
|
|
|
|
" password: \"admin\"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"```\n",
|
|
|
|
|
"\n"
|
|
|
|
|
"```"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -571,11 +569,11 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | C2 Server Actions | C2_SERVER_RANSOMWARE_LAUNCH\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Finally, to the ransomware configuration action, there is also the ``C2_SERVER_RANSOMWARE_LAUNCH`` which quite simply launches the ransomware script installed on the same node as the C2 beacon.\n",
|
|
|
|
|
"Finally, the last available action is for the C2_SERVER_RANSOMWARE_LAUNCH to start the ransomware script installed on the same node as the C2 beacon.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This action is indexed as action ``7``.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The below yaml snippet shows all the relevant agent options for this action\n",
|
|
|
|
|
"\"The yaml snippet below shows all the relevant agent options for this action:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"``` yaml\n",
|
|
|
|
|
" action_space:\n",
|
|
|
|
|
@@ -623,9 +621,9 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"## **Command and Control** | Blue Agent Relevance\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The next section of the notebook will demonstrate the impact that the command and control suite has to the Blue Agent's observation space as well as some potential actions that can be used to prevent the attack from being successfully.\n",
|
|
|
|
|
"The next section of the notebook will demonstrate the impact the command and control suite has on the Blue Agent's observation space as well as some potential actions that can be used to prevent the attack from being successful.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The code cell below re-creates the UC2 network and swaps out the previous custom red agent with a custom blue agent. \n"
|
|
|
|
|
"The code cell below recreates the UC2 network and swaps out the previous custom red agent with a custom blue agent. "
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1072,7 +1070,7 @@
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# This method is used to shorthand setting up the C2Server and the C2 Beacon.\n",
|
|
|
|
|
"# This method is used to simplify setting up the C2Server and the C2 Beacon.\n",
|
|
|
|
|
"def c2_setup(given_env: PrimaiteGymEnv):\n",
|
|
|
|
|
" client_1: Computer = given_env.game.simulation.network.get_node_by_hostname(\"client_1\")\n",
|
|
|
|
|
" web_server: Server = given_env.game.simulation.network.get_node_by_hostname(\"web_server\")\n",
|
|
|
|
|
@@ -1190,7 +1188,7 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"#### Shutting down the node infected with a C2 Beacon.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Another way a blue agent can prevent the C2 suite is via shutting down the C2 beacon's host node. Whilst not as effective as the previous option, dependant on situation (such as multiple malicious applications) or other scenarios it may be more timestep efficient for a blue agent to shut down a node directly."
|
|
|
|
|
"Another way a blue agent can prevent the C2 suite is by shutting down the C2 beacon's host node. Whilst not as effective as the previous option, dependant on the situation (such as multiple malicious applications) or other scenarios it may be more timestep efficient for a blue agent to shut down a node directly."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1218,7 +1216,7 @@
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"The code cell below uses the custom blue agent defined at the start of this section perform NODE_SHUT_DOWN on the web server."
|
|
|
|
|
"The code cell below uses the custom blue agent defined at the start of this section perform a ``NODE_SHUT_DOWN`` action on the web server."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1235,7 +1233,7 @@
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Which we can see after the effects of after stepping another timestep and looking at the web_servers operating state & the OBS differences."
|
|
|
|
|
"Which we can see the effects of after another timestep and looking at the web_server's operating state & the OBS differences."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1264,7 +1262,7 @@
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# Attempting to install the C2 RansomwareScript\n",
|
|
|
|
|
"ransomware_install_command = {\"commands\":[[\"software_manager\", \"application\", \"install\", \"RansomwareScript\"]],\n",
|
|
|
|
|
"ransomware_install_command = {\"commands\":[\"software_manager\", \"application\", \"install\", \"RansomwareScript\"],\n",
|
|
|
|
|
" \"username\": \"admin\",\n",
|
|
|
|
|
" \"password\": \"admin\"}\n",
|
|
|
|
|
"\n",
|
|
|
|
|
@@ -1280,7 +1278,7 @@
|
|
|
|
|
"\n",
|
|
|
|
|
"Another potential option a blue agent could take is by placing an ACL rule which blocks traffic between the C2 Server can C2 Beacon.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"It's worth noting the potential effectiveness of approach is also linked by the current green agent traffic on the network. The same applies for the previous example."
|
|
|
|
|
"It's worth noting the potential effectiveness of this approach is connected to the current green agent traffic on the network. For example, if there are multiple green agents using the C2 Beacon's host node then blocking all traffic would lead to a negative reward. The same applies for the previous example."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1325,7 +1323,7 @@
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Which we can see after the effects of after stepping another timestep and looking at router 1's ACLs and the OBS differences."
|
|
|
|
|
"Which we can see the effects of after another timestep and looking at router 1's ACLs and the OBS differences."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1454,9 +1452,9 @@
|
|
|
|
|
"\n",
|
|
|
|
|
"As with a majority of client and server based application configuration in primaite, the remote IP of server must be supplied.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"In the case of the C2 Beacon, the C2 Server's IP must be supplied before the C2 beacon will be able to perform any other actions (including ``APPLICATION EXECUTE``).\n",
|
|
|
|
|
"In the case of the C2 Beacon, the C2 Server's IP address must be supplied before the C2 beacon will be able to perform any other actions (including ``APPLICATION EXECUTE``).\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"If the network contains multiple C2 Servers then it's also possible to switch to different C2 servers mid episode which is demonstrated in the below code cells."
|
|
|
|
|
"If the network contains multiple C2 Servers then it's also possible to switch to different C2 servers mid-episode which is demonstrated in the below code cells."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1546,7 +1544,7 @@
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"After six timesteps the client_1 server will recognise the c2 beacon previous connection as dead and clear it's connections. (This is dependant o the ``Keep Alive Frequency`` setting.)"
|
|
|
|
|
"After six timesteps the client_1 server will recognise the C2 beacon's previous connection as dead and clear its connections. (This is dependant on the ``Keep Alive Frequency`` setting.)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -1569,7 +1567,7 @@
|
|
|
|
|
"\n",
|
|
|
|
|
"In order to confirm it's connection the C2 Beacon will send out a ``Keep Alive`` to the C2 Server and receive a keep alive back. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"By default, this occurs at a rate of 5 timesteps. However, this setting can be configured to be much more infrequent or as frequent as every timestep. \n",
|
|
|
|
|
"By default, this occurs every 5 timesteps. However, this setting can be configured to be much more infrequent or as frequent as every timestep. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The next set of code cells below demonstrate the impact that this setting has on blue agent observation space."
|
|
|
|
|
]
|
|
|
|
|
@@ -1631,7 +1629,7 @@
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"The code cell below goes through 10 timesteps and displays the differences between the default and the current timestep.\n",
|
|
|
|
|
"The code cell below executes 10 timesteps and displays the differences between the default and the current timestep.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"You will notice that the only two timesteps displayed observation space differences. This is due to the C2 Suite confirming their connection through sending ``Keep Alive`` traffic across the network every 5 timesteps."
|
|
|
|
|
]
|
|
|
|
|
@@ -1688,7 +1686,7 @@
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Additionally, the keep_alive_frequency can also be used to configure the C2 Beacon to confirm connection less frequently. \n",
|
|
|
|
|
"Lastly, the keep_alive_frequency can also be used to configure the C2 Beacon to confirm connection less frequently. \n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The code cells below demonstrate the impacts of changing the frequency rate to ``7`` timesteps."
|
|
|
|
|
]
|
|
|
|
|
@@ -1713,9 +1711,9 @@
|
|
|
|
|
"source": [
|
|
|
|
|
"### **Command and Control** | Configurability | Masquerade Port & Masquerade Protocol\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The final configurable options are ``Masquerade Port`` & ``Masquerade Protocol``. These options can be used to control what networking IP Protocol and Port the C2 traffic is currently using.\n",
|
|
|
|
|
"The final configurable options are ``Masquerade Port`` & ``Masquerade Protocol``. These options can be used to control the networking IP Protocol and Port the C2 traffic is currently using.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"In the real world, Adversaries take defensive steps to reduce the chance that an installed C2 Beacon is discovered. One of the most commonly used methods is to masquerade c2 traffic as other commonly used networking protocols.\n",
|
|
|
|
|
"In the real world, adversaries take defensive steps to reduce the chance that an installed C2 Beacon is discovered. One of the most commonly used methods is to masquerade C2 traffic as other commonly used networking protocols.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"In primAITE, red agents can begin to simulate stealth behaviour by configuring C2 traffic to use different protocols mid episode or between episodes.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
|