Introduction to CTFd#
CTFd is a free and open-source CTF (Capture the Flag) platform that provides a powerful set of tools and solutions for creating, organizing, managing, and hosting CTF competitions and challenging activities. CTFd is designed to meet the needs of users with various skill levels and backgrounds, offering an easy-to-use and configurable interface.
CTFd supports various types of challenges, including Web, reverse engineering, cryptography, binaries, forensics, and miscellaneous, and provides multiple competition types, including individual competitions, team competitions, and directed competitions.
CTFd also offers a range of powerful plugins and themes that can be configured and extended as needed.
CTFd Installation#
- Set up using this article, simple and easy to understand
https://mp.weixin.qq.com/s/oMI9h_hBc373poVsR2CiVw
The project address based on the above article:
GitHub - Un1kTeam/CTFd: CTFs as you need them
This project version is 3.3.0, which can be localized, and also includes frp, ctfd-whale @ 138b042, ctf-whale can be downloaded and installed separately.
The general process is as follows:
- Create a single server cluster, then join the cluster
- View nodes and get the id value
- Update the label information on the docker node
- Once the setup is complete, you can start building the image
- After finishing, open the browser and visit http://127.0.0.1:9124
Notes:
- Sometimes due to network issues, you may need to run
docker-compose up -d
multiple times. - When pulling the environment with docker, there may be issues with the internal ubuntu container not being able to access the aliyun source, so you need to set the DNS resolution in ubuntu as follows:
Simplified Installation#
- (Optional) A VMware version already set up by someone else: VMware Virtual Machine Version
Directly using someone else's virtual machine setup can be a bit troublesome to set up yourself, here I will record some issues and experiences during the usage process.
- There is also an automatic setup script for CTFd that uses the nip.io domain.
Project address: GitHub - pwnthebox/ctfd-auto-deploy
The values that need to be manually entered are as follows:
Http Domain Suffix
: domain/ip
External Http Port
: target machine http mapping port
(cannot be 80 here, as 80 is assigned to CTFd)
Direct Minimum/Maximum Port
: target machine port open range
CTFd Environment Testing#
Open the browser and enter http://127.0.0.1:9124 to access, returning the following interface:
After setting everything step by step, if the banner size is too large there may be some issues with the style, once the setup is complete, it can be used.
Dynamic Target Configuration#
After logging in, enter the management interface and click on the Whale plugin
If there is no domain, the Http Domain Suffix
can be left blank.
Fill in the Direct IP Address
with the IP address of the virtual machine.
Create Questions#
Select dynamic_docker
Write the question title, category, description, etc. For the docker image, fill in the address of the docker image, change the Frp Redirect Type to Direct, and set the Frp Redirect Port to the internal port of the docker container, which is usually specified in the dockerfile.
Set the score for the question, Initial Value is the initial score, Decay Limit is the number of decay times, after a question is answered twice, it starts using the score set in Minimum Value, and Score Type is set to Dynamic Score. If the Decay Limit is set to 0 and no minimum score setting is made, then Score Type can only be changed to Static Score.
After creating the question, test it.
Visit the question environment
Test submitting the flag.
Thus, the environment setup is complete.
Other Settings and Notes#
Dynamic Flag Generation in Dockerfile#
CTFd Page Management Settings#
- Modify the homepage
Mapping CTFd Platform to the External Network#
After the CTFd platform is installed, settings can be done at any time, not necessarily before setting up the CTFd platform. The following places need to be set:
- Map the platform port (9124) on the router at the internet exit.
- Map the environment port (28000-28200) on the router at the internet exit.
- Configure whale (as shown in the figure)
In the Frps config template [generated]
, set subdomain_host
to the public IP or domain.
The above settings will suffice.
Read-only File System Solution (Untested)#
Modify the docker-compose.yml
file, remove the :ro
on line 22.
Some Target Environments Cannot Access the Internet (Untested)#
You need to modify the docker-compose.yml file, as shown in the figure below:
The container has started, and modifying this part will cause an error.
CTFd Localization#
Import the files into the CTFd directory.
Project address: GitHub - Gu-f/CTFd_chinese_CN: Localization records for various versions of the CTFd platform. key: Chinese, localization, translation, Chinese, CN, CTFd
The localized version has been pushed to the hub docker.
References#
ctfd-whale/install.zh-cn.md at master · frankli0324/ctfd-whale · GitHub
How to Properly Use Docker to Create a CTF Question - Von's Blog | Von Blog
GitHub - antlers12/CTFd_sqlilabs
CTFd&ctfd-whale Dynamic Target Machine Setup and Maintenance · Yuque
GitHub - CTFTraining/CTFTraining: CTF Training Classic Problem Reproduction Environment
BUUCTF Question Contribution Guide – glzjin