You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NetSecGame (Network Security Game) is a framework for training and evaluation of AI agents in the network security tasks (both offensive and defensive). It is build with [CYST](https://pypi.org/project/cyst/) network simulator and enables rapid development and testing of AI agents in highly configurable scenarios. Examples of implemented agents can be seen in the submodule [NetSecGameAgents](https://github.com/stratosphereips/NetSecGameAgents/tree/main).
7
+
The NetSecGame (Network Security Game) is a framework for training and evaluation of AI agents in network security tasks (both offensive and defensive). It is built with [CYST](https://pypi.org/project/cyst/) network simulator and enables rapid development and testing of AI agents in highly configurable scenarios. Examples of implemented agents can be seen in the submodule [NetSecGameAgents](https://github.com/stratosphereips/NetSecGameAgents/tree/main).
8
8
9
9
## Installation Guide
10
-
It is recommended to install the NetSecGame in a virual environement:
10
+
It is recommended to install the NetSecGame in a virtual environment:
11
11
### Python venv
12
12
1.
13
13
```bash
@@ -37,7 +37,7 @@ The NetSecGame can be run in a Docker container. You can build the image locally
37
37
```bash
38
38
docker build -t aidojo-nsg-coordinator:latest .
39
39
```
40
-
or use the availabe image from [Dockerhub](https://hub.docker.com/r/lukasond/aidojo-coordinator).
40
+
or use the available image from [Dockerhub](https://hub.docker.com/r/lukasond/aidojo-coordinator).
41
41
```bash
42
42
docker pull lukasond/aidojo-coordinator:1.0.2
43
43
```
@@ -150,7 +150,7 @@ The NetSecGame environment has several components in the following files:
150
150
### Directory Details
151
151
-`coordinator.py`: Basic coordinator class. Handles agent communication and coordination. **Does not implement dynamics of the world** and must be extended (see examples in `worlds/`).
152
152
-`game_components.py`: Implements a library with objects used in the environment. See [detailed explanation](AIDojoCoordinator/docs/Components.md) of the game components.
153
-
-`global_defender.py`: Implements global (omnipresent) defender which can be used to stop agents. Simulation of SIEM.
153
+
-`global_defender.py`: Implements a global (omnipresent) defender that can be used to stop agents. Simulation of SIEM.
154
154
155
155
#### **`worlds/`**
156
156
Modules for different world configurations:
@@ -161,9 +161,9 @@ Modules for different world configurations:
161
161
#### **`scenarios/`**
162
162
Predefined scenario configurations:
163
163
-`tiny_scenario_configuration.py`: A minimal example scenario.
164
-
-`smaller_scenario_configuration.py`: A compact scenario configuration used for develompent and rapid testing.
164
+
-`smaller_scenario_configuration.py`: A compact scenario configuration used for development and rapid testing.
165
165
-`scenario_configuration.py`: The main scenario configuration.
166
-
-`three_net_configuration.py`: Configuration for a three-network scenario. Used for evaluation of the model overfitting.
166
+
-`three_net_configuration.py`: Configuration for a three-network scenario. Used for the evaluation of the model overfitting.
167
167
Implements the network game's configuration of hosts, data, services, and connections. It is taken from [CYST](https://pypi.org/project/cyst/).
168
168
169
169
#### **`utils/`**
@@ -184,9 +184,9 @@ The [scenarios](#definition-of-the-network-topology) define the **topology** of
184
184
2. If the attacker does a successful action in the same step that the defender successfully detects the action, the priority goes to the defender. The reward is a penalty, and the game ends.
185
185
(From commit d6d4ac9, July 18th, 2024, the new action BlockIP removes controlled hosts from the state of others. So the state can get smaller)
186
186
187
-
- The action FindServices finds the new services in a host. If in a subsequent call to FindServices there are less services, they completely replace the list of previous services found. That is, each list of services is the final one, and no memory of previous open services is retained.
187
+
- The action FindServices finds the new services in a host. If in a subsequent call to FindServices there are fewer services, they completely replace the list of previous services found. That is, each list of services is the final one, and no memory of previous open services is retained.
188
188
189
-
#### Assumption and Conditions for Actions
189
+
#### Assumptions and Conditions for Actions
190
190
1. When playing the `ExploitService` action, it is expected that the agent has discovered this service before (by playing `FindServices` in the `target_host` before this action)
191
191
2. The `Find Data` action finds all the available data in the host if successful.
192
192
3. The `Find Data` action requires ownership of the target host.
@@ -220,7 +220,7 @@ Each action type has a predefined probability of being detected. However, detect
220
220
- BlockIP: 0.01
221
221
222
222
This means that one action of the type ScanNetwork has a 5% probability of being detected by the defender.
223
-
This way we can define some basic probabilities based on how good we want the defender to be.
223
+
This way, we can define some basic probabilities based on how good we want the defender to be.
224
224
225
225
- Type Ratio Threshold
226
226
@@ -275,10 +275,10 @@ This approach ensures that only repeated or excessive behavior is flagged, reduc
275
275
## Starting the game
276
276
The environment should be created before starting the agents. The properties of the game, the task and the topology can be either read from a local file or via REST request to the GameDashboard.
277
277
278
-
#### To start the game with local configuration file
278
+
#### To start the game with a local configuration file
279
279
```python3 -m AIDojoCoordinator.worlds.NSEGameCoordinator --task_config=<PATH TO CONFIGURATION FILE>```
280
280
281
-
#### To start the game with remotely defined configuration
281
+
#### To start the game with a remotely defined configuration
282
282
```python3 -m AIDojoCoordinator.worlds.CYSTCoordinator --service_host=<URL OF THE REMOTE HOST> --service_port=<PORT FOR THE CONFIGURATION REST API> ```
283
283
284
284
When created, the environment:
@@ -289,7 +289,7 @@ When created, the environment:
289
289
5. starts the game server in a specified address and port
290
290
291
291
### Interaction with the Environment
292
-
When the game server is created, [agents](https://github.com/stratosphereips/NetSecGameAgents/tree/main) connect to it and interact with the environment. In every step of the interaction, agents submits an [Action](./AIDojoCoordinator/docs/Components.md#actions) and receives[Observation](./AIDojoCoordinator/docs/Components.md#observations) with `next_state`, `reward`, `is_terminal`, `end`, and `info` values. Once the terminal state or timeout is reached, no more interaction is possible until the agent asks for a game reset. Each agent should extend the `BaseAgent` class in [agents](https://github.com/stratosphereips/NetSecGameAgents/tree/main).
292
+
When the game server is created, [agents](https://github.com/stratosphereips/NetSecGameAgents/tree/main) connect to it and interact with the environment. In every step of the interaction, agents submits an [Action](./AIDojoCoordinator/docs/Components.md#actions) and receive[Observation](./AIDojoCoordinator/docs/Components.md#observations) with `next_state`, `reward`, `is_terminal`, `end`, and `info` values. Once the terminal state or timeout is reached, no more interaction is possible until the agent asks for a game reset. Each agent should extend the `BaseAgent` class in [agents](https://github.com/stratosphereips/NetSecGameAgents/tree/main).
293
293
294
294
295
295
### Configuration
@@ -299,17 +299,17 @@ The NetSecEnv is highly configurable in terms of the properties of the world, ta
299
299
300
300
#### Environment configuration
301
301
The environment part defines the properties of the environment for the task (see the example below). In particular:
302
-
-`random_seed` - sets seed for any random processes in the environment
302
+
-`random_seed` - sets the seed for any random processes in the environment
303
303
-`scenario` - sets the scenario (network topology) used in the task (currently, `scenario1_tiny`, `scenario1_small`, `scenario1` and `three_nets` are available)
304
304
-`save_tajectories` - if `True`, interaction of the agents is serialized and stored in a file
305
305
-`use_dynamic_addresses` - if `True`, the network and IP addresses defined in `scenario` are randomly changed at the beginning of **EVERY** episode (the network topology is kept as defined in the `scenario`. Relations between networks are kept, IPs inside networks are chosen at random based on the network IP and mask)
306
-
-`use_firewall` - if `True` firewall rules defined in `scenario` are used when executing actions. When `False`, the firewall is ignored, and all connections are allowed (Default)
307
-
-`use_global_defender` - if `True`, enables global defendr which is part of the environment and can stop interaction of any playing agent.
306
+
-`use_firewall` - if `True`, firewall rules defined in `scenario` are used when executing actions. When `False`, the firewall is ignored, and all connections are allowed (Default)
307
+
-`use_global_defender` - if `True`, enables global defender, which is part of the environment and can stop interaction of any playing agent.
308
308
-`required_players` - Minimum required players for the game to start (default 1)
309
309
-`rewards`:
310
-
-`success` - sets reward which agent gets when it reaches the goal (default 100)
311
-
-`fail` - sets the reward that which agent does not reach it's objective (default -10)
312
-
-`step_reward` - sets reward which agent gets for every step taken (default -1)
310
+
-`success` - sets the reward when the agent reaches the goal (default 100)
311
+
-`fail` - sets the reward when the agent does not reach its objective (default -10)
312
+
-`step_reward` - sets the reward when the agent does each single step in the game (default -1)
313
313
-`actions` - defines the probability of success for every ActionType
314
314
315
315
```YAML
@@ -364,7 +364,7 @@ Configuration of the attacking agents. Consists of three parts:
364
364
- `known_blocks`(dict)
365
365
366
366
The initial network configuration must assign at least **one** controlled host to the attacker in the network. Any item in `controlled_hosts` is copied to `known_hosts`, so there is no need to include these in both sets. `known_networks` is also extended with a set of **all** networks accessible from the `controlled_hosts`
367
-
3. Definition of maximum allowed amount of steps:
367
+
3. Definition of maximum allowed number of steps:
368
368
- `max_steps:`(int): defines the maximum allowed number of steps for attackers in **each** episode.
369
369
370
370
Example attacker configuration:
@@ -420,38 +420,38 @@ Example of defender configuration:
420
420
blocked_ips: {}
421
421
known_blocks: {}
422
422
```
423
-
As in other agents, the description is only a text for the agent, so it can know what is supposed to do to win. In the curent implementation, the *Defender* wins, if **NO ATTACKER** reaches their goal.
423
+
As in other agents, the description is only a text for the agent, so it can know what is supposed to do to win. In the current implementation, the *Defender* wins, if **NO ATTACKER** reaches their goal.
424
424
425
425
426
426
### Definition of the network topology
427
427
The network topology and rules are defined using a [CYST](https://pypi.org/project/cyst/) simulator configuration. Cyst defines a complex network configuration, and this environment does not use all Cyst features for now. CYST components currently used are:
428
428
429
429
- Server hosts (are a NodeConf in CYST)
430
430
- Interfaces, each with one IP address
431
-
- Users that can log in to the host
431
+
- Users who can log in to the host
432
432
- Active and passive services
433
433
- Data in the server
434
434
- To which network is connected
435
-
- Client host (are a Node in CYST)
435
+
- Client host (are of type Node in CYST)
436
436
- Interfaces, each with one IP address
437
437
- To which network is connected
438
-
- Active and passive services if any
438
+
- Active and passive services, if any
439
439
- Data in the client
440
-
- Router (are a RouterConf in CYST)
440
+
- Router (are of type RouterConf in CYST)
441
441
- Interfaces, each with one IP address
442
442
- Networks
443
443
- Allowed connections between hosts
444
-
- Internet host (as an external router) (are a Node in RouterConf)
444
+
- Internet host (as an external router) (are of type Node in RouterConf)
445
445
- Interfaces, each with one IP address
446
446
- Which host can connect
447
447
- Exploits
448
-
- which service is the exploit linked to
448
+
- Which service is the exploit linked to
449
449
450
450
### Scenarios
451
451
In the current state, we support a single scenario: Data exfiltration to a remote C&C server. However, extensions can be made by modification of the task configuration.
452
452
453
453
#### Data exfiltration to a remote C&C
454
-
For the data exfiltration we support 3 variants. The full scenario contains 5 clients (where the attacker can start) and 5 servers where the data that is supposed to be exfiltrated can be located. *scenario1_small* is a variant with a single client (the attacker always starts there) and all 5 servers. *scenario1_tiny* contains only a single server with data. The tiny scenario is trivial and intended only for debugging purposes.
454
+
For the data exfiltration, we support 3 variants. The full scenario contains 5 clients (where the attacker can start) and 5 servers, where the data that is supposed to be exfiltrated can be located. *scenario1_small* is a variant with a single client (the attacker always starts there) and all 5 servers. *scenario1_tiny* contains only a single server with data. The tiny scenario is trivial and intended only for debugging purposes.
It is advised after every change you test if the env is running correctly by doing
479
+
It is advised that after every change, you test if the env is running correctly by doing
480
480
481
481
```bash
482
482
tests/run_all_tests.sh
483
483
```
484
-
This will load and run the unit tests in the `tests` folder. After passing all tests, linting and formatting is checked with ruff.
484
+
This will load and run the unit tests in the `tests` folder. After passing all tests, linting and formatting are checked with ruff.
485
485
486
486
## Code adaptation for new configurations
487
487
The code can be adapted to new configurations of games and for new agents. See [Agent repository](https://github.com/stratosphereips/NetSecGameAgents/tree/main) for more details.
0 commit comments