Skip to content

Commit

Permalink
Merge pull request #211 from stratosphereips/ondrej-lukas-fix-readme-…
Browse files Browse the repository at this point in the history
…typos

Update Components.md
  • Loading branch information
ondrej-lukas authored Apr 25, 2024
2 parents 1cae2a5 + 9aefa18 commit 55b5309
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions docs/Components.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
# Game Components
Here you can see the details of all components of the NetSetEnvironment and their usage. These components are located in [game_components.py](/env/game_components.py).
Here, you can see the details of all components of the NetSetEnvironment and their usage. These components are located in [game_components.py](/env/game_components.py).

## Building blocks
Following classes are used in the game to hold information about the state of the game. They are used both in the [Actions](#actions) and [GameState](#gamestate).
The following classes are used in the game to hold information about the state of the game. They are used both in the [Actions](#actions) and [GameState](#gamestate).

### IP
IP is immutable object that represents an IPv4 object in the NetSecGame. It has a single parameter of the address in a dot-decimal notation (4 octet represeted as decimal value separeted by dots).

Example: `ip = IP("192.168.1.1")`

### Network
Network is immutable object that represents a IPv4 network object in the NetSecGame. It has 2 parameters:
Network is immutable object that represents an IPv4 network object in the NetSecGame. It has 2 parameters:
- `network_ip:str` representing the IPv4 address of the network.
- `mask:int` representing the mask in the CIDR notation.

Example: `net = Network("192.168.1.0", 24)`

## Service
Service class holds information about services running in hosts. Each Service has four parameters:
- `name`:str - Name of the service (e.g. "SSH")
- `name`:str - Name of the service (e.g., "SSH")
- `type`:str - `passive` or `active`. Currently not being used.
- `version`:str - version of the service.
- `is_local`:bool - flag specifying if the service is local only. (if `True`, service is NOT visible wihtout controlling the host).
- `is_local`:bool - flag specifying if the service is local only. (if `True`, service is NOT visible without controlling the host).

Example: `s = Service('postgresql', 'passive', '14.3.0', False)`

## Data
Data class holds information about datapoints (files) present in the NetSecGame. Datapoints DO NOT hold the content of files.
Each data instance has two parameters:
- `owner`:str - specifying the user who ownes this datapoint
- `owner`:str - specifying the user who owns this datapoint
- `id`: str - unique identifier of the datapoint in a host
- `size`: int - size of the datapoint (optional, default=0)
- `type`: str - indetification of a type of the file (optional, default="")
- `type`: str - identification of a type of the file (optional, default="")

Example:`Data("User1", "DatabaseData")`
Examples:`Data("User1", "DatabaseData")`, `Data("User1", "DatabaseData", size=42, type="txt")`

## GameState
GameState is a object which represents a view of the NetSecGame environment in a given state. It is constructed as a collection of 'assets' available to the agent. GameState has following parts:
GameState is an object that represents a view of the NetSecGame environment in a given state. It is constructed as a collection of 'assets' available to the agent. GameState has following parts:
- `known_networks`: Set of [Network](#network) objects that the agent is aware of
- `known_hosts`: Set of [IP](#ip) objects that the agent is aware of
- `controlled_hosts`: Set of [IP](#ip) objetcs that the agent has control over. Note that `controlled_hosts` is a subset of `known_hosts`.
- `known_services`: Dictionary of services that the agent is aware of.
The dictonary format: {`IP`: {`Service`}} where [IP](#ip) object is a key and the value is a set of [Service](#service) objects located in the `IP`.
- `known_data`: Dictionary of data instances that the agent is aware of. The dictonary format: {`IP`: {`Data`}} where [IP](#ip) object is a key and the value is a set of [Data](#data) objects located in the `IP`.
The dictionary format: {`IP`: {`Service`}} where [IP](#ip) object is a key and the value is a set of [Service](#service) objects located in the `IP`.
- `known_data`: Dictionary of data instances that the agent is aware of. The dictionary format: {`IP`: {`Data`}} where [IP](#ip) object is a key and the value is a set of [Data](#data) objects located in the `IP`.


## Actions
Actions are the objects send by the agents to the environment. Each action is evaluated by AIDojo and executed if
Actions are the objects sent by the agents to the environment. Each action is evaluated by AIDojo and executed if
1. Is a valid Action
2. Can be processed in the current state of the environment

In all cases, when an agent sends action to AIDojo, it is given a response.
In all cases, when an agent sends an action to AIDojo, it is given a response.
### Action format
The Action class is defined in `env.game_components.py`. It has two basic parts:
1. ActionType:Enum
Expand All @@ -62,14 +62,14 @@ ActionType is unique Enum that determines what kind of action is agent playing.
- **QuitGame**, params={}: Used for termination of agent's interaction.
- **ResetGame**, params={}: Used for requesting reset of the game to it's initial position.
---
- **ScanNetwork**, params{`source_host`:\<IP\>, `target_network`:\<Network\>}: Scans the given \<Network\> from a specified source host. Discovers ALL hosts in a network which are accessible from \<IP\>. If successful, returns set of discovered \<IP\> objects.
- **FindServices**, params={`source_host`:\<IP\>, `target_host`:\<IP\>}: Used to discover ALL services running in the `target_host` if the host is accessible from `source_host`. If sucessful, returns set of all dicovered \<Service\> objects.
- **FindData**, params={`source_host`:\<IP\>, `target_host`:\<IP\>}: Searches `target_host` for data. If `source_host` differs from `target_host` success depends on accessability from the `source_host`. If sucessful, returns set of all discovered \<Data\> objects.
- **ExploitService**, params={`source_host`:\<IP\>, `target_host`:\<IP\>, `taget_service`:\<Service\>}: Exploits `target_service` in a specified `target_host`. If sucessful, the attacker gains control of the `target_host`.
- **ScanNetwork**, params{`source_host`:\<IP\>, `target_network`:\<Network\>}: Scans the given \<Network\> from a specified source host. Discovers ALL hosts in a network that are accessible from \<IP\>. If successful, returns set of discovered \<IP\> objects.
- **FindServices**, params={`source_host`:\<IP\>, `target_host`:\<IP\>}: Used to discover ALL services running in the `target_host` if the host is accessible from `source_host`. If successful, returns a set of all discovered \<Service\> objects.
- **FindData**, params={`source_host`:\<IP\>, `target_host`:\<IP\>}: Searches `target_host` for data. If `source_host` differs from `target_host`, success depends on accessability from the `source_host`. If successful, returns a set of all discovered \<Data\> objects.
- **ExploitService**, params={`source_host`:\<IP\>, `target_host`:\<IP\>, `taget_service`:\<Service\>}: Exploits `target_service` in a specified `target_host`. If successful, the attacker gains control of the `target_host`.
- **ExfiltrateData**, params{`source_host`:\<IP\>, `target_host`:\<IP\>, `data`:\<Data\>}: Copies `data` from the `source_host` to `target_host` IF both are controlled and `target_host` is accessible from `source_host`.

### Action preconditons and effects
In the following table, we describe effects of selected actions and their preconditions. Note that if the preconditions are not satisfied, the actions's effects are not applied.
### Action preconditions and effects
In the following table, we describe the effects of selected actions and their preconditions. Note that if the preconditions are not satisfied, the actions's effects are not applied.

| Action | Params | Preconditions | Effects |
|----------------------|----------------------|----------------------|----------------------|
Expand All @@ -88,8 +88,8 @@ ExfiltrateData| `source_host`,`target_host`, `data` |`source_host`, `target_host
6. Parameters of `ScanNetwork` and `FindServices` can be chosen arbitrarily (they don't have to be listed in `known_newtworks`/`known_hosts`)

## Observations
After submitting Action `a` to the environment, agents receives an `Observation` in return. Each observation consists of 4 parts:
After submitting Action `a` to the environment, agents receive an `Observation` in return. Each observation consists of 4 parts:
- `state`:`Gamestate` - with the current view of the environment [state](#gamestate)
- `reward`: `int` - with the imedeate reward agent gets for playing Action `a`
- `end`:`bool` - indicating if the intaraction can continue after playing Action `a`
- `info`: `dict` - placeholder for any information given to the agent (e.g. the reason why `end is True` )
- `reward`: `int` - with the immediate reward agent gets for playing Action `a`
- `end`:`bool` - indicating if the interaction can continue after playing Action `a`
- `info`: `dict` - placeholder for any information given to the agent (e.g., the reason why `end is True` )

0 comments on commit 55b5309

Please sign in to comment.