-
Notifications
You must be signed in to change notification settings - Fork 3
Docker #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker #5
Changes from 3 commits
10f5a7f
b198847
ca79b2f
781ee27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ Cargo.lock | |
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# For vim | ||
*.swp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from ubuntu:latest | ||
|
||
# Install dependencies. | ||
RUN apt update -y | ||
RUN DEBIAN_FRONTEND="noninteractive" apt install -y tzdata | ||
RUN apt install -y \ | ||
git-all \ | ||
vim \ | ||
nano \ | ||
whois \ | ||
openssh-server \ | ||
curl \ | ||
apt-utils \ | ||
iputils-ping \ | ||
zsh \ | ||
tmux | ||
|
||
# Create the required users. The game master is the `git` account, and the player is the user's account | ||
# TODO - change the gamemaster password? | ||
# TODO - change the gamemaster username to git? | ||
RUN useradd --comment "GameMaster account" --create-home --password $(mkpasswd -m sha-512 gamemaster) gamemaster | ||
RUN useradd --comment "Player account" --create-home --password $(mkpasswd -m sha-512 player) --shell /bin/zsh player | ||
|
||
|
||
# Set up the player's SSH keys and copy the public key to /tmp | ||
COPY build/player_entrypoint.sh /home/player | ||
RUN ls -Rla /home/player | ||
RUN chown player:player /home/player/player_entrypoint.sh | ||
RUN chmod 770 /home/player/player_entrypoint.sh | ||
RUN ls -Rla /home/player | ||
RUN su -c "/home/player/player_entrypoint.sh" - player | ||
|
||
RUN mkdir /var/run/sshd | ||
RUN echo 'ClientAliveInterval 60' >> /etc/ssh/sshd_config | ||
RUN echo 'ClientAliveCountMax 10' >> /etc/ssh/sshd_config | ||
COPY build/ssh_banner.txt /etc/banner | ||
RUN echo 'Banner /etc/banner' >> /etc/ssh/sshd_config | ||
|
||
# Set up the git server so that the player can run git clone gamemaster@localhost:/home/gamemaster/game-repo | ||
RUN git clone --bare https://github.com/ShayNehmad/make-git-better-levels.git /home/gamemaster/game-repo | ||
# This file adds the player's ssh public key from before | ||
COPY build/gamemaster_entrypoint.sh /home/gamemaster | ||
RUN chown gamemaster:gamemaster /home/gamemaster/gamemaster_entrypoint.sh | ||
RUN chmod 770 /home/gamemaster/gamemaster_entrypoint.sh | ||
RUN su -c "/home/gamemaster/gamemaster_entrypoint.sh" - gamemaster | ||
# Set up the hooks for the actual gameplay in the repo | ||
COPY levels/checkers /home/gamemaster/game-repo/hooks/checkers | ||
COPY scripts/generate-pre-receive-hook/output/pre-receive /home/gamemaster/game-repo/hooks | ||
# Make sure that gamemaster owns all of their files | ||
RUN chown -R gamemaster:gamemaster /home/gamemaster | ||
|
||
# Now that we're done with gamemaster's setup we can change his shell to git shell | ||
RUN chsh gamemaster -s $(which git-shell) | ||
|
||
# Cleanup | ||
RUN rm -rf /tmp/* | ||
RUN rm -rf /home/player/player_entrypoint.sh | ||
|
||
# Some debug messages | ||
RUN ls -Rla /home | ||
|
||
EXPOSE 22 | ||
CMD ["/usr/sbin/sshd", "-D"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
if [[ ! $(whoami) == "gamemaster" ]] | ||
then echo "I'm not the gamemaster"; exit 1; | ||
fi | ||
|
||
if [[ ! -f /tmp/id_rsa.player.pub ]] | ||
then echo "Not public key file found"; exit 1; | ||
fi | ||
|
||
# https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server | ||
cd | ||
pwd | ||
mkdir .ssh && chmod 700 .ssh | ||
cat /tmp/id_rsa.player.pub >> ~/.ssh/authorized_keys | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/zsh | ||
|
||
if [[ ! $(whoami) == "player" ]] | ||
then echo "I'm not the player"; exit 1; | ||
fi | ||
|
||
# https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server | ||
cd | ||
pwd | ||
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa 2>/dev/null <<< y >/dev/null | ||
|
||
cat ~/.ssh/id_rsa.pub >> /tmp/id_rsa.player.pub | ||
|
||
echo "Setting up zsh" | ||
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | ||
echo "ZSH_THEME=\"agnoster\"" >> ~/.zshrc | ||
ShayNehmad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
echo "plugins=( git )" >> ~/.zshrc | ||
|
||
git config --global user.email "[email protected]" | ||
git config --global user.name "CTF player" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
_ _ _ | ||
_ __ __ _ | |__ ___ __ _ (_) | |_ | ||
| ' \ / _` | | / / / -_) / _` | | | | _| | ||
|_|_|_| \__,_| |_\_\ \___| \__, | |_| \__| | ||
|___/ | ||
___ ___ ___ | ||
_____ / /\ ___ ___ / /\ / /\ | ||
/ /::\ / /:/_ / /\ / /\ / /:/_ / /::\ | ||
/ /:/\:\ / /:/ /\ / /:/ / /:/ / /:/ /\ / /:/\:\ | ||
/ /:/~/::\ / /:/ /:/_ / /:/ / /:/ / /:/ /:/_ / /:/~/:/ | ||
/__/:/ /:/\:| /__/:/ /:/ /\ / /::\ / /::\ /__/:/ /:/ /\ /__/:/ /:/___ | ||
\ \:\/:/~/:/ \ \:\/:/ /:/ /__/:/\:\ /__/:/\:\ \ \:\/:/ /:/ \ \:\/:::::/ | ||
\ \::/ /:/ \ \::/ /:/ \__\/ \:\ \__\/ \:\ \ \::/ /:/ \ \::/~~~~ | ||
\ \:\/:/ \ \:\/:/ \ \:\ \ \:\ \ \:\/:/ \ \:\ | ||
\ \::/ \ \::/ \__\/ \__\/ \ \::/ \ \:\ | ||
\__\/ \__\/ \__\/ \__\/ | ||
|
||
|
||
A CTF challenge by Shay Nehmad | ||
Visit https://mrnice.dev | ||
|
||
This is a game server. Please try to not mess it up ¯\_(ツ)_/¯ | ||
If you find any issues, let me know @ShayNehmad on Twitter. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add some notes about the server config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be on the site. No need to see each login |
Uh oh!
There was an error while loading. Please reload this page.