This CTFd plugin allows you to run ephemeral Docker containers for specific challenges. Users can request a container to use as needed, and its lifecycle will be managed by the plugin.
Go to your CTFd/plugins folder and execute following commands:
git clone https://github.com/EternalBlueCTE2k24/CTFdDockerContainersPlugin.git containers
cd containers
pip install -r requirements.txtRestart your ctfd.
To configure the plugin, go to the admin page, click the dropdown in the navbar for plugins, and go to the Containers page (https://example.com/containers/settings).
Then you can click the settings button to configure the connection. You will need to specify some values, including the connection string to use. This can either be the local Unix socket, or an TCP connection. If using Docker Compose CTFd installation, you can map docker socket into CTFd container by modifying the docker-compose.yml file (Be careful to best pratices):
services:
ctfd:
...
volumes:
...
- /var/run/docker.sock:/var/run/docker.sock
...The other options are described on the page. After saving, the plugin will try to connect to the Docker daemon and the status should show as an error message or as a green symbol (maybe restart ctf to be sure).
To create challenges, use the container challenge type and configure the options. It is set up with dynamic scoring, so if you want regular scoring, set the maximum and minimum to the same value and the decay to zero.
It's also possible to configure auto deployment using ctfcli and its YAML configuration:
name: BestChallenge
...
type: container
value: 50
extra:
initial: 50
decay: 75
minimum: 10
image: bestchallenge:latest
port: 1337
connection_info: https://container.example.com
...If you need to specify advanced options like the volumes, read the Docker SDK for Python documentation for the syntax, since most options are passed directly to the SDK.
When a user clicks on a container challenge, a button labeled "Start Instance" appears. Clicking it shows the information below with a random port assignment.
- Possibility to use 2 docker TCP connection method (like 1 windows and 1 linux).
- Add logging.
- Only one docker per team.
- Make it work with Team mode.
- Tests with 3.7 CTFd.
You can create issues and PRs by yourself if you experienced a bug, have questions or if you have an idea for a new feature. This repository aims to remain active, up to date and scalable.
