Skip to content

Commit b2ff74c

Browse files
authored
Merge pull request #328 from stratosphereips/ondrej-lukas-patch-1
Ondrej lukas patch 1
2 parents aa98cd2 + 00432e8 commit b2ff74c

File tree

2 files changed

+99
-33
lines changed

2 files changed

+99
-33
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy MkDocs site to GitHub Pages
1+
name: Deploy MkDocs
22

33
on:
44
push:

README.md

Lines changed: 98 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,127 @@
11
# Netwrok Security Game
22
[![Python Checks](https://github.com/stratosphereips/game-states-maker/actions/workflows/python-checks.yml/badge.svg)](https://github.com/stratosphereips/game-states-maker/actions/workflows/python-checks.yml)
33
[![Autotag](https://github.com/stratosphereips/game-states-maker/actions/workflows/autotag.yml/badge.svg)](https://github.com/stratosphereips/game-states-maker/actions/workflows/autotag.yml)
4-
[![Docs](https://github.com/<user>/stratosphereips/game-states-maker/actions/workflows/deploy-docs.yml/badge.svg)](https://stratosphereips.github.io/NetSecGame/))
4+
[![Docs](https://github.com/stratosphereips/game-states-maker/actions/workflows/deploy-docs.yml/badge.svg)](https://stratosphereips.github.io/NetSecGame/)
55

66

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).
88

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.
1913
```bash
20-
source ai-dojo-venv<yourusername>/bin/activate
14+
python -m venv <venv-name>
2115
```
22-
3. Install with pip:
16+
2.
2317
```bash
24-
pip install -e .
18+
source <venv-name>/bin/activate
2519
```
26-
### Installing with Conda
27-
1. Create conda environment
20+
21+
### Conda
22+
1.
2823
```bash
2924
conda create --name aidojo python==3.12
3025
```
31-
2. Activate it
26+
2.
3227
```bash
3328
conda activate aidojo
3429
```
35-
3. Install the package
30+
31+
After the virtual environment is activated, install using pip:
3632
```bash
3733
pip install -e .
3834
```
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
4438
docker build -t aidojo-nsg-coordinator:latest .
4539
```
46-
47-
or pull the image from Dockerhub
40+
or use the availabe image from [Dockerhub](https://hub.docker.com/r/lukasond/aidojo-coordinator).
4841
```bash
4942
docker pull lukasond/aidojo-coordinator:1.0.2
5043
```
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).
5152

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: {}
5673

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/)
59125
## Components of the NetSecGame Environment
60126
The architecture of the environment can be seen [here](docs/Architecture.md).
61127
The NetSecGame environment has several components in the following files:

0 commit comments

Comments
 (0)