Skip to content

Commit

Permalink
add ubuntu support
Browse files Browse the repository at this point in the history
  • Loading branch information
zsarge committed Mar 26, 2024
1 parent 430508b commit 36064cc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
10 changes: 10 additions & 0 deletions ChallengeDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The basic dockerfile that is loaded for each console.
# should take ~1MB per open console.
FROM ubuntu:22.04

COPY SETUP.sh SETUP.sh
RUN bash SETUP.sh
RUN rm SETUP.sh

CMD ["/bin/bash"]

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ COPY --from=download-gotty /go/bin/gotty /app/gotty
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

COPY start-shell.sh start-shell.sh
COPY ChallengeDockerfile Dockerfile
COPY SETUP.sh SETUP.sh

# run docker containers inside this docker container.
# therefore, each client is isolated from each other
Expand Down
18 changes: 18 additions & 0 deletions SETUP.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

apt update && apt upgrade -y && apt install tmux htop vim -y # install generally helpful packages
cat << EOF > /etc/motd
Hi! You're currently running Ubuntu Linux version 22.04.
Run 'help' for help.
We recommend using the mouse to select, copy, and paste text.
This terminal will close after 5 minutes to save resources.
EOF
printf "\ncat /etc/motd\n# hello!\n" >> /root/.bashrc

cat << "EOF" >> /root/.bashrc
# custom prompt
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
cd "$HOME"
EOF

16 changes: 13 additions & 3 deletions start-shell.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#!/bin/sh

set -e

# This script is loaded by gotty, and is in charge of starting a jailed and virtualized console.
# This script is loaded by "Dockerfile"
# This script depends on "ChallengeDockerfile"

CONTAINER_NAME="challenge-shell-$RANDOM"
CONTAINER_TAG="webshell"
TIMEOUT="300" # 300 seconds = 5 minutes

TIMEOUT="600" # 600 seconds = 10 minutes
# Build image from ChallengeDockerfile
docker build --tag "$CONTAINER_TAG" .

(sleep "$TIMEOUT" ; echo "Out of time after $TIMEOUT seconds! Refresh to try again." ; docker stop $CONTAINER_NAME)&
clear # clear output

docker run -m 15M --cpu-quota 3000 --name "$CONTAINER_NAME" -it --rm busybox
(sleep "$TIMEOUT" ; echo "Out of time after $TIMEOUT seconds! Refresh to try again." ; docker stop $CONTAINER_NAME)&

docker run -m 15M --cpu-quota 3000 --name "$CONTAINER_NAME" -it --rm "$CONTAINER_TAG"

0 comments on commit 36064cc

Please sign in to comment.