Skip to content

CTFd plugin allowing for individual Docker containers per team

License

Notifications You must be signed in to change notification settings

phannhat17/CTFd-Docker-Plugin

 
 

Repository files navigation

CTFd Docker Containers Plugin

CTFd Docker Containers Plugin

A plugin to create containerized challenges for your CTF contest.

Table of Contents

  1. Getting Started
  2. Usage
  3. Demo
  4. Roadmap
  5. License
  6. Contact

Getting Started

This section provides instructions for setting up the project locally.

Prerequisites

To use this plugin, you should have:

  • Experience hosting CTFd with Docker
  • Basic knowledge of Docker
  • SSH access to remote servers (if using remote Docker)

Installation

  1. Clone this repository:
    git clone https://github.com/phannhat17/CTFd-Docker-Plugin.git
  2. Rename the folder:
    mv CTFd-Docker-Plugin containers
  3. Move the folder to the CTFd plugins directory:
    mv containers /path/to/CTFd/plugins/

Back to top


Usage

Using Local Docker Daemon

Case A: CTFd Running Directly on Host:

  • Go to the plugin settings page: /containers/settings
  • Fill in all fields except the Base URL.

Settings Example

Case B: CTFd Running via Docker:

  • Map the Docker socket into the CTFd container by modify the docker-compose.yml file:
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.

Using Remote Docker via SSH

For remote Docker, the CTFd host must have SSH access to the remote server.

Prerequisites:

  • SSH access from the CTFd host to the Docker server
  • The remote server's fingerprint should be in the known_hosts file
  • SSH key files (id_rsa) and an SSH config file should be available

Case A: CTFd Running via Docker

  1. Prepare SSH Config:

    mkdir ssh_config
    cp ~/.ssh/id_rsa ~/.ssh/known_hosts ~/.ssh/config ssh_config/
  2. Mount SSH Config into the CTFd container:

    services:
      ctfd:
        ...
        volumes:
          - ./ssh_config:/root/.ssh:ro
        ...
  3. Restart CTFd:

    docker-compose down
    docker-compose up -d

Case B: CTFd Running Directly on Host

  1. Ensure SSH Access:

    • Test the connection:
      ssh user@remote-server
  2. Configure Docker Base URL:

    • In the CTFd plugin settings page (/containers/settings), set:
      Base URL: ssh://user@remote-server
      
  3. Restart CTFd:

    sudo systemctl restart ctfd

Back to top


Demo

Admin Dashboard

  • Manage running containers
  • Filter by challenge or player

Manage Containers

Challenge View

Web Access TCP Access
Web TCP

Live Demo

Live Demo

Back to top


Roadmap

  • Support for user mode
  • Admin dashboard with team/user filtering
  • Compatibility with the core-beta theme
  • Monitor share flag
  • Monitor detail on share flag
  • Prevent container creation on solved challenge

For more features and known issues, check the open issues.

Back to top


License

Distributed under the MIT License. See LICENSE.txt for details.

This plugin is an upgrade of andyjsmith's plugin with additional features.

If there are licensing concerns, please reach out via email (contact below).

Back to top


Contact

Phan Nhat

Back to top

About

CTFd plugin allowing for individual Docker containers per team

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 53.8%
  • HTML 33.4%
  • JavaScript 12.8%