From b56a224044b7cde93cb446f14f0fa9ff30d28b65 Mon Sep 17 00:00:00 2001 From: Johannes Maier Date: Fri, 12 Jan 2024 01:36:52 +0100 Subject: [PATCH] Add dockerfile for DEBUGGING purposes! --- .gitignore | 5 ++++ debug_docker/Dockerfile | 55 +++++++++++++++++++++++++++++++++++++++++ debug_docker/launch.sh | 6 +++++ 3 files changed, 66 insertions(+) create mode 100644 debug_docker/Dockerfile create mode 100755 debug_docker/launch.sh diff --git a/.gitignore b/.gitignore index 2f58603..0daf164 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,8 @@ build /.idea /.vscode + +debug_docker/**/* +!/debug_docker/Dockerfile +!/debug_docker/launch.sh + diff --git a/debug_docker/Dockerfile b/debug_docker/Dockerfile new file mode 100644 index 0000000..3d3bbc2 --- /dev/null +++ b/debug_docker/Dockerfile @@ -0,0 +1,55 @@ +FROM debian:bullseye + +############################################# +############ FOR DEBUGGING ONLY! ############ +############################################# + + + +RUN apt update -y && apt upgrade -y && apt install -y build-essential wget cmake tar gdb libc6-dbg python3 file + + +############### INSTALL FNETD +RUN wget https://cloud.sec.in.tum.de/index.php/s/n5cJnDqnnpSeEpd/download/fnetd.tar.xz -O /fnetd.tar.xz +RUN tar -xf fnetd.tar.xz +RUN mkdir /fnetd/build + +WORKDIR /fnetd/build +RUN cmake .. -G "Unix Makefiles" +RUN make + +WORKDIR / +############### END INSTALL + +## Add your own dummy get_flag here +COPY get_flag /bin/get_flag + +## Uncomment to use course libc. +COPY libc-2.31.so /lib/x86_64-linux-gnu/libc-2.31-bx.so +RUN ln -sf /lib/x86_64-linux-gnu/libc-2.31-bx.so /lib/x86_64-linux-gnu/libc.so.6 + +RUN useradd -m pwn + +# compile vuln +COPY parent.tar.xz /home/pwn/parent.tar.xz +RUN mkdir /home/pwn/source +RUN tar xvf /home/pwn/parent.tar.xz -C /home/pwn/source +RUN mkdir /home/pwn/build +WORKDIR /home/pwn/build +RUN cmake /home/pwn/source -G "Unix Makefiles" +RUN make +WORKDIR / + +RUN cp /home/pwn/build/vuln /home/pwn/vuln + +RUN chmod 0755 /home/pwn/vuln + +# setup for usage of gdb inside container +RUN echo "export LC_CTYPE=C.UTF-8" >> ~/.bashrc +RUN bash -c "$(wget https://gef.blah.cat/sh -O -)" + +EXPOSE 1337 + +# Feel free to replace password with the actual chall pw +ENV FNETD_PASSWORD=1234 +CMD ["/fnetd/build/fnetd", "-p", "1337", "-u", "pwn", "-lt", "2", "-lm", "536870912", "./vuln"] diff --git a/debug_docker/launch.sh b/debug_docker/launch.sh new file mode 100755 index 0000000..63beaf3 --- /dev/null +++ b/debug_docker/launch.sh @@ -0,0 +1,6 @@ +rm -f parent +find .. -maxdepth 1 -type f | xargs tar cvf parent.tar.xz +docker container rm binex_project +docker image rm binex_project +docker build -t binex_project . +docker run -it -p 1337:1337 --cap-add=SYS_PTRACE --name binex_project binex_project