Hosting a CTF
Originally published on September 4, 2021 on my previous blog.
Introduction
Creating a full-fledged platform to host a CTF is very time taking. Moreover, this task looks almost impossible if you are not a developer. This blog will tell how I created the CTF platform for my School InfoSec club using CTFd within a few minutes.
Choosing the Server
To host the platform, you need a server that will be accessible to everyone. For the server, you can create one from Digital Ocean. You have to decide what specifications you require based on the expected participants. In my case, I expected 100 participants, so I selected the following specifications:
- RAM: 8GB
- Cpu: 4vCPUs
- Storage: 100GB
- Version: Ubuntu 20.04 LTS x64
After the instance is created, Digital Ocean will provide you with an IP address and password. You can log in to your server with the credentials using Putty
Setting up CTF Platform
After logging in to the server, the first thing you need to do is update it and install the requirements. You will only need to install git, docker, and docker-compose.
sudo apt update sudo apt install docker docker-compose gitNow we need to clone the CTFd repo and move into it.
git clone https://github.com/CTFd/CTFd cd CTFdCreate a random key. This is used by the Application for security purpose. I am storing the key in the
.ctfd_secret_keyfile.head -c 64 /dev/urandom > .ctfd_secret_key(Optional) Change the number of workers in
docker-compose.ymlfile. The higher the number the better it can manage traffic. In my case, I used 4 workers.Running the platform
sudo docker-compose up
That's it, now your platform will be running in port 80 and 8080. You can test it from your machine by going to localhost:8080 or using any other machine and going to the given IP.
Now you need the rest of the setup from the platform. The guide for that setup is available at the Repo.
The basic requirement for the platform is covered. But if you are hosting it at a global level, then you need to implement security feature like Rate limiting and Firewall to the server. You also need the get a domain for your IP from GoDaddy or somewhere else. You can check this article for more.
Firewall Setup
I will cover the basic steps required to setup a firewall which will only allow http/https and SSH traffic to the server.
sudo apt update
sudo ufw allow 'Nginx Full'
sudo ufw allow 'OpenSSH'
sudo ufw enable
Comments
Join the discussionNo comments yet. Be the first to comment.