GZCTF搭建过程
1、配置项目
vim appsettings.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 { "AllowedHosts" : "*" , "ConnectionStrings" : { "Database" : "Host=db:5432;Database=gzctf;Username=postgres;Password=tjqcjs123!" }, "EmailConfig" : { "SenderAddress" : "" , "SenderName" : "" , "UserName" : "" , "Password" : "" , "Smtp" : { "Host" : "localhost" , "Port" : 587 } }, "XorKey" : "tjqcjs123!" , "ContainerProvider" : { "Type" : "Docker" , // or "Kubernetes" "PortMappingType" : "Default" , // or "PlatformProxy" "EnableTrafficCapture" : false , "PublicEntry" : "120.55.243.101" , // or "xxx.xxx.xxx.xxx" // optional "DockerConfig" : { "SwarmMode" : false , "Uri" : "unix:///var/run/docker.sock" } }, "RequestLogging" : false , "DisableRateLimit" : true , "RegistryConfig" : { "UserName" : "" , "Password" : "" , "ServerAddress" : "" }, "CaptchaConfig" : { "Provider" : "None" , // or "CloudflareTurnstile" or "GoogleRecaptcha" "SiteKey" : "..." , "SecretKey" : "..." , // optional "GoogleRecaptcha" : { "VerifyAPIAddress" : "https://www.recaptcha.net/recaptcha/api/siteverify" , "RecaptchaThreshold" : "0.5" } }, "ForwardedOptions" : { "ForwardedHeaders" : 7, "ForwardLimit" : 1, "TrustedNetworks" : ["172.27.83.0/8" ] } }
POSTGRES_PASSWORD
: 数据库密码
XOR_KEY
: 用于加密比赛私钥的随机字符串
PUBLIC_ENTRY
: 外部访问地址,可以是 IP 或域名
TrustedNetworks
:修改成自己的对应ip,防止网段冲突问题
vim docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 services: gzctf: image: registry.cn-shanghai.aliyuncs.com/gztime/gzctf:develop restart: always environment: - "GZCTF_ADMIN_PASSWORD=Nbcc123!" - "LC_ALL=zh_CN.UTF-8" ports: - "80:8080" volumes: - "./data/files:/app/files" - "./appsettings.json:/app/appsettings.json:ro" - "/var/run/docker.sock:/var/run/docker.sock" depends_on: - db db: image: postgres:alpine restart: always environment: - "POSTGRES_PASSWORD=tjqcjs123!" volumes: - "./data/db:/var/lib/postgresql/data"
POSTGRES_PASSWORD
:上面的数据库密码
GZCTF_ADMIN_PASSWORD
:管理员账号密码
2、启动项目
访问端口 发现搭建成功
默认用户名 Admin
3、搭建web 动态flag题目
编写好dockerfile 以及源码文件 上传到服务器中
3.1示例Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 FROM php:8.0 -apacheWORKDIR /var/www/html COPY . . RUN chmod +x /var/www/html/flag.sh ENV GZCTF_FLAG="nccctf{ass21v}" RUN sed -i 's/\r//' /var/www/html/flag.sh EXPOSE 80 CMD ["/bin/bash" , "-c" , "/var/www/html/flag.sh && apache2-foreground" ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #!/bin/sh if [ ! -f /var/www/html/flag.txt ]; then echo "flag{testflag}" > /var/www/html/flag.txt echo "flag.txt created with initial content" else echo "flag.txt already exists" fi echo "flag.txt content before sed:" cat /var/www/html/flag.txtsed -i "s/flag{testflag}/$GZCTF_FLAG /" /var/www/html/flag.txt echo "flag.txt content after sed:" cat /var/www/html/flag.txtunset GZCTF_FLAG
3.3 构建镜像
上传到服务器后
版本号可不写,默认最新
1 docker build -t <镜像名 > :版本号 .
3.4 上传dockerhub
登录docker服务器 (大概率需要爬墙)
tag 打标签 仓库名可以随意取 版本号可不写
1 2 3 docker login docker tag <镜像名> soupgod/<仓库名> :<版本号> docker push soupgod/sssrc
4、拉取测试
gzctf管理账号新建题目
5、题目合集
web题
1 2 3 soupgod/dsb_web soupgod/sssrc soupgod/gzctf_ezcalc
1、单身杯反序列化
2、jwt爆破
3、简单计算