From 9a0c74b701700d9eee9c25f0b045de29d1d06f7f Mon Sep 17 00:00:00 2001 From: Pin Date: Tue, 20 Dec 2022 22:15:44 -0500 Subject: [PATCH] initial commit --- .gitignore | 3 +++ client/Dockerfile | 11 +++++++++++ client/scripts/setup.sh | 25 +++++++++++++++++++++++++ controller/Dockerfile | 7 +++++++ controller/scripts/gen_keys.sh | 10 ++++++++++ controller/scripts/init.sh | 27 +++++++++++++++++++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 .gitignore create mode 100644 client/Dockerfile create mode 100755 client/scripts/setup.sh create mode 100644 controller/Dockerfile create mode 100755 controller/scripts/gen_keys.sh create mode 100755 controller/scripts/init.sh create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eddde25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env + +keys/ diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..c130430 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.16 + +RUN apk --no-cache add openrc openssh bash && \ + ssh-keygen -A && \ + mkdir -p /run/openrc && \ + touch /run/openrc/softlevel + +COPY scripts /opt/scripts +RUN chmod 700 /opt/scripts + +ENTRYPOINT ["/opt/scripts/setup.sh"] diff --git a/client/scripts/setup.sh b/client/scripts/setup.sh new file mode 100755 index 0000000..22da73d --- /dev/null +++ b/client/scripts/setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +TEAM_NUM=${TEAM_NUM:=10} + +for (( i=1; i<=TEAM_NUM; i++ )); do + echo "Creating Team ${i}" + adduser -D "team${i}" + chmod 750 "/home/team${i}" + PASSWORD="TEAM${i}_PASSWORD" + if [[ -z "${!PASSWORD}" ]]; then + PASSWORD=$(head -c10 .flag' + done + + sleep 30 + +done + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..335bd22 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +--- +version: "3.9" + +services: + client: + image: local/c2games-client:latest + build: + context: ./client + environment: + TEAM_NUM: 5 + SSHD_CHALLENGE_DIR: .ssh/auth_keys + + controller: + image: local/c2games-controller:latest + build: + context: ./controller + environment: + TEAM_NUM: 5 + volumes: + - "${PWD}/keys:/root/.ssh" +...