-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile.ubuntu-18.04
103 lines (79 loc) · 3.73 KB
/
Dockerfile.ubuntu-18.04
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# used for compile ubuntu 18.04 debugging pwn image
# author: roderick
# date: 2024-04-21
# docker build --no-cache --build-arg BUILD_VERSION=18.04 -t debug_pwn_env:18.04 . -f Dockerfile.ubuntu-18.04
ARG BUILD_VERSION
FROM ubuntu:$BUILD_VERSION
ARG DEBIAN_FRONTEND=noninteractive
ARG HUB_DOMAIN=github.com
ARG NORMAL_USER_NAME=ctf
ENV TZ=Etc/UTC
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
WORKDIR /root
RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y --fix-missing python3 python3-pip python3-dev lib32z1 \
xinetd curl gcc gdb gdbserver g++ git libssl-dev libffi-dev build-essential tmux patchelf \
vim iputils-ping gdb-multiarch \
file net-tools socat ruby ruby-dev locales autoconf automake libtool make && \
gem install one_gadget && \
gem install seccomp-tools -v 1.5.0 && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
# 先执行容易失败的操作
RUN git clone https://${HUB_DOMAIN}/pwndbg/pwndbg && \
cd ./pwndbg && git checkout ubuntu18.04-final && \
./setup.sh
RUN python3 -m pip install --upgrade pip && \
git clone https://${HUB_DOMAIN}/hugsy/gef.git && \
git clone https://${HUB_DOMAIN}/RoderickChan/Pwngdb.git && \
git clone https://${HUB_DOMAIN}/Gallopsled/pwntools && \
pip3 install --upgrade --editable ./pwntools && \
git clone https://${HUB_DOMAIN}/RoderickChan/pwncli.git && \
pip3 install --upgrade --editable ./pwncli && \
pip3 install ropper capstone z3-solver qiling lief
COPY ./gdb-gef /bin
COPY ./gdb-pwndbg /bin
COPY ./update.sh /bin
COPY ./test-this-container.sh /bin
COPY ./heaptrace /bin
COPY ./.tmux.conf ./
COPY ./.gdbinit ./
COPY ./flag /
COPY ./flag /flag.txt
RUN chmod +x /bin/gdb-gef /bin/gdb-pwndbg /bin/update.sh /bin/test-this-container.sh /bin/heaptrace && \
echo "root:root" | chpasswd
# normal user
RUN useradd ${NORMAL_USER_NAME} -d /home/${NORMAL_USER_NAME} -m -s /bin/bash -u 1001 && \
echo "${NORMAL_USER_NAME}:${NORMAL_USER_NAME}" | chpasswd && \
cp -r /root/pwndbg /home/${NORMAL_USER_NAME} && \
cp -r /root/gef /home/${NORMAL_USER_NAME} && \
cp -r /root/pwntools /home/${NORMAL_USER_NAME} && \
cp -r /root/Pwngdb /home/${NORMAL_USER_NAME} && \
cp -r /root/pwncli /home/${NORMAL_USER_NAME} && \
cp /root/.tmux.conf /home/${NORMAL_USER_NAME} && \
cp /root/.gdbinit /home/${NORMAL_USER_NAME} && \
cp /flag /home/${NORMAL_USER_NAME} && \
cp /flag.txt /home/${NORMAL_USER_NAME} && \
chown -R ${NORMAL_USER_NAME}:${NORMAL_USER_NAME} /home/${NORMAL_USER_NAME}
USER ${NORMAL_USER_NAME}:${NORMAL_USER_NAME}
WORKDIR /home/${NORMAL_USER_NAME}
RUN python3 -m pip install --upgrade pip && pip3 install --prefix ~/.local --upgrade --editable ./pwntools && \
pip3 install --prefix ~/.local --upgrade --editable ./pwncli
# switch to root and install zsh
USER root:root
RUN apt-get install -y sudo zsh && usermod -s /bin/zsh ${NORMAL_USER_NAME} && \
echo "${NORMAL_USER_NAME} ALL=(ALL) NOPASSWD : ALL" | tee /etc/sudoers.d/${NORMAL_USER_NAME}sudo
# switch 2 normal user
USER ${NORMAL_USER_NAME}:${NORMAL_USER_NAME}
WORKDIR /home/${NORMAL_USER_NAME}
# install on-my-zsh
RUN curl -fsSL -O https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh && \
chmod +x ./install.sh && \
sed -i -e 's/read[[:space:]]*-r[[:space:]]*opt/opt=n/g' ./install.sh && \
./install.sh && \
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && \
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
COPY ./.zshrc ./
# expose some ports
EXPOSE 20 21 22 80 443 23946 10001 10002 10003 10004 10005
CMD ["/bin/update.sh"]