forked from Windforce17/base_pwn_xinetd_kafel_1804
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
89 lines (75 loc) · 2.64 KB
/
Dockerfile
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
FROM ubuntu:18.04 as build-stage
WORKDIR /opt
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \
sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list && \
sed -i '/security/d' /etc/apt/sources.list && \
apt-get update -y && \
apt-get upgrade -y
RUN apt-get install -y wget bison flex build-essential unzip
RUN apt-get build-dep -y xinetd
RUN wget https://github.com/google/kafel/archive/master.zip && \
unzip master.zip && \
rm master.zip && \
mv kafel-master kafel && \
cd kafel && make
RUN wget https://github.com/Asuri-Team/xinetd-kafel/archive/master.zip && \
unzip master.zip && \
rm master.zip && \
mv xinetd-kafel-master xinetd && \
cd xinetd && \
./configure --prefix=/usr --with-kafel=/opt/kafel --with-loadavg --with-libwrap && \
make
FROM ubuntu:18.04
LABEL Organization="CTFTraining" Author="Virink <[email protected]>"
MAINTAINER Virink@CTFTraining <[email protected]>
COPY _files /tmp
COPY --from=build-stage /opt/xinetd/xinetd/xinetd /tmp/xinetd
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \
sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list && \
sed -i '/security/d' /etc/apt/sources.list && \
apt-get update -y && \
apt-get upgrade -y; \
# netbase tcpdump xinetd
apt-get install -y --no-install-recommends netbase tcpdump xinetd; \
# lib
apt-get install -y lib32ncurses5 lib32z1 lib32stdc++6; \
# xinetd configure
mkdir -p /etc/xinetd.d && \
mv /tmp/xinetd.conf /etc/xinetd.conf && \
mv /tmp/pwn.xinetd.conf /etc/xinetd.d/pwn && \
mv /tmp/pwn.kafel /etc/pwn.kafel && \
mv /tmp/banner_fail /etc/banner_fail && \
mv /tmp/flag.sh /flag.sh && \
mv /tmp/start.sh /start.sh && \
mv /tmp/xinetd /usr/sbin/xinetd && \
chmod +x /start.sh && \
chmod +x /usr/sbin/xinetd; \
# pwn home dir
useradd -U -m ctf && \
mkdir -p /home/ctf && \
# lib
cp -R /lib* /home/ctf && \
cp -R /usr/lib* /home/ctf; \
# bin
mkdir /home/ctf/bin && \
cp /bin/sh /home/ctf/bin && \
cp /bin/ls /home/ctf/bin && \
cp /bin/cat /home/ctf/bin; \
# pwn home dir permission
chown -R root:ctf /home/ctf; \
chmod -R 750 /home/ctf && \
# dev
mkdir /home/ctf/dev && \
mknod /home/ctf/dev/null c 1 3 && \
mknod /home/ctf/dev/zero c 1 5 && \
mknod /home/ctf/dev/random c 1 8 && \
mknod /home/ctf/dev/urandom c 1 9 && \
chmod 666 /home/ctf/dev/*; \
# clean
apt-get clean && \
# /var/lib/apt/lists/*
rm -rf /tmp/* /var/tmp/*;
WORKDIR /home/ctf
VOLUME /var/lib/tcpdump
EXPOSE 10000
CMD ["/start.sh"]