# API documentation

The API documentation can be found as a Swagger UI at /api/docs.

## Send command to implant

<mark style="color:green;">`POST`</mark> `https:/YOURDOMAIN-OR-IP/api/commands/`

This endpoint allows you to execute the command of choice on the implant of choice.

#### Request Body

| Name             | Type   | Description                  |
| ---------------- | ------ | ---------------------------- |
| Implant ID       | string | Provide the Implant ID       |
| Implant Location | string | Provide the Implant Location |
| Implant Project  | string | Provide the Implant Project  |
| command          | string | Provide the command          |

{% tabs %}
{% tab title="302 POST was succesful, routing the user back to the index page." %}

```
```

{% endtab %}

{% tab title="500 Exception occured in the Flask API" %}

```
Error details
```

{% endtab %}
{% endtabs %}

## Get all mqtt data (WARNING: use this carefully)

<mark style="color:blue;">`GET`</mark> `htthttps:/YOURDOMAIN-OR-IP/api/data`

Get all mqtt data from mariadb.

{% tabs %}
{% tab title="200 Returns all mqtt data in JSON format" %}

```
[{"value_timestamp": "2020-12-03T12:56:53.883", "value": "DUMPFULLSD", "topic_id": 1}, {"value_timestamp": "2020-12-03T13:08:05.422", "value": "DUMPFULLSD", "topic_id": 1}]
```

{% endtab %}
{% endtabs %}

## Get all mqtt topics

<mark style="color:blue;">`GET`</mark> `https:/YOURDOMAIN-OR-IP/api/topics`

Get all mqtt topics from mariadb.

{% tabs %}
{% tab title="200 Returns all mqtt topics in JSON format" %}

```
[{"topic_id": 1, "topic": "projectx/apt1/receive"}, {"topic_id": 2, "topic": "projectx/apt1/send"}]
```

{% endtab %}
{% endtabs %}

## Create new implant config

<mark style="color:green;">`POST`</mark> `https:/YOURDOMAIN-OR-IP/api/create/config`

Create new config for new implant

#### Request Body

| Name             | Type   | Description |
| ---------------- | ------ | ----------- |
| Implant ID       | string |             |
| Implant Project  | string |             |
| Implant Location | string |             |
| Workhours (UTC)  | string |             |
| Username         | string |             |
| Password         | string |             |

{% tabs %}
{% tab title="302 POST was succesful, routing the user back to the index page." %}

```
```

{% endtab %}

{% tab title="500 Exception occured in t" %}

```
```

{% endtab %}
{% endtabs %}

## Update implant config

<mark style="color:green;">`POST`</mark> `https:/YOURDOMAIN-OR-IP/api/update/config`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## Delete implant config

<mark style="color:green;">`POST`</mark> `https:/YOURDOMAIN-OR-IP/api/delete/config`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## Get implant configs

<mark style="color:blue;">`GET`</mark> `https:/YOURDOMAIN-OR-IP/api/get/config`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## Get topics for implant

<mark style="color:blue;">`GET`</mark> `https:/YOURDOMAIN-OR-IP/api/get/topics_implant`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## Download txt file with all mqtt data (including timestamps) for implant for given timeframe

<mark style="color:blue;">`GET`</mark> `https:/YOURDOMAIN-OR-IP/api/download/export`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}
