Skip to content

Commit 781ee27

Browse files
committed
Fixed CR and made some other small improvements
1 parent ca79b2f commit 781ee27

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

Dockerfile

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,44 @@ RUN apt install -y \
1616
tmux
1717

1818
# Create the required users. The game master is the `git` account, and the player is the user's account
19-
# TODO - change the gamemaster password?
20-
# TODO - change the gamemaster username to git?
21-
RUN useradd --comment "GameMaster account" --create-home --password $(mkpasswd -m sha-512 gamemaster) gamemaster
22-
RUN useradd --comment "Player account" --create-home --password $(mkpasswd -m sha-512 player) --shell /bin/zsh player
19+
RUN useradd --comment "GameMaster account" --create-home --password $(mkpasswd -m sha-512 94+wings+STRONG+mountain+35) gamemaster
20+
RUN useradd --comment "Player account" --create-home --password $(mkpasswd -m sha-512 player) --shell $(which zsh) player
2321

2422
# Set up the player's SSH keys and copy the public key to /tmp
2523
COPY build/player_entrypoint.sh /home/player
26-
RUN ls -Rla /home/player
2724
RUN chown player:player /home/player/player_entrypoint.sh
2825
RUN chmod 770 /home/player/player_entrypoint.sh
29-
RUN ls -Rla /home/player
3026
RUN su -c "/home/player/player_entrypoint.sh" - player
27+
COPY build/player_zshrc.sh /home/player/.zshrc
28+
RUN chown player:player /home/player/.zshrc
29+
RUN chmod 770 /home/player/.zshrc
3130

3231
RUN mkdir /var/run/sshd
3332
RUN echo 'ClientAliveInterval 60' >> /etc/ssh/sshd_config
3433
RUN echo 'ClientAliveCountMax 10' >> /etc/ssh/sshd_config
35-
COPY build/ssh_banner.txt /etc/banner
36-
RUN echo 'Banner /etc/banner' >> /etc/ssh/sshd_config
34+
COPY build/login_banner.txt /etc/motd
3735

38-
# Set up the git server so that the player can run git clone gamemaster@localhost:/home/gamemaster/game-repo
39-
RUN git clone --bare https://github.com/ShayNehmad/make-git-better-levels.git /home/gamemaster/game-repo
36+
# Set up the git server so that the player can run git clone gamemaster@localhost:/home/gamemaster/ctf-repo
37+
RUN git clone --bare https://github.com/ShayNehmad/make-git-better-levels.git /home/gamemaster/ctf-repo
4038
# This file adds the player's ssh public key from before
4139
COPY build/gamemaster_entrypoint.sh /home/gamemaster
4240
RUN chown gamemaster:gamemaster /home/gamemaster/gamemaster_entrypoint.sh
4341
RUN chmod 770 /home/gamemaster/gamemaster_entrypoint.sh
4442
RUN su -c "/home/gamemaster/gamemaster_entrypoint.sh" - gamemaster
4543
# Set up the hooks for the actual gameplay in the repo
46-
COPY levels/checkers /home/gamemaster/game-repo/hooks/checkers
47-
COPY scripts/generate-pre-receive-hook/output/pre-receive /home/gamemaster/game-repo/hooks
44+
COPY levels/checkers /home/gamemaster/ctf-repo/hooks/checkers
45+
COPY scripts/generate-pre-receive-hook/output/pre-receive /home/gamemaster/ctf-repo/hooks
4846
# Make sure that gamemaster owns all of their files
4947
RUN chown -R gamemaster:gamemaster /home/gamemaster
5048

51-
# Now that we're done with gamemaster's setup we can change his shell to git shell
49+
# Now that we're done with gamemaster's setup we can change their shell to git shell and block their home directory
5250
RUN chsh gamemaster -s $(which git-shell)
51+
RUN chmod 700 -R /home/gamemaster
5352

5453
# Cleanup
5554
RUN rm -rf /tmp/*
5655
RUN rm -rf /home/player/player_entrypoint.sh
5756

58-
# Some debug messages
59-
RUN ls -Rla /home
60-
6157
EXPOSE 22
6258
CMD ["/usr/sbin/sshd", "-D"]
6359

build/ssh_banner.txt renamed to build/login_banner.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
\__\/ \__\/ \__\/ \__\/
1717

1818

19-
A CTF challenge by Shay Nehmad
19+
A git CTF challenge by Shay Nehmad
2020
Visit https://mrnice.dev
2121

2222
This is a game server. Please try to not mess it up ¯\_(ツ)_/¯
2323
If you find any issues, let me know @ShayNehmad on Twitter.
2424

25+
To start playing, clone the game repository by running:
26+
27+
git clone gamemaster@localhost:~/ctf-repo
28+

build/player_entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ cat ~/.ssh/id_rsa.pub >> /tmp/id_rsa.player.pub
1313

1414
echo "Setting up zsh"
1515
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
16-
echo "ZSH_THEME=\"agnoster\"" >> ~/.zshrc
17-
echo "plugins=( git )" >> ~/.zshrc
16+
1817

1918
git config --global user.email "[email protected]"
2019
git config --global user.name "CTF player"

build/player_zshrc.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export ZSH="/home/player/.oh-my-zsh"
2+
ZSH_THEME="juanghurtado"
3+
plugins=(git)
4+
5+
source $ZSH/oh-my-zsh.sh
6+

0 commit comments

Comments
 (0)