-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from stratosphereips/ondra-add-optimal-trajec…
…tories Ondra add optimal trajectories
- Loading branch information
Showing
11 changed files
with
534 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,3 +156,4 @@ aim*/ | |
figures/* | ||
*trajectories*.json | ||
.vscode/settings.json | ||
trajectories/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Trajectories and Trajectory analusis | ||
Trajectories capture interactions of agents in AI Dojo. They can be stored in a file for future analysis using the configuration option `save_trajectories: True` in `env` section of the task configuration file. Trajectories are stored in a JSON format, one JSON object per line using [jsonlines](https://jsonlines.readthedocs.io/en/latest/). | ||
|
||
### Example of the trajectory | ||
Below we show an example of a trajectory consisting only from 1 step. Starting from state *S1*, the agent takes action*A1* and moves to state *S2* and is awarded with immediate reward `r = -1`: | ||
```json | ||
{ | ||
"agent_name": "ExampleAgent", | ||
"agent_role": "Attacker", | ||
"end_reason": "goal_reached", | ||
"trajectory": | ||
{ | ||
"states":[ | ||
"<DictRepresentation of State 1>", | ||
"<DictRepresentation of State 2>" | ||
], | ||
"actions":[ | ||
"<DictRepresentation of Action 1>" | ||
], | ||
"rewards":[-1] | ||
} | ||
} | ||
``` | ||
`agent_name` and `agent_role` are provided by the agent upon registration in the game. `end_reason` identifies how did the episode end. Currently there are four options: | ||
1. `goal_reached` - the attacker succcessfully reached the goal state and won the game | ||
2. `detected` - the attacker was detected by the defender subsequently lost the game | ||
3. `max_steps` - the agent used the max allowed amount of steps and the episode was terminated | ||
4. `None` - the episode was interrupted before ending and the trajectory is incomplete. | ||
|
||
## Trajectory analysis | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Configuration file for the NetSecGame environment | ||
|
||
coordinator: | ||
# Define the conf for all the 'attacker' agents. | ||
agents: | ||
attackers: | ||
goal: | ||
description: "Exfiltrate data to '213.47.23.195'" | ||
# Put randomize_goal_every_episode in True if you put any of the goal values in 'random' | ||
is_any_part_of_goal_random: False | ||
known_networks: [] | ||
#known_networks: [192.168.1.0/24, 192.168.3.0/24] | ||
known_hosts: [] | ||
#known_hosts: [192.168.1.1, 192.168.1.2] | ||
controlled_hosts: [] | ||
#controlled_hosts: [213.47.23.195, 192.168.1.3] | ||
# Services are defined as a target host where the service must be, and then a description in the form 'name,type,version,is_local' | ||
known_services: {} | ||
#known_services: {192.168.1.3: [Local system, lanman server, 10.0.19041, False], 192.168.1.4: [Other system, SMB server, 21.2.39421, False]} | ||
# In data, put the target host that must have the data and which data in format user,data | ||
# Example to fix the data in one host | ||
known_data: {213.47.23.195: [[User1,DataFromServer1]]} | ||
# Example to fix two data in one host | ||
#known_data: {213.47.23.195: [[User1,DataFromServer1], [User5,DataFromServer5]]} | ||
# Example to fix the data in two host | ||
#known_data: {213.47.23.195: [User1,DataFromServer1], 192.168.3.1: [User3,Data3FromServer3]} | ||
# Example to ask a random data in a specific server. Putting 'random' in the data, forces the env to randomly choose where the goal data is | ||
# known_data: {213.47.23.195: [random]} | ||
|
||
start_position: | ||
known_networks: [] | ||
known_hosts: [] | ||
# The attacker must always at least control the CC if the goal is to exfiltrate there | ||
# Example of fixing the starting point of the agent in a local host | ||
controlled_hosts: [213.47.23.195, random] | ||
# Example of asking a random position to start the agent | ||
# controlled_hosts: [213.47.23.195, random] | ||
# Services are defined as a target host where the service must be, and then a description in the form 'name,type,version,is_local' | ||
known_services: {} | ||
# known_services: {192.168.1.3: [Local system, lanman server, 10.0.19041, False], 192.168.1.4: [Other system, SMB server, 21.2.39421, False]} | ||
# Same format as before | ||
known_data: {} | ||
|
||
defenders: | ||
# types are StochasticDefender and NoDefender | ||
#type: 'StochasticDefender' | ||
type: 'StochasticWithThreshold' | ||
# type: 'NoDefender' | ||
tw_size: 5 | ||
thresholds: | ||
scan_network: # if both conditions are true, you are never detected | ||
consecutive_actions: 2 # min amount of consecutive actions you can do without detection | ||
tw_ratio: 0.25 # min ratio of actions in the tw below which you are not detected | ||
find_services: | ||
consecutive_actions: 3 | ||
tw_ratio: 0.3 | ||
exploit_service: | ||
repeated_actions_episode: 2 | ||
tw_ratio: 0.25 | ||
find_data: | ||
tw_ratio: 0.5 | ||
repeated_actions_episode: 2 | ||
exfiltrate_data: | ||
consecutive_actions: 2 | ||
tw_ratio: 0.25 | ||
action_detetection_prob: | ||
scan_network: 0.05 | ||
find_services: 0.075 | ||
exploit_service: 0.1 | ||
find_data: 0.025 | ||
exfiltrate_data: 0.025 | ||
env: | ||
# random means to choose the seed in a random way, so it is not fixed | ||
random_seed: 'random' | ||
# Or you can fix the seed | ||
# random_seed: 42 | ||
scenario: 'scenario1' | ||
max_steps: 100 | ||
store_replay_buffer: True | ||
use_dynamic_addresses: False | ||
goal_reward: 100 | ||
detection_reward: -5 | ||
step_reward: -1 | ||
actions: | ||
scan_network: | ||
prob_success: 1.0 | ||
find_services: | ||
prob_success: 1.0 | ||
exploit_service: | ||
prob_success: 1.0 | ||
find_data: | ||
prob_success: 1.0 | ||
exfiltrate_data: | ||
prob_success: 1.0 |
Oops, something went wrong.