-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
142 lines (122 loc) · 4.39 KB
/
Copy pathDockerfile
File metadata and controls
142 lines (122 loc) · 4.39 KB
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
# Dockerfile pour compilation & debugging multi-arch (x86_64, ARM32/64, MIPS, RISC-V, Windows…)
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV HOME=/root
# Installe QEMU, toolchains & dev headers, debuggers, Python3 + pwntools
RUN apt-get update && apt-get install -y --no-install-recommends \
# émulation -> pour qemu
binfmt-support \
#qemu-user-static \
#qemu-user \
# toolchains & dev headers (cross) -> pour les tests
build-essential \
gcc \
libc6-dev \
# ARM32/ARMHF -> pour les tests et qemu
gcc-arm-linux-gnueabi \
libc6-dev-armhf-cross \
# ARM64/AARCH64 -> pour les tests et qemu
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \
# MIPS -> pour les tests et qemu
gcc-mips-linux-gnu \
libc6-dev-mips-cross \
# RISC-V64 -> pour les tests et qemu
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
# x86 i386 -> pour les tests et qemu
# lib32gcc-s1 \
# libc6-dev-i386-cross \
libc6-dev-i386-cross \
# Windows PE (x86_64) -> ca c'est pas utile pour le moment
mingw-w64 \
# Debuggers & outils -> important
tmux \
gdb \
gdb-multiarch \
git \
# Python3 & pwntools -> important
python3 \
python3-pip \
python3-venv \
# six -> pour peda
python3-six \
# wget & certif & file -> pour GEF
wget ca-certificates file \
# for qemu :
autoconf \
libtool \
pkg-config \
libglib2.0-dev \
libpixman-1-dev \
libfdt-dev \
zlib1g-dev \
ninja-build \
meson \
# enable and install 32-bit libs for x86 testing
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
libc6:i386 libgcc-s1:i386 \
qemu-user-static \
&& rm -rf /var/lib/apt/lists/*
# Update meson, ubuntu 24.04 Meson version is 1.3.2 but project requires >=1.5.0
RUN python3 -m pip install --upgrade meson --break-system-packages
# Compile qemu at a recent version (including gdbstubs for mappings)
RUN cd /usr/src \
&& git clone https://gitlab.com/qemu-project/qemu.git \
&& cd qemu \
&& git fetch --tags \
&& git checkout v10.0.2 \
&& mkdir build && cd build \
&& ../configure \
--prefix=/usr/local \
--target-list=arm-linux-user,aarch64-linux-user,mips-linux-user,riscv64-linux-user,i386-linux-user,x86_64-linux-user \
--enable-debug \
&& ninja -C . install \
&& ldconfig
# Crée un venv à /opt/venv
RUN python3 -m venv /opt/venv
# Ajoute le venv au PATH pour que les commandes python passent par là
ENV PATH="/opt/venv/bin:${PATH}"
# Pour pwntools, modifiée pour le venv
RUN pip install --upgrade pip setuptools wheel \
&& pip install --no-cache-dir \
--default-timeout=100 \
--retries=5 \
--resume-retries=5 \
pycryptodome pwntools\
six
# Crée les symlinks manquants pour i386-linux-gnu -> pour build & run en x86
RUN ln -s /usr/i686-linux-gnu /usr/i386-linux-gnu \
&& mkdir -p /usr/lib/i386-linux-gnu \
&& ln -s /usr/lib32 /usr/lib/i386-linux-gnu
### PEDA GET PWNDBG ### -> BEGIN
# voir https://infosecwriteups.com/pwndbg-gef-peda-one-for-all-and-all-for-one-714d71bf36b8
# pwndbg -> voir la doc de pwndbg
RUN git clone https://github.com/pwndbg/pwndbg /opt/pwndbg-src && \
cd /opt/pwndbg-src && \
./setup.sh
# PEDA -> voir la doc de PEDA
RUN git clone https://github.com/longld/peda.git $HOME/peda \
&& rm -f $HOME/peda/lib/six.py \
&& rm -fr $HOME/peda/lib/six
# on enlève six ici car il est nul
# GEF -> voir la doc de GEF
RUN wget -q -O $HOME/.gdbinit-gef.py \
https://raw.githubusercontent.com/hugsy/gef/main/gef.py
# Script from host -> for custom commands in gdb
COPY dot_gdbinit $HOME/.gdbinit
# wrapper scripts in /usr/local/bin -> useless when called from python script but we can keep it
RUN for name in peda pwndbg gef; do \
echo "#!/bin/sh" > /usr/local/bin/gdb-$name && \
echo "exec gdb -q -ex init-$name \"\$@\"" >> /usr/local/bin/gdb-$name; \
done && chmod +x /usr/local/bin/gdb-*
### PEDA GET PWNDBG ### <- END
COPY init $HOME/init
RUN chmod +x $HOME/init
# Montez votre dossier ./shared ici
VOLUME ["/shared"]
WORKDIR /shared
ENV PYTHONPATH=/shared
CMD ["tmux", "new-session", "-A", "-s", "pwnbox", "$HOME/init"]