A plugin for CTFd to create secure, containerized challenges with advanced per-instance flag management and anti-cheat features.
-
Per-Instance Teencode Flags:
- This feature is inspired by GPNCTF
- When an admin creates a challenge, a pool of unique teencode-style flags is pre-generated and stored in the database.
- When a user/team creates a container instance, a random unused flag from the pool is assigned to them.
- Flags are generated using a customizable teencode mapping, supporting diverse and obfuscated flag variants.
-
Anti-Cheat Detection:
- If a user/team submits a flag assigned to another user/team, the system detects cheating and logs the incident.
- Flags can only be used by the user/team they are assigned to, and only once.
- Cheating attempts can trigger bans or notifications as configured.
-
Automatic Flag Reuse Prevention:
- When a user/team terminates an instance, the flag assignment is reset, allowing the flag to be reassigned if unused.
- Flags are never reused across users/teams unless explicitly allowed by the admin.
-
Admin & User Workflows:
- Admins can create challenges with a single flag input (no suffix needed).
- Flags are automatically teencode-variant generated and managed.
- Users get a unique flag per instance, and cannot share or reuse flags.
-
Container Management:
- Supports both local and remote Docker daemons (via SSH).
- Admin dashboard for monitoring and managing running containers.
- Per-challenge and per-user/team container tracking.
-
UI Improvements:
- Clean challenge creation/update forms (no flag suffix field).
- Real-time feedback for flag submission and cheating detection.
- CTFd instance (Docker or direct)
- Docker (local or remote)
- (Optional) SSH access for remote Docker
- Clone this repository:
git clone https://github.com/JerryyyTheDuck/CTFd-Docker-Plugin.git
- Move the folder to the CTFd plugins directory:
mv CTFd-Docker-Plugin containers mv containers /path/to/CTFd/plugins/
- Go to the plugin settings page:
/containers/settings - Create a new challenge. Enter your flag in the "Flag" field (no suffix needed).
- The system will automatically generate a pool of teencode flags for the challenge.
- When users create an instance, they are assigned a unique flag from the pool.
- If a user submits a flag not assigned to them, or reuses a flag, cheating is detected and logged.
- Go to the plugin settings page:
/containers/settings - Fill in all fields except the
Base URL.
- Map the Docker socket into the CTFd container by modify the
docker-compose.ymlfile:
services:
ctfd:
...
volumes:
- /var/run/docker.sock:/var/run/docker.sock
...- Restart CTFd
- Go to the plugin settings page:
/containers/settings - Fill in all fields except the
Base URL.
For remote Docker, the CTFd host must have SSH access to the remote server.
- SSH access from the CTFd host to the Docker server
- The remote server's fingerprint should be in the
known_hostsfile - SSH key files (
id_rsa) and an SSH config file should be available
-
Prepare SSH Config:
mkdir ssh_config cp ~/.ssh/id_rsa ~/.ssh/known_hosts ~/.ssh/config ssh_config/
-
Mount SSH Config into the CTFd container:
services: ctfd: ... volumes: - ./ssh_config:/root/.ssh:ro ...
-
Restart CTFd:
docker-compose down docker-compose up -d
-
Ensure SSH Access:
- Test the connection:
ssh user@remote-server
- Test the connection:
-
Configure Docker Base URL:
- In the CTFd plugin settings page (
/containers/settings), set:Base URL: ssh://user@remote-server
- In the CTFd plugin settings page (
-
Restart CTFd:
sudo systemctl restart ctfd
- Manage running containers
- Monitor flag assignments and cheating attempts
- Users receive a unique teencode flag per instance
- User can spawn and extend the instance if they want
- Cheating attempts are detected and handled automatically. If user are detected as cheating, their POV will be below
- Per-instance teencode flag assignment
- Anti-cheat detection and logging
- Admin dashboard for container and flag management
- Clean UI for challenge creation/update
- Support for both user and team modes
- Fame or shame announcement
Distributed under the MIT License. See LICENSE.txt for details.
This plugin is an upgrade of andyjsmith's plugin with additional features from phannhat17 and major improvements for secure, per-instance flag management.







