-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (35 loc) · 1.29 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
FROM i386/ubuntu:18.04 AS builder
RUN apt-get update && apt-get install -y gcc-4.8 make
WORKDIR /build
COPY src/* ./
RUN make
FROM ghcr.io/svuctf/base-v2/xinetd:latest
# Copy initialization script and xinetd configuration
COPY --chmod=500 init.sh /init.sh
COPY xinetd.conf /etc/xinetd.conf
# Set up the CTF environment
RUN chmod -R 750 /home/ctf && \
mkdir -p /home/ctf/lib64 && \
mkdir -p /home/ctf/dev && \
mkdir -p /home/ctf/bin && \
mkdir -p /home/ctf/lib/x86_64-linux-gnu && \
mkdir -p /home/ctf/lib32
# Copy necessary libraries from builder stage
COPY --from=builder /lib/i386-linux-gnu/libc.so.6 /home/ctf/lib/i386-linux-gnu/
COPY --from=builder /lib/ld-linux.so.2 /home/ctf/lib/
# Copy the challenge binary
COPY --from=builder --chmod=500 /build/ret2text32 /home/ctf/ret2text32
# Set up device nodes
RUN 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/*
# Copy necessary binaries abd binaries
RUN cp /lib/ld-musl-x86_64.so.1 /home/ctf/lib/ && \
cp /bin/sh /home/ctf/bin && \
cp /bin/ls /home/ctf/bin && \
cp /bin/cat /home/ctf/bin && \
cp /bin/base64 /home/ctf/bin
RUN chown -R ctf:ctf /home/ctf
CMD ["xinetd", "-dontfork"]