Skip to content

Instantly share code, notes, and snippets.

@eschulte eschulte/Dockerfile
Last active Apr 16, 2019

What would you like to do?
# Build souffle
FROM ubuntu:18.04 as souffle
RUN apt-get -y update && apt-get -y install automake bison build-essential clang doxygen flex git libtool make mcpp openjdk-8-jdk pkg-config python sqlite3 libsqlite3-dev subversion swi-prolog zlib1g-dev
RUN git clone -b 1.4.0
RUN cd souffle && sh ./bootstrap
RUN cd souffle && ./configure --prefix=/usr --enable-64bit-domain --disable-provenance
RUN cd souffle && make -j4 install
RUN cd souffle && cp include/souffle/RamTypes.h /usr/include/souffle/
# Build the faulty version of UnrealIRCd
# This is the oldest version of Ubuntu that seems to work w/Docker.
FROM ubuntu:14.04 as unrealircd
RUN apt-get -y update && apt-get -y install automake build-essential git libssl-dev wget
RUN wget
RUN tar xzf Unreal3.2.8.1_backdoor.tar.gz
WORKDIR /Unreal3.2
# This change was required to get the build to go through.
RUN sed -i 's/inline void parse_addlag/void parse_addlag/' src/parse.c
RUN ./configure
# As was this extra call to gcc.
RUN make; cd src/;gcc -I../include -I/Unreal3.2/extras/regexp/include -I/Unreal3.2/extras/c-ares/include -L../extras/c-ares/lib -pipe -g -O2 -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -o ircd timesynch.o res.o s_bsd.o auth.o aln.o channel.o cloak.o crule.o dbuf.o events.o fdlist.o hash.o help.o ircd.o ircsprintf.o list.o lusers.o match.o modules.o packet.o parse.o s_auth.o s_conf.o s_debug.o s_err.o s_extra.o s_kline.o s_misc.o s_numeric.o s_serv.o s_svs.o socket.o ssl.o s_user.o charsys.o scache.o send.o support.o umodes.o version.o whowas.o zip.o cidr.o random.o extcmodes.o extbans.o md5.o api-isupport.o api-command.o -lcrypt -lnsl -L../extras/regexp/lib -ltre -lcares -lrt -ldl
# Build GTIRB, GTIRB-pprinter, and DDisasm
FROM ubuntu:18.04
RUN apt-get -y update && \
apt-get -y install clang git build-essential \
wget curl autoconf libtool cmake mcpp
# Build capstone
RUN cd /usr/local/src \
&& wget \
&& tar xf 4.0.1.tar.gz \
&& cd capstone-4.0.1 \
&& CAPSTONE_ARCHS=x86 ./ \
&& CAPSTONE_ARCHS=x86 ./ install
# Build protobuf
RUN cd /usr/local/src \
&& wget \
&& tar xf protobuf-cpp-3.6.0.tar.gz \
&& cd protobuf-3.6.0 \
&& ./configure \
&& make \
&& make install
RUN ldconfig
# Build Boost
ENV BOOST_ROOT=/usr/include/boost
RUN cd /home && wget${BOOST_VERSION}/source/boost_${BOOST_VERSION_}.tar.gz \
&& tar xfz boost_${BOOST_VERSION_}.tar.gz \
&& rm boost_${BOOST_VERSION_}.tar.gz \
&& cd boost_${BOOST_VERSION_} \
&& ./ --prefix=/usr --with-libraries=program_options,filesystem,system,serialization \
&& ./b2 install \
&& cd /home \
&& rm -rf boost_${BOOST_VERSION_}
# Build GTIRB
RUN git clone
RUN make -C/gtirb/build install
# Build gtirb-pprinter
RUN git clone
RUN cmake /gtirb-pprinter -B/gtirb-pprinter/build -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_COMPILER=g++-7 -DGTIRB_PPRINTER_USE_SYSTEM_BOOST=ON
RUN make -C/gtirb-pprinter/build install
# Build ddisasm
COPY --from=souffle /usr/bin/souffle-compile /usr/bin/souffle-compile
COPY --from=souffle /usr/bin/souffle-config /usr/bin/souffle-config
COPY --from=souffle /usr/bin/souffle /usr/bin/souffle
COPY --from=souffle /usr/bin/souffle-profile /usr/bin/souffle-profile
COPY --from=souffle /usr/share/man/man1/souffle.1 /usr/share/man/man1/souffle.1
COPY --from=souffle /usr/share/man/man1/souffle-config.1 /usr/share/man/man1/souffle-config.1
COPY --from=souffle /usr/share/man/man1/souffle-profile.1 /usr/share/man/man1/souffle-profile.1
COPY --from=souffle /usr/share/man/man1/souffle-compile.1 /usr/share/man/man1/souffle-compile.1
COPY --from=souffle /usr/include/souffle/ /usr/include/souffle
ENV TERM xterm
# RUN git clone
RUN git clone --branch other-symbols-without-address
RUN rm -rf /ddisasm/build /ddisasm/CMakeCache.txt /ddisasm/CMakeFiles /ddisasm/CMakeScripts
RUN make -C/ddisasm/build install
ENV PATH=/ddisasm/build/bin:$PATH
# Copy in the UnrealIRCd binary.
COPY --from=unrealircd /Unreal3.2/ /Unreal3.2/
COPY --from=unrealircd /Unreal3.2/src/ircd /ircd
# Analyze the resulting ircd binary
RUN ddisasm /ircd --ir /ircd.gtirb
RUN gtirb-pprinter /ircd.gtirb -o /ircd.s
# Inspect with GTIRB.
COPY blog.cpp blog.cpp
RUN g++ --std=c++17 blog.cpp -lgtirb
RUN ./a.out /ircd.gtirb 1
# Repair.
RUN sed 's/system@PLT/puts@PLT/' -i ircd.s
RUN gcc ircd.s -o ircd-fixed -lcrypt -lrt -ldl -lc -lpthread -no-pie

This comment has been minimized.

Copy link
Owner Author

commented Apr 15, 2019

Alternately, the Dockerfile based on Arch Linux is somewhat simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.