Skip to content

Commit 5481d07

Browse files
committed
增加pwn-ubuntu_22.04,并更新项目说明
1 parent 350ed11 commit 5481d07

File tree

12 files changed

+173
-11
lines changed

12 files changed

+173
-11
lines changed

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
python-version: "3.10"
2121

2222
- name: Package
23-
run: python3 ./workflow-action/deploy.py
23+
run: python3 ./source-workflow/deploy.py
2424

2525
- name: Release
2626
uses: ncipollo/release-action@v1
2727
with:
28-
tag: newest
28+
tag: 已打包模板下载
2929
artifacts: "release/*"
30-
bodyFile: "./workflow-action/body.md"
30+
bodyFile: "./source-workflow/body.md"

README.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
三种动态flag部署方式,支持GZCTF、CTFd、安恒DASCTF等支持Docker动态部署题目靶机的平台
1111

12-
**有问题请开issue,好用请点star**
12+
**有问题请开issue,好用请点star,有问题的话欢迎通过 [CTF-Archives售后快速服务群](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=KFamhBpmURTZpndhc0MI7_1l3a6Xezrf&authKey=Yenwm7%2B%2F%2FT%2BtSXCSyr%2B7fYS47Ot0MwFqesH4HOLT8ZADE2e9XO6AS96HQvjxh%2B%2BG&noverify=0&group_code=894957229) 联系维护人员寻求帮助**
1313

14-
## 请注意,此仓库内的模板仅在Linux环境(linux/amd64)下进行测试并保证可用性,如果为windows(windows/amd64)或者macos(linux/arm)等其他架构,不保证不会出问题😔
14+
## 请注意,此仓库内的模板仅在Linux环境(linux/amd64)下进行测试并保证可用性,如果为windows(windows/amd64)或者macos(linux/arm)等其他架构,不保证可用性😔
1515

1616
## 关于每个模板内的文件内容
1717

@@ -69,12 +69,16 @@ sed -i ""s/\r//"" docker-entrypoint.sh
6969

7070
请注意,`sed`指令在`unix(macos)`下的预期执行效果与`linux`下的预期执行效果不同
7171

72-
## 如有其他问题
72+
## A little advertisement
7373

74-
欢迎直接提issue,一般于三个工作日内就能有回复,也请遇到问题的时候能提供当前的整体题目文件,以及具体的报错/信息
74+
[Randark-JMT](https://github.com/Randark-JMT) 可以无偿为CTF平台搭建、题目打包提供一定帮助,欢迎联系😘
7575

76-
也欢迎通过 [CTF-Archives售后快速服务群](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=KFamhBpmURTZpndhc0MI7_1l3a6Xezrf&authKey=Yenwm7%2B%2F%2FT%2BtSXCSyr%2B7fYS47Ot0MwFqesH4HOLT8ZADE2e9XO6AS96HQvjxh%2B%2BG&noverify=0&group_code=894957229) 或者 [CTF快速入门手册 - QQ群聊](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=wJ35e-T-qSlU7Y3Cs-PAasrAvZfRSc9k&authKey=WNEQbZUpolxgfKjUHHoUIoTBvSnvk2jZtcyWlhaDcUZ6ZYGgvywqi1ah5D7UwUrg&noverify=0&group_code=590430891) 联系维护人员寻求帮助
76+
## 参考与鸣谢
7777

78-
## A little advertisement
78+
[https://github.com/CTFTraining](https://github.com/CTFTraining)
7979

80-
[Randark-JMT](https://github.com/Randark-JMT) 可以无偿为CTF平台搭建、题目打包提供一定帮助,欢迎联系😘
80+
感谢**glzjin-赵总****mozhu1024-陌竹**师傅们的项目,根据上述仓库,此项目才有了雏形,感谢他们为CTF事业做出的巨大贡献
81+
82+
[qsnctf / qsnctf_base_docker_images 青少年CTF基础Docker镜像](https://github.com/qsnctf/qsnctf_base_docker_images)
83+
84+
感谢**末心**师傅对相关模板作出的建议与努力

pwn-ubuntu_22.04/Dockerfile

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM ubuntu:22.04
2+
3+
# 制作者信息
4+
LABEL auther_template="CTF-Archives"
5+
6+
# apt更换镜像源,并安装相关依赖
7+
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list && \
8+
sed -i 's@//.*security.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
9+
RUN apt-get update && apt-get -y dist-upgrade && \
10+
apt-get install -y lib32z1 xinetd
11+
12+
# 新建用户,并进行账户改变
13+
RUN useradd -m ctf
14+
WORKDIR /home/ctf
15+
16+
# 复制相关lib,并处理环境
17+
RUN cp -R /usr/lib* /home/ctf
18+
19+
# 配置特殊管道映射
20+
RUN mkdir /home/ctf/dev && \
21+
mknod /home/ctf/dev/null c 1 3 && \
22+
mknod /home/ctf/dev/zero c 1 5 && \
23+
mknod /home/ctf/dev/random c 1 8 && \
24+
mknod /home/ctf/dev/urandom c 1 9 && \
25+
chmod 666 /home/ctf/dev/*
26+
27+
# 设置xinetd启动之后,chroot限制能使用的bin程序
28+
RUN mkdir /home/ctf/bin && \
29+
cp /bin/sh /home/ctf/bin && \
30+
cp /bin/ls /home/ctf/bin && \
31+
cp /bin/cat /home/ctf/bin && \
32+
cp /usr/bin/timeout /home/ctf/bin
33+
34+
# 部署xinetd服务
35+
COPY ./config/ctf.xinetd /etc/xinetd.d/ctf
36+
RUN echo "Blocked by ctf_xinetd" > /etc/banner_fail
37+
38+
# 复制容器启动脚本
39+
COPY ./service/docker-entrypoint.sh /
40+
RUN chmod +x /docker-entrypoint.sh
41+
42+
# 部署程序
43+
COPY ./src/attachment /home/ctf/attachment
44+
45+
# 初始化flag
46+
RUN chown -R root:ctf /home/ctf && \
47+
chmod -R 750 /home/ctf && \
48+
touch /home/ctf/flag && \
49+
chmod 744 /home/ctf/flag
50+
51+
# [可选]指定对外暴露端口,对于GZCTF等平台,强制EXPOSE可能会造成非预期端口泄露,请酌情启用
52+
# EXPOSE 9999
53+
54+
# 指定容器入口点
55+
ENTRYPOINT ["/bin/bash","/docker-entrypoint.sh"]

pwn-ubuntu_22.04/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# pwn-ubuntu_22.04
2+
3+
## 环境说明
4+
5+
提供 `Ubuntu 22.04 GLIBC 2.35` 的基础环境,并已经添加 `lib32z1` + `xinetd` 软件包,并基于 `xinetd` 实现服务转发,默认暴露端口位于9999
6+
7+
实现:当选手连接到对应端口(默认为9999端口,默认选手使用 `netcat` )的时候,运行 `程序文件`,并将会话转发至选手的连接
8+
9+
镜像做到:
10+
- 选手通过端口连接到容器/靶机
11+
- xinted服务检测到连接,启动一个 `chroot` 会话
12+
- `chroot` 通过参数 `--userspec=1000:1000 /home/ctf` 限制了程序运行时的账户权限,并更改了程序运行时的root根目录环境位置为 `/home/ctf` ,然后在限制环境中启动程序
13+
- `xinted` 将程序会话转发给选手的连接
14+
15+
## 如何使用
16+
17+
将程序文件放入 `./src` 目录即可,文件名请修改为 `attachment` 作为文件名,便于镜像定位程序位置
18+
19+
如果需要更改为自己的文件名,需要在 `./config/ctf.xinetd``./Dockerfile``./service/docker-entrypoint.sh` 中进行修改
20+
21+
程序放置进 `./src` 目录之后,执行
22+
```shell
23+
docker build .
24+
```
25+
即可开始编译镜像
26+
27+
也可以在安放好程序文件之后,直接使用 `./docker/docker-compose.yml` 内的 `docker-compose` 文件实现一键启动测试容器
28+
29+
```shell
30+
cd ./docker
31+
docker-compose up -d
32+
```

pwn-ubuntu_22.04/config/ctf.xinetd

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
service ctf
2+
{
3+
disable = no
4+
socket_type = stream
5+
protocol = tcp
6+
wait = no
7+
user = root
8+
type = UNLISTED
9+
port = 9999
10+
bind = 0.0.0.0
11+
# 设置xinetd连接启动后的服务程序
12+
server = /usr/sbin/chroot
13+
# 设置chroot的相关参数
14+
server_args = --userspec=1000:1000 /home/ctf ./attachment
15+
banner_fail = /etc/banner_fail
16+
# safety options
17+
per_source = 10 # the maximum instances of this service per source IP address
18+
rlimit_cpu = 20 # the maximum number of CPU seconds that the service may use
19+
#rlimit_as = 1024M # the Address Space resource limit for the service
20+
#access_times = 2:00-9:00 12:00-24:00
21+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
services:
3+
test:
4+
build: ../
5+
environment:
6+
# 仅为测试用flag
7+
FLAG: "flag{a63b4d37-7681-4850-b6a7-0d7109febb19}"
8+
ports:
9+
# 设置了暴露端口
10+
- 9999:9999
11+
restart: unless-stopped
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Get the user
4+
user=$(ls /home)
5+
6+
# Check the environment variables for the flag and assign to INSERT_FLAG
7+
if [ "$DASFLAG" ]; then
8+
INSERT_FLAG="$DASFLAG"
9+
export DASFLAG=no_FLAG
10+
DASFLAG=no_FLAG
11+
elif [ "$FLAG" ]; then
12+
INSERT_FLAG="$FLAG"
13+
export FLAG=no_FLAG
14+
FLAG=no_FLAG
15+
elif [ "$GZCTF_FLAG" ]; then
16+
INSERT_FLAG="$GZCTF_FLAG"
17+
export GZCTF_FLAG=no_FLAG
18+
GZCTF_FLAG=no_FLAG
19+
else
20+
INSERT_FLAG="flag{TEST_Dynamic_FLAG}"
21+
fi
22+
23+
# 将FLAG写入文件 请根据需要修改
24+
echo $INSERT_FLAG | tee /home/$user/flag
25+
26+
# 赋予程序运行权限
27+
chmod 711 /home/ctf/attachment
28+
29+
/etc/init.d/xinetd start;
30+
sleep infinity;

pwn-ubuntu_22.04/src/attachment

8.41 KB
Binary file not shown.

source-workflow/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Workflow 相关文件
2+
3+
此文件夹内的文件用于为 Github Action 自动化流提供支持,请勿随意修改

source-workflow/body.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
以下压缩包基于 Github Action 进行自动化打包,**不保证与源码之间的完整正确(已尽力保证)**
2+
3+
可以尝试以下镜像/加速服务
4+
5+
- https://github.ur1.fun/
6+
- https://github.zhlh6.cn/

workflow-action/deploy.py renamed to source-workflow/deploy.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
if (
1414
not directory.name.startswith(".")
1515
and not directory.name.startswith("sp")
16+
and not directory.name.startswith("source")
1617
and os.path.isdir("./" + directory.name)
1718
and directory.name != "release"
1819
):

workflow-action/body.md

-1
This file was deleted.

0 commit comments

Comments
 (0)