forked from RoderickChan/docker_pwn_env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.ubuntu-16.04
133 lines (106 loc) · 5.1 KB
/
Dockerfile.ubuntu-16.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# used for compile ubuntu 16.04 debugging pwn image
# author: roderick
# date: 2024-04-06
# docker build --no-cache --build-arg BUILD_VERSION=16.04 -t debug_pwn_env:16.04 . -f Dockerfile.ubuntu-16.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
# install ruby 2.7
RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y --fix-missing python3 python3-pip python3-dev lib32z1 \
xinetd curl gcc g++ gdbserver git libssl-dev libffi-dev build-essential tmux \
vim iputils-ping \
file net-tools socat locales autoconf automake libtool make wget && \
wget http://ftp.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.gz && \
tar -xzvf ruby-2.7.1.tar.gz && \
cd ruby-2.7.1/ && \
./configure && \
make -j16 && \
make install -j16 && \
gem install one_gadget seccomp-tools && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
# install python 3.8
RUN apt-get install -y zlib1g-dev libbz2-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev \
libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libc6-dev && \
wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz && \
tar -xzvf Python-3.8.6.tgz && \
cd Python-3.8.6 && \
./configure --enable-optimizations && \
make -j16 && make install -j16 && rm -rf /usr/bin/pip3 /usr/bin/python3 /usr/bin/python /usr/bin/pip && \
ln -s /usr/local/bin/python3.8 /usr/bin/python3 && \
ln -s /usr/local/bin/python3.8 /usr/bin/python && \
ln -s /usr/local/bin/pip3.8 /usr/bin/pip3 && \
ln -s /usr/local/bin/pip3.8 /usr/bin/pip
# install gdb manually
RUN apt-get install -y texinfo && \
wget https://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz && \
tar -xzvf gdb-10.2.tar.gz && cd gdb-10.2 && ./configure --enable-targets=all && \
make -j16 && make install -j16
# 先执行容易失败的操作
RUN git clone https://${HUB_DOMAIN}/pwndbg/pwndbg && \
cd ./pwndbg && git checkout ubuntu18.04-final && \
./setup.sh && ./.venv/bin/pip3 install --upgrade --force-reinstall 'requests==2.6.0' urllib3 && \
pip3 install --upgrade --force-reinstall 'requests==2.6.0' urllib3
# install patchelf
RUN wget https://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/universe/p/patchelf/patchelf_0.9-1~ubuntu16.04.3_amd64.deb && \
dpkg -i patchelf_0.9-1~ubuntu16.04.3_amd64.deb
RUN 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
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 && \
pip3 install ropper capstone z3-solver qiling lief
# root 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 pip3 install --upgrade --editable ./pwntools && \
pip3 install --upgrade --editable ./pwncli && \
pip3 install --upgrade --force-reinstall 'requests==2.6.0' urllib3
# 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"]