|
| 1 | +FROM ubuntu:artful |
| 2 | + |
| 3 | +RUN apt-get update && \ |
| 4 | + apt-get install -y \ |
| 5 | + openjdk-8-jdk git-core gnupg flex bison gperf build-essential \ |
| 6 | + zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \ |
| 7 | + lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \ |
| 8 | + libgl1-mesa-dev libxml2-utils xsltproc unzip python gdb python3 \ |
| 9 | + tmux screen pkg-config libtool automake sudo libgmp-dev iptables \ |
| 10 | + xl2tpd module-init-tools supervisor emacs gettext libcap-dev |
| 11 | + |
| 12 | +RUN groupadd vpn |
| 13 | +RUN useradd -g vpn vpn |
| 14 | + |
| 15 | +WORKDIR /opt/work |
| 16 | +RUN git clone git://git.strongswan.org/strongswan.git |
| 17 | +RUN cd strongswan && git checkout 5.6.2 && ./autogen.sh && \ |
| 18 | + ./configure --with-capabilities=libcap --with-user=vpn --with-group=vpn && \ |
| 19 | + make && make install |
| 20 | + |
| 21 | +# switch over to the 'attacker' user, since root access is no longer required |
| 22 | +RUN addgroup attacker --gid 1001 |
| 23 | +RUN adduser attacker --disabled-password --uid 1001 --gid 1001 |
| 24 | +RUN adduser attacker vpn |
| 25 | + |
| 26 | +# We need to give the "attacker" user sudo permission so that we can |
| 27 | +# start strongswan inside the container. The sudo privileges are not |
| 28 | +# used to run the exploit. For that, the attacker only needs to be a |
| 29 | +# member of the "vpn" group. |
| 30 | +RUN adduser attacker sudo |
| 31 | +RUN echo "attacker:x" | chpasswd # sudo password is "x" |
| 32 | + |
| 33 | +USER attacker |
| 34 | +WORKDIR /home/attacker/ |
| 35 | + |
| 36 | +# Get a copy of the strongswan codebase for the "attacker" user. This |
| 37 | +# is just a lazy way to write the code for the exploit. The only thing |
| 38 | +# that we will use from this copy of the code is the "stroke" utility. |
| 39 | +# We will modify the code slightly and use stroke to send a malicious |
| 40 | +# message to the charon daemon. |
| 41 | +RUN git clone git://git.strongswan.org/strongswan.git |
| 42 | +COPY stroke_patch.txt /home/attacker/stroke_patch.txt |
| 43 | +RUN cd strongswan && git checkout 5.6.2 && \ |
| 44 | + git apply ../stroke_patch.txt && \ |
| 45 | + ./autogen.sh && ./configure && make |
0 commit comments