Skip to content

About

attackmate api server for remote execution of playbooks

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

AttackMate API Server

AttackMate API Server is a RESTful API built with FastAPI for remotely controlling AttackMate instances and executing attack playbooks. It provides secure endpoints to orchestrate attack chains, execute commands, and run attack playbook.

Features

  • Execute AttackMate commands or playbooks remotely
  • Automatic logging for requests, command execution, and playbooks.
  • Supports SSL/TLS for secure communication.

Requirements

  • Python 3.11+
  • uv
  • openssl

Installation

From PyPI:

uv tool install attackmate-api-server

This installs the attackmate-api command on your PATH. Configuration (.env, key.pem, cert.pem) is read from the directory you start it in.

From source:

git clone https://github.com/ait-testbed/attackmate-api-server.git
cd attackmate-api-server

uv sync


## Developer setup

If you plan to contribute to the development of this package, follow these steps to set up the dev environment and install pre-commit hooks (using [prek](https://github.com/j178/prek))

```bash
uv sync --dev
uv run --dev prek install

Run the tests:

uv run --dev pytest -q

Run the tests with coverage (add --cov-report=html to generate an HTML report):

uv run --dev pytest --cov=. --cov-report=term-missing

Certificate generation

with open ssl

    openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

Common Name: server IP adress

Clients receive the cert.pem SSL certificate

By default the server looks for key.pem and cert.pem in the directory you start it from (the same directory as .env). Set SSL_KEY_PATH and SSL_CERT_PATH to use files elsewhere.

Environment Configuration

Create an .env file in the project root with the following variables:

USERS='{"username": "<argon2_hash>", ...}'
ATTACKMATE_CONFIG_PATH="/path/to/attackmate.yml"
WRITE_PLAYBOOK_LOGS_TO_DISK="False"
LOG_DIR="/path/to/logs"
Variable Description
USERS JSON object mapping usernames to Argon2-hashed passwords
ATTACKMATE_CONFIG_PATH Absolute path to the AttackMate config YAML
WRITE_PLAYBOOK_LOGS_TO_DISK Whether to persist playbook logs to disk (True/False)
LOG_DIR Directory for log output
ATTACKMATE_API_SERVER_PORT The port on which the server listens for incoming REST API requests.

To generate a password hash for USERS, run this and type the password when asked:

uv run --with argon2-cffi python -c "import getpass; from argon2 import PasswordHasher; print(PasswordHasher().hash(getpass.getpass()))"

Put the printed hash into your .env file, keeping the outer single quotes (the hash contains $):

USERS='{"alice": "$argon2id$v=19$m=65536,t=3,p=4$..."}'

Running the application

attackmate-api          # installed with uv tool install
uv run attackmate-api   # from a source checkout

The server will run on https://0.0.0.0:8445 by default.

Can be changed via ATTACKMATE_API_SERVER_PORT in the .env file

Swagger UI: https://:8445/docs – interactive API documentation.

Authentication

The API uses token-based authentication.

Endpoint: POST /login

Request:

{
  "username": "your_username",
  "password": "your_password"
}

Response:

{
  "access_token": "<TOKEN>",
  "token_type": "bearer"
}

Use the token in the Authorization header for all protected endpoints

API Endpoints

POST /playbooks/execute/yaml – Execute a playbook provided as YAML content on an AttackMate instantiated for the duration of playbook execution.

POST /command/execute – Execute a command on a persistent AttackMate instance. Request body must follow the RemotelyExecutableCommand schema

Client Usage

The recommended way to interact with the API is via the AttackMate Client, which provides a convenient interface for authentication, playbook submission, and result retrieval.

Security Notes

Use strong passwords. Anyone who can log in can run commands on the server. Never commit .env to version control. Ensure .env is listed in .gitignore. Use CA-signed certificates in production. Self-signed certificates should only be used for local testing. Restrict network access to the API server to trusted hosts where possible.

Related Projects

AttackMate – the underlying attack orchestration engine AttackMate Client – recommended client for interacting with this API

License

This project is licensed under EUPL-1.2

About

attackmate api server for remote execution of playbooks

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages