-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
155 lines (130 loc) · 4.62 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
ARG IMAGE=ubuntu:20.04
FROM ${IMAGE} AS base
# Args
ARG PROXY
ARG NO_PROXY="localhost,127.0.0.1"
# Env
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV TZ=Asia/Shanghai
ENV HTTP_PROXY=${PROXY}
ENV HTTPS_PROXY=${PROXY}
ENV NO_PROXY=${NO_PROXY}
RUN if [ "$PROXY" != "" ]; then \
echo "Using proxy: ${PROXY}" && \
echo "Acquire::http::Proxy \"${PROXY}\";" > /etc/apt/apt.conf.d/proxy.conf && \
echo "Acquire::https::Proxy \"${PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf && \
sed -i 's@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list && \
sed -i 's@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list; \
fi
# Install
RUN apt-get update && apt-get install -y build-essential wget
# --- Stage 2: Build Python ---
FROM base AS python-build
ARG PYTHON_VERSION=3.12.0
RUN apt-get install -y zlib1g-dev \
libssl-dev \
libffi-dev \
libsqlite3-dev \
libbz2-dev \
liblzma-dev \
libreadline-dev \
libncursesw5-dev \
libgdbm-dev \
libnss3-dev \
uuid-dev && \
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
tar xzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
./configure --enable-optimizations && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf Python-${PYTHON_VERSION}*
# --- Stage 3: gdb ---
FROM python-build AS gdb-build
ARG GDB_VERSION=15.2
ARG GDB_MULTIARCH=no
RUN apt-get install -y libgmp-dev libmpfr-dev&& \
wget https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.gz && \
tar xzf gdb-${GDB_VERSION}.tar.gz && \
cd gdb-${GDB_VERSION} && \
if [ "$GDB_MULTIARCH" = "yes" ]; then \
./configure --with-python=python3 --enable-targets=all; \
else \
./configure --with-python=python3; \
fi && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf gdb-${GDB_VERSION}* && \
rm -rf /var/lib/apt/lists/*
# --- Stage 4: Ruby ---
FROM base AS ruby-build
ARG RUBY_VERSION=3.2.6
RUN apt-get install -y \
libssl-dev \
libreadline-dev \
zlib1g-dev \
autoconf \
bison \
libyaml-dev \
libgdbm-dev \
libncurses5-dev \
libffi-dev
RUN wget https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-${RUBY_VERSION}.tar.gz && \
tar xzf ruby-${RUBY_VERSION}.tar.gz && \
cd ruby-${RUBY_VERSION} && \
./configure --disable-install-doc && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf ruby-${RUBY_VERSION}* && \
rm -rf /var/lib/apt/lists/*
# --- Stage 5: Final ---
FROM base AS final
COPY --from=gdb-build /usr/local /usr/local
COPY --from=ruby-build /usr/local /usr/local
RUN apt-get install -y libyaml-0.2 git tmux && \
if [ "$HTTP_PROXY" != "" ]; then \
echo "Using proxy: ${HTTP_PROXY}" && \
git config --global http.proxy ${HTTP_PROXY} && \
git config --global https.proxy ${HTTP_PROXY}; \
fi && \
gem install --no-document one_gadget seccomp-tools && \
pip3 install --no-cache-dir ropgadget pwntools ropper pwno
RUN git clone --depth 1 https://github.com/pwndbg/pwndbg ~/.local/pwndbg && \
cd ~/.local/pwndbg && \
./setup.sh && \
git clone --depth 1 https://github.com/scwuaptx/Pwngdb.git ~/.local/Pwngdb && \
wget -q https://raw.githubusercontent.com/bata24/gef/dev/install.sh -O- | sh && \
mkdir -p ~/.local/gef && \
mv /root/.gdbinit-gef.py ~/.local/gef/gef.py
RUN apt-get install -y fish curl && \
mkdir -p ~/.config/fish && \
# 安装 fisher 包管理器
wget -qO- https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | \
fish -c "source && fisher install jorgebucaran/fisher" && \
# 安装一些有用的 fish 插件
fish -c "fisher install jethrokuan/z" && \
fish -c "fisher install PatrickF1/fzf.fish" && \
# 设置为默认 shell
chsh -s /usr/bin/fish
# ADD YOUR PACKAGES HERE
# RUN apt-get install -y <your-package> --no-install-recommends
RUN apt-get remove -y ruby-dev python3-pip gdb python3-dev python3-venv python3-setuptools && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf ~/.cache/pypoetry/* && \
pip3 cache purge && \
rm -rf ~/.cache/pip && \
gem cleanup && \
rm -rf /usr/local/lib/ruby/gems/*/cache/ && \
rm -rf ~/.gem && \
# 一些优化
ln -s /usr/local/bin/python3 /usr/local/bin/python && \
ln -s /usr/local/bin/pip3 /usr/local/bin/pip
COPY scripts/.gdbinit /root/.gdbinit
COPY scripts/config.fish /root/.config/fish/config.fish
COPY scripts/.tmux.conf /root/.tmux.conf
CMD ["/usr/bin/fish"]