diff --git a/.gitignore b/.gitignore index 5509140..4f56188 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.DS_Store +*.gdb_history diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..793b482 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:16.04 +MAINTAINER insp3ct0r_x + +ARG DEBIAN_FRONTEND=noninteractive + +ENV TZ Asia/Seoul + +RUN sed -i "s/archive.ubuntu.com/mirror.kakao.com/g" /etc/apt/sources.list +RUN apt update && apt upgrade -y +RUN apt install xinetd gdbserver binutils -y + +RUN dpkg --add-architecture i386 +RUN apt update +RUN apt install libc6-dbg libc6:i386 libc6-dbg:i386 -y + +WORKDIR /root/ +COPY chall.bin /root/ +RUN chmod 755 /root/chall.bin +COPY chall.daemon /etc/xinetd.d/chall +RUN echo "chall 9929/tcp" >> /etc/services + +COPY ep.sh /root/ +RUN chmod 755 /root/ep.sh +ENTRYPOINT ["/root/ep.sh"] diff --git a/chall.bin b/chall.bin new file mode 100755 index 0000000..219014c Binary files /dev/null and b/chall.bin differ diff --git a/chall.daemon b/chall.daemon new file mode 100644 index 0000000..934e646 --- /dev/null +++ b/chall.daemon @@ -0,0 +1,11 @@ +service chall +{ + socket_type = stream + flags = REUSE + wait = no + protocol = tcp + user = root + disable = no + server = /root/chall.bin + port = 9929 +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..53fe355 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + chall: + build: ./ + ports: + - "9929:9929" # for challenge + - "929:929" # for remote debugging + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined diff --git a/ep.sh b/ep.sh new file mode 100644 index 0000000..8d19bf2 --- /dev/null +++ b/ep.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo "[!] Container is started... Setting up xinetd" +/etc/init.d/xinetd restart 1>/dev/null + +echo "[!] If challenge session is connected, gdbserver is run automatically..." +while [[ 1 ]]; do + PID=$(pidof /root/chall.bin 2>/dev/null) + if [[ -n $PID ]]; then + gdbserver 0.0.0.0:929 --attach $PID 2>/dev/null + fi +done