I recently took up an assignment where I had to set up and host a Capture the Flag (CTF) event. I have only ever participated in CTFs, never actually hosted one. Therefore, this was a new and exciting experience. I researched and found multiple platforms to host my CTF on, but I decided to go with CTFd due to the fact that it open source and had a vast library of features that I required for my event:
- Allows participants to compete individually or in teams
- Enables admin (me) to track all participants submissions and scores
- Back up our challenges, event status and scores and import it to a new CTFd instance if necessary
With all these features and more, CTFd was an ideal platform. Let’s get started on the steps I took to set it up, shall we?
- Virtual Private Server
I will be making use of the latest version of Ubuntu: Ubuntu 20.04. It can be downloaded here.
First, we will need to install Docker. This is important as CTFd will be running on our webserver as a Docker container. Here is the command I used:
# sudo apt install docker.io docker-compose
After installation, we can verify if the download was successful using these commands:
# docker --version
# docker-compose --version
These were my results:
After installation, we should be able to run docker and docker-machine command line tools which we will be using for deployment.
Cloning the CTFd GitHub Repository
Next, I used this command to clone the CTFd GitHub repository into my machine:
# git clone https://github.com/CTFd/CTFd.git
I changed to the root user and entered the CTFd directory that was created using these commands:
# sudo su
# cd CTFd
Building the CTFd Docker Container
Since we have everything installed in the CTFd folder, all we need to do now is build the CTFd container by entering this command:
# docker-compose up
Wait for the build to finish, and then launch up your server’s IP address.
We are done! Now, you can set up and customise your very own CTF and access it using the IP address.
Have fun 😀