|
1 | 1 | # Netwrok Security Game |
2 | 2 | [](https://github.com/stratosphereips/game-states-maker/actions/workflows/python-checks.yml) |
3 | 3 | [](https://github.com/stratosphereips/game-states-maker/actions/workflows/autotag.yml) |
4 | | -[](https://stratosphereips.github.io/NetSecGame/)) |
| 4 | +[](https://stratosphereips.github.io/NetSecGame/) |
5 | 5 |
|
6 | 6 |
|
7 | | -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 builds a simulated local network using the [CYST](https://pypi.org/project/cyst/) network simulator, adds many conditions on the environment and can train reinforcement learning (RL) algorithms on how to better attack and defend the network. 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 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). |
8 | 8 |
|
9 | | -The main part of he NetSecGame is the Game coordinator. It creates the enivronemnt, handles the agents and their interactions and coordinates the game(s). |
10 | | - |
11 | | -## Installation and Dependencies |
12 | | -To run this code you need an environment and access to cyst code. However, the venv needs to be created for your own user |
13 | | -### Installing in Pyton virtual environment |
14 | | -1. Create the [virual envtironment](https://docs.python.org/3/library/venv.html): |
15 | | -```bash |
16 | | -python -m venv ai-dojo-venv-<yourusername> |
17 | | -``` |
18 | | -2. Activate the venv: |
| 9 | +## Installation Guide |
| 10 | +It is recommended to install the NetSecGame in a virual environement: |
| 11 | +### Python venv |
| 12 | +1. |
19 | 13 | ```bash |
20 | | -source ai-dojo-venv<yourusername>/bin/activate |
| 14 | +python -m venv <venv-name> |
21 | 15 | ``` |
22 | | -3. Install with pip: |
| 16 | +2. |
23 | 17 | ```bash |
24 | | -pip install -e . |
| 18 | +source <venv-name>/bin/activate |
25 | 19 | ``` |
26 | | -### Installing with Conda |
27 | | -1. Create conda environment |
| 20 | + |
| 21 | +### Conda |
| 22 | +1. |
28 | 23 | ```bash |
29 | 24 | conda create --name aidojo python==3.12 |
30 | 25 | ``` |
31 | | -2. Activate it |
| 26 | +2. |
32 | 27 | ```bash |
33 | 28 | conda activate aidojo |
34 | 29 | ``` |
35 | | -3. Install the package |
| 30 | + |
| 31 | +After the virtual environment is activated, install using pip: |
36 | 32 | ```bash |
37 | 33 | pip install -e . |
38 | 34 | ``` |
39 | | - |
40 | | -### Running in Docker |
41 | | -You can run the coordinator in a Docker container |
42 | | -Build the Contaier (run from the *root* of the project) locally. |
43 | | -```bash |
| 35 | +### With Docker |
| 36 | +The NetSecGame can be run in a Docker container. You can build the image locally with: |
| 37 | +```bash |
44 | 38 | docker build -t aidojo-nsg-coordinator:latest . |
45 | 39 | ``` |
46 | | - |
47 | | -or pull the image from Dockerhub |
| 40 | +or use the availabe image from [Dockerhub](https://hub.docker.com/r/lukasond/aidojo-coordinator). |
48 | 41 | ```bash |
49 | 42 | docker pull lukasond/aidojo-coordinator:1.0.2 |
50 | 43 | ``` |
| 44 | +## Quick Start |
| 45 | +A task configuration needs to be specified to start the NetSecGame (see [Configuration](configuration.md)). For the first step, the example task configuration is recommended: |
| 46 | +```yaml |
| 47 | +# Example of the task configuration for NetSecGame |
| 48 | +# The objective of the Attacker in this task is to locate specific data |
| 49 | +# and exfiltrate it to a remote C&C server. |
| 50 | +# The scenario starts AFTER initial breach of the local network |
| 51 | +# (the attacker controls 1 local device + the remote C&C server). |
51 | 52 |
|
52 | | -## Running the game: |
53 | | -There are currently two variants of how you can run the game: |
54 | | -- Network Security Game - pure simulation |
55 | | -- CYST-based Environment - simulation + emulation |
| 53 | +coordinator: |
| 54 | + agents: |
| 55 | + Attacker: # Configuration of 'Attacker' agents |
| 56 | + max_steps: 25 |
| 57 | + goal: |
| 58 | + description: "Exfiltrate data from Samba server to remote C&C server." |
| 59 | + is_any_part_of_goal_random: True |
| 60 | + known_networks: [] |
| 61 | + known_hosts: [] |
| 62 | + controlled_hosts: [] |
| 63 | + known_services: {} |
| 64 | + known_data: {213.47.23.195: [[User1,DataFromServer1]]} # winning condition |
| 65 | + known_blocks: {} |
| 66 | + start_position: # Defined starting position of the attacker |
| 67 | + known_networks: [] |
| 68 | + known_hosts: [] |
| 69 | + controlled_hosts: [213.47.23.195, random] # |
| 70 | + known_services: {} |
| 71 | + known_data: {} |
| 72 | + known_blocks: {} |
56 | 73 |
|
57 | | -### Running Network Security Game |
58 | | -1. Prepare the task configuration file (see ) |
| 74 | + Defender: |
| 75 | + goal: |
| 76 | + description: "Block all attackers" |
| 77 | + is_any_part_of_goal_random: False |
| 78 | + known_networks: [] |
| 79 | + known_hosts: [] |
| 80 | + controlled_hosts: [] |
| 81 | + known_services: {} |
| 82 | + known_data: {} |
| 83 | + known_blocks: {213.47.23.195: 'all_attackers'} |
| 84 | + |
| 85 | + start_position: |
| 86 | + known_networks: [] |
| 87 | + known_hosts: [] |
| 88 | + controlled_hosts: [] |
| 89 | + known_services: {} |
| 90 | + known_data: {} |
| 91 | + blocked_ips: {} |
| 92 | + known_blocks: {} |
| 93 | + |
| 94 | +env: |
| 95 | + scenario: 'two_networks_tiny' # use the smallest topology for this example |
| 96 | + use_global_defender: False # Do not use global SIEM Defender |
| 97 | + use_dynamic_addresses: False # Do not randomize IP addresses |
| 98 | + use_firewall: True # Use firewall |
| 99 | + save_trajectories: False # Do not store trajectories |
| 100 | + required_players: 1 |
| 101 | + rewards: # Configurable reward function |
| 102 | + success: 100 |
| 103 | + step: -1 |
| 104 | + fail: -10 |
| 105 | + false_positive: -5 |
| 106 | +``` |
| 107 | +
|
| 108 | +The game can be started with: |
| 109 | +```bash |
| 110 | +python3 -m AIDojoCoordinator.worlds.NSEGameCoordinator \ |
| 111 | + --task_config=./examples/example_config.yaml \ |
| 112 | + --game_port=9000 |
| 113 | +``` |
| 114 | +Upon which the game server is created on `localhost:9000` to which the agents can connect to interact in the NetSecGame. |
| 115 | +### Docker Container |
| 116 | +When running in the Docker container, the NetSecGame can be started with: |
| 117 | +```bash |
| 118 | +docker run -it --rm \ |
| 119 | + -v $(pwd)/examples/example_config.yaml:/aidojo/netsecenv_conf.yaml \ |
| 120 | + -v $(pwd)/logs:/aidojo/logs \ |
| 121 | + -p 9000:9000 lukasond/aidojo-coordinator:1.0.2 |
| 122 | +``` |
| 123 | +## Documentation |
| 124 | +You can find user documentation at [https://stratosphereips.github.io/NetSecGame/](https://stratosphereips.github.io/NetSecGame/) |
59 | 125 | ## Components of the NetSecGame Environment |
60 | 126 | The architecture of the environment can be seen [here](docs/Architecture.md). |
61 | 127 | The NetSecGame environment has several components in the following files: |
|
0 commit comments