diff options
Diffstat (limited to 'chall')
| -rw-r--r-- | chall/Dockerfile | 25 | ||||
| -rw-r--r-- | chall/checker.sh | 9 | ||||
| -rw-r--r-- | chall/docker-compose.yml | 8 | ||||
| -rw-r--r-- | chall/flag.txt | 1 |
4 files changed, 43 insertions, 0 deletions
diff --git a/chall/Dockerfile b/chall/Dockerfile new file mode 100644 index 0000000..9606414 --- /dev/null +++ b/chall/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:jammy + +RUN apt-get update && apt-get -y install openssh-server file procps + +WORKDIR /app + +RUN groupadd -r ctf && useradd -m -r -g ctf ctf +RUN echo "ctf:ctf" | chpasswd + +RUN echo 'ForceCommand "/app/checker.sh"' >> /etc/ssh/sshd_config +RUN echo 'Port 2022' >> /etc/ssh/sshd_config +RUN mkdir /var/run/sshd + +COPY flag.txt / +COPY checker.sh /app/ + +RUN chmod 444 /flag.txt +RUN chmod 555 /app/checker.sh + +CMD while true; do \ + # kill long running processes for ssh + ps -eo comm,pid,etimes | awk '/^checker.sh/ {if ($3 > 10) { print $2 }}' | xargs --no-run-if-empty kill -9; \ + sleep 5s; \ + done & \ + /sbin/sshd -D diff --git a/chall/checker.sh b/chall/checker.sh new file mode 100644 index 0000000..45f7942 --- /dev/null +++ b/chall/checker.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +read -p "Input a file path: " filepath +file $filepath 2>/dev/null | grep -q "ASCII text" 2>/dev/null + +# TODO: print the result the above command. +# $? == 0 -> It's a text file. +# $? != 0 -> It's not a text file. +exit 0 diff --git a/chall/docker-compose.yml b/chall/docker-compose.yml new file mode 100644 index 0000000..c13f708 --- /dev/null +++ b/chall/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3" + +services: + challenge: + build: . + restart: always + ports: + - 2022:2022 diff --git a/chall/flag.txt b/chall/flag.txt new file mode 100644 index 0000000..8671e48 --- /dev/null +++ b/chall/flag.txt @@ -0,0 +1 @@ +SECCON{dummy} |
