File tree Expand file tree Collapse file tree 5 files changed +100
-0
lines changed
Expand file tree Collapse file tree 5 files changed +100
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM ubuntu:20.04
2+
3+ RUN sed -i "s/http:\/\/ archive.ubuntu.com/http:\/\/ mirrors.tuna.tsinghua.edu.cn/g" /etc/apt/sources.list && \
4+ apt-get update && apt-get -y dist-upgrade && \
5+ apt-get install -y lib32z1 xinetd && \
6+ apt-get install -y python3 && \
7+ apt-get install -y python3-pip && \
8+ pip3 install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple
9+
10+
11+ COPY ./src/ctf.xinetd /etc/xinetd.d/ctf
12+ COPY ./service/docker-entrypoint.sh /
13+
14+ RUN chmod +x /docker-entrypoint.sh
15+
16+ COPY ./src/server.py /home/server.py
17+
18+ RUN echo "Blocked by ctf_xinetd" > /etc/banner_fail && chmod +x /docker-entrypoint.sh && chmod -R 777 /home/
19+ CMD ["/docker-entrypoint.sh" ]
20+
21+ EXPOSE 9999
Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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 /flag
25+
26+
27+ # 启动 xinetd 服务
28+ /etc/init.d/xinetd start;
29+ sleep infinity;
30+ rm -rf /docker-entrypoint.sh
Original file line number Diff line number Diff line change 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+ server = /usr/sbin/chroot
12+ # replace helloworld to your program(要跑的服务)
13+ server_args = --userspec=1000:1000 / python3 /home/server.py
14+ banner_fail = /etc/banner_fail
15+ # safety options
16+ per_source = 10 # the maximum instances of this service per source IP address
17+ rlimit_cpu = 20 # the maximum number of CPU seconds that the service may use
18+ #rlimit_as = 1024M # the Address Space resource limit for the service
19+ #access_times = 2:00-9:00 12:00-24:00
20+ }
Original file line number Diff line number Diff line change 1+ WELCOME = '''
2+ _ ______ _ _ _ _
3+ | | | ____| (_) | | (_) |
4+ | |__ | |__ __ _ _ _ __ _ __ ___ _ __ | | __ _ _| |
5+ | '_ \| __| / _` | | '_ \| '_ \ / _ \ '__| _ | |/ _` | | |
6+ | |_) | |___| (_| | | | | | | | | __/ | | |__| | (_| | | |
7+ |_.__/|______\__, |_|_| |_|_| |_|\___|_| \____/ \__,_|_|_|
8+ __/ |
9+ |___/
10+ '''
11+
12+ print (WELCOME )
13+
14+ print ("Welcome to the python jail" )
15+ print ("Let's have an beginner jail of calc" )
16+ print ("Enter your expression and I will evaluate it for you." )
17+ input_data = input ("> " )
18+ print ('Answer: {}' .format (eval (input_data )))
You can’t perform that action at this time.
0 commit comments