From Installation to Competition: Setting Up Your CTFd Environment

2 min read by M1NDB3ND3R
DockerCTF

Introduction to CTFd

CTFd is an open-source Capture The Flag framework designed for ease of use for both administrators and participants. It provides a robust platform for creating, managing, and hosting CTF challenges, making it an excellent choice for educational purposes, competitions, or community events.

Prerequisites

Before diving into the setup, ensure you have the following:

  • A Virtual Private Server (VPS) or a local machine with a Linux distribution (Ubuntu is recommended).
  • Docker and Docker Compose installed on your system.

Step-by-Step Setup Guide

1. Install Docker and Docker Compose

To manage your CTFd instance effectively, you need Docker and Docker Compose. Run the following commands to install them:

sudo apt update
sudo apt install docker.io docker-compose

Verify the installation:

docker --version
docker-compose --version

2. Clone the CTFd Repository

Next, clone the CTFd repository from GitHub:

git clone https://github.com/CTFd/CTFd.git
cd CTFd

3. Build the CTFd Docker Container

Now, build the Docker container using Docker Compose:

docker-compose up -d

This command will download the necessary images and start your CTFd instance in detached mode.

Alternative Method

docker run -p 8000:8000 -it ctfd/ctfd

This command does not need to git clone the repo and build it , we directly pull it from docker hub

4. Accessing CTFd

Once the container is running, access CTFd by navigating to your server’s IP address in a web browser. You will be greeted with the setup page where you can create your admin account and configure basic settings.

5. Creating Your First Challenge

After setting up your admin account, log into the admin panel. To add challenges:

  • Click on the Challenges tab.
  • Select New Challenge.
  • Fill in details such as name, point value, description, and flags (static or regex).
  • Save your challenge, which will now be visible to participants once your CTF event starts.

6. Customizing Your CTF

CTFd allows customization through themes and additional pages. You can create new pages for rules, FAQs, or any other information relevant to your participants using Markdown or HTML.

7. Setting Up Security (Optional)

For added security, consider enabling HTTPS by obtaining an SSL certificate for your domain. This step is crucial if you plan to host your CTF publicly.

Conclusion

Hosting a CTF using CTFd can be a rewarding experience that enhances learning and engagement in cybersecurity. By following these steps, you’ll be well on your way to creating a dynamic platform for participants to test their skills.

Feel free to explore additional features of CTFd as you become more comfortable with the platform. Happy hacking!