From e8781a67a443b1ba53f51fd2f1428bd5334ca6ca Mon Sep 17 00:00:00 2001 From: galanggg Date: Mon, 22 Oct 2018 19:21:45 +0800 Subject: [PATCH] docker --- calc-pwn/Dockerfile | 31 +++++++++++++++++++++++++++++++ calc-pwn/{ => chall}/calc.py | 0 calc-pwn/server.sh | 3 --- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 calc-pwn/Dockerfile rename calc-pwn/{ => chall}/calc.py (100%) delete mode 100755 calc-pwn/server.sh diff --git a/calc-pwn/Dockerfile b/calc-pwn/Dockerfile new file mode 100644 index 0000000..6e01cdd --- /dev/null +++ b/calc-pwn/Dockerfile @@ -0,0 +1,31 @@ +# Use ubuntu 16.04 +FROM ubuntu:16.04 + +RUN apt-get update && apt-get -y dist-upgrade --fix-missing --fix-broken + +# install socat editor ssh +RUN apt-get install curl netcat-openbsd vim nano openssh-server socat lib32ncurses5 python python-pip python-dev -y + +RUN adduser --disabled-password --gecos "" ksl +RUN echo "ksl:sebuahrahasiamas" | chpasswd + +ADD chall/. /chall +WORKDIR /chall + +RUN echo 'KSL{EVAL_4_LYFE}' > /chall/flag.txt # ubah isi flagnya + +# Secure ENV + +RUN echo 'alias kill="echo no kill please!"' >> ~/.bashrc +RUN chmod 700 /tmp /var/tmp /usr/bin/* /bin/* /dev/shm +RUN chmod 755 /usr/bin/env /bin/dash /bin/bash /bin/sh /bin/nc /bin/cat /usr/bin/curl /usr/bin/groups /usr/bin/id /bin/ls /usr/bin/python + + +RUN chown root:ksl /chall/calc.py # ubah nama file +RUN chmod 775 /chall/calc.py # ubah nama file + +# Run Service + +RUN echo '#!/bin/bash'"\n(socat TCP-LISTEN:7000,reuseaddr,fork EXEC:"/chall/calc.py,su=nobody")" > /var/tmp/.start.sh && chmod +x /var/tmp/.start.sh + +CMD ["/var/tmp/.start.sh"] diff --git a/calc-pwn/calc.py b/calc-pwn/chall/calc.py similarity index 100% rename from calc-pwn/calc.py rename to calc-pwn/chall/calc.py diff --git a/calc-pwn/server.sh b/calc-pwn/server.sh deleted file mode 100755 index bcd2d57..0000000 --- a/calc-pwn/server.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -socat TCP-LISTEN:5000,reuseaddr,fork EXEC:./calc2.py \ No newline at end of file