-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.ctf
65 lines (55 loc) · 2.41 KB
/
Dockerfile.ctf
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
# This is the Dockerfile for those CTF Players who only
# need RISC-V gdb utilis and user/system mode QEMU
# Also python3 support for gdb is enabled during compilation
FROM ubuntu:18.04 AS build_env
RUN apt -y update \
&& apt install -y autoconf automake autotools-dev curl \
libmpc-dev libmpfr-dev libgmp-dev \
python3 pkg-config libglib2.0-dev libpixman-1-dev gawk \
build-essential bison flex texinfo gperf libtool patchutils \
bc zlib1g-dev libexpat-dev git ninja-build \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
# Use QEMU v7.0.0, keep the same version as RISC-V
RUN mkdir riscv-qemu-linux \
&& cd riscv-qemu-linux \
&& git clone --depth=1 --branch=v7.0.0 https://github.com/qemu/qemu
WORKDIR /tmp/riscv-qemu-linux/qemu
# Build qemu with system emulation
# Build target: riscv64-softmmu and riscv32-softmmu with system
RUN ./configure --target-list=riscv32-softmmu,riscv64-softmmu \
&& make -j $(nproc) \
&& make install \
&& make clean \
&& mkdir -p /opt/qemu-riscv-static \
# Build user mode riscv QEMU
&& ./configure --target-list=riscv32-linux-user,riscv64-linux-user \
--static \
--disable-system \
--enable-linux-user \
--prefix=/opt/qemu-riscv-static \
&& make -j $(nproc) \
&& make install \
&& make clean \
&& rm -rf /tmp/riscv-qemu-linux/qemu
WORKDIR /tmp/riscv-qemu-linux/
# Build risc-v 32/64 gdb with python3.8 enabled, branch 2.38
RUN apt update -y && apt install wget python3-pip python3.8 python3.8-dev -y \
&& git clone --depth=1 --branch=riscv-binutils-2.38 https://github.com/riscv/riscv-binutils-gdb.git \
&& export CPPFLAGS='-I/usr/include/python3.8/' \
&& export LDFLAGS='-L/usr/lib/python3.8/' \
&& export LC_CTYPE=C.UTF-8 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 \
&& mkdir /opt/riscv-binutils-gdb \
&& cd riscv-binutils-gdb \
&& ./configure --prefix=/opt/riscv-binutils-gdb --target riscv64-unknown-elf -enable-multilib --with-python \
&& make -j $(nproc) \
&& make install \
&& rm -rf /tmp/riscv-qemu-linux/riscv-binutils-gdb \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /root
# Install GEF for gdb https://github.com/hugsy/gef
RUN pip3 install capstone unicorn keystone-engine ropper \
&& bash -c "$(wget http://gef.blah.cat/sh -O -)"
ENV LC_CTYPE C.UTF-8