Created
April 15, 2019 15:46
-
-
Save eschulte/6deacbd32ad6eaf53c1519d0c7d8e931 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 http://stalkr.net/files/unrealircd/Unreal3.2.8.1_backdoor.tar.gz | |
COPY Unreal3.2.8.1_backdoor.tar.gz Unreal3.2.8.1_backdoor.tar.gz | |
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 | |
# This extra call to gcc was also required to build. | |
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 | |
# A newer OS to build and use GTIRB. | |
FROM archlinux/base | |
# Install the latest GTIRB, GTIRB-pprinter, and DDisasm. | |
RUN pacman --noconfirm -Syu archlinux-keyring && pacman -Syu --noconfirm base-devel boost git protobuf autoconf automake bison flex fakeroot sqlite libtool pkg-config zlib mcpp | |
RUN sed -i "s/^\(OPT_LONG=(\)/\1'asroot' /;s/EUID == 0/1 == 0/" /usr/bin/makepkg | |
RUN git clone --depth 1 https://aur.archlinux.org/souffle-git.git /souffle-aur | |
RUN sed -i "/make check/d" /souffle-aur/PKGBUILD | |
RUN cd /souffle-aur && makepkg --noconfirm -si | |
RUN for pkg in gtirb-git gtirb-pprinter-git ddisasm-git;do \ | |
git clone --depth 1 https://aur.archlinux.org/${pkg}.git && cd ${pkg} && makepkg --noconfirm -si; \ | |
done | |
# 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 -lgtirb blog.cpp | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment