Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
a3c17ec
added some basic structure for the project, started the first script.
ShayNehmad May 16, 2020
f817c10
Added complete generation script, modified game-config.toml, and adde…
sandspider2234 May 17, 2020
fff15bd
Added usage information.
sandspider2234 May 17, 2020
46053a1
Fixed template file.
sandspider2234 May 17, 2020
5848fc0
Added logging, default output argument, and minor fixes
ShayNehmad May 17, 2020
c830550
debugging the scripts and added the flags
ShayNehmad May 17, 2020
394edd2
Fixed template quoting issue and renamed template.
sandspider2234 May 17, 2020
00cccdd
fixed start-here import path and template error code checking
ShayNehmad May 17, 2020
eb64b83
wip on branch name replacement
ShayNehmad May 17, 2020
082450f
Script works woot
ShayNehmad May 17, 2020
04a7e52
Merge pull request #4 from ShayNehmad/feature/generate-pre-receive-hook
ShayNehmad May 17, 2020
10f5a7f
Started working on the dockerfile - still not ready
ShayNehmad May 17, 2020
b198847
Dockerfile moved to build dir along with helper scripts - still in te…
ShayNehmad May 19, 2020
ca79b2f
It works 🤩
ShayNehmad May 19, 2020
781ee27
Fixed CR and made some other small improvements
ShayNehmad May 20, 2020
6a851fb
Merge pull request #5 from ShayNehmad/docker
ShayNehmad May 21, 2020
19b042d
Changed Rust project structure, and started the new graph generation …
sandspider2234 May 21, 2020
994b62b
Moved the rust scripts one dir up and added some code to the generate…
ShayNehmad May 25, 2020
a85e083
Works up until the graph is created
ShayNehmad May 25, 2020
92c0cbd
Generate level graph works!
ShayNehmad May 27, 2020
077d730
Improve how the graph looks and behaves in the UI
ShayNehmad May 27, 2020
cc5b59c
Added some unit tests, run with `cargo test`
ShayNehmad May 27, 2020
602f0fd
Fix CR comments
ShayNehmad May 28, 2020
5a60376
Fixed CR comment :)
ShayNehmad May 28, 2020
64957b0
Merge pull request #6 from ShayNehmad/feature/generate-levels-graph
ShayNehmad May 28, 2020
5f5e39f
Fixed path of pre-receive hook output in Dockerfile.
sandspider2234 May 28, 2020
cf397aa
Merge pull request #7 from ShayNehmad/hotfix/dockerfile-after-scripts…
sandspider2234 May 28, 2020
221d6e2
Started creating the script
ShayNehmad May 28, 2020
fc1e289
All input part of script is done, now need to generate files from lev…
ShayNehmad May 28, 2020
7771971
Script works!
ShayNehmad May 28, 2020
2975109
Fixed some CR comments
ShayNehmad May 29, 2020
59d54c9
Merge pull request #9 from ShayNehmad/generate-new-level
ShayNehmad May 29, 2020
ab1bf13
Updating the bare repo inside the docker
ShayNehmad May 29, 2020
82a7b70
Added some build documentation
ShayNehmad May 29, 2020
98ab437
Added the gretag alias
ShayNehmad May 29, 2020
7562179
Starting to add levels for real
ShayNehmad May 29, 2020
5672344
Update README.md
ShayNehmad May 29, 2020
c04002e
Update basic-1.sh
ShayNehmad May 29, 2020
700e71e
Update basic-1.sh
ShayNehmad May 29, 2020
ac27bfb
Changed two ifs into if...else
ShayNehmad May 29, 2020
2f04901
Fix dockerfile bug + print motd
ShayNehmad May 30, 2020
db1adf1
Update Dockerfile
ShayNehmad May 30, 2020
de82048
Added some QoL improvments and fixed for Dockerfile
ShayNehmad May 30, 2020
979560e
Merge pull request #10 from ShayNehmad/add-first-levels
ShayNehmad May 30, 2020
f2ff414
Add tester account (for running tests) and fixed Docker issues
ShayNehmad May 30, 2020
6d7a423
Added tests, all pass
ShayNehmad May 30, 2020
bbb6757
Make test output less noisy
ShayNehmad May 30, 2020
107fde4
Added documentation
ShayNehmad May 30, 2020
5190ebc
Merge pull request #11 from ShayNehmad/testing-levels
ShayNehmad May 31, 2020
5307fe4
Fixed output path format for tests
ShayNehmad Jun 1, 2020
d44fa49
Added the build time to the motd.
ShayNehmad Jun 1, 2020
4680d1d
Added get_commit_of utility function
ShayNehmad Jun 1, 2020
4f29f56
Add merge-1 level
ShayNehmad Jun 1, 2020
5002887
Changed player default editor to vim.
ShayNehmad Jun 1, 2020
926561b
Auto space the graph
ShayNehmad Jun 1, 2020
778fd37
Print the level name, not only its title
ShayNehmad Jun 1, 2020
c52580c
Stop build on errors
ShayNehmad Jun 1, 2020
f502855
Some web content improvements
ShayNehmad Jun 1, 2020
8e6b53a
Merge pull request #28 from ShayNehmad/adding-more-levels
ShayNehmad Jun 2, 2020
88cfc9e
moved testing output to log for ez grepping
ShayNehmad Jun 2, 2020
a4374f5
add manfiles to docker
ShayNehmad Jun 2, 2020
3b1e324
Add merge-2
ShayNehmad Jun 2, 2020
e16cd70
renamed common.sh files to separate libs
ShayNehmad Jun 2, 2020
790b32d
Merge pull request #29 from ShayNehmad/15/add-level
ShayNehmad Jun 2, 2020
3f2bd36
Added all log levels.
ShayNehmad Jun 2, 2020
0af3b8c
dos2unix and some other minor fixes
ShayNehmad Jun 2, 2020
fc2cbe7
Merge pull request #30 from ShayNehmad/12/add-level
ShayNehmad Jun 3, 2020
2630d3f
Added merge-3 level
ShayNehmad Jun 4, 2020
7143924
Merge pull request #31 from ShayNehmad/16/merge-levels
ShayNehmad Jun 6, 2020
7be8fde
Make the hook print multiple flags better
ShayNehmad Jun 6, 2020
df78a41
Added the revert-1 level
ShayNehmad Jun 6, 2020
7b952dd
Merge pull request #33 from ShayNehmad/19/revert-level
ShayNehmad Jun 6, 2020
b164bb7
Add some styling to the level browser div
ShayNehmad Jun 6, 2020
3be196d
Added level merge-4
ShayNehmad Jun 6, 2020
be06b0b
Merge pull request #34 from ShayNehmad/17/merge-4
ShayNehmad Jun 6, 2020
24c8c7b
Update flag format + UT
ShayNehmad Jun 7, 2020
b511e0c
Made tests script with -v
ShayNehmad Jun 7, 2020
5abd799
Added merge-5 level
ShayNehmad Jun 7, 2020
791a950
Updated the script to local script and improved clone start page
ShayNehmad Jun 11, 2020
68b6083
Merge pull request #35 from ShayNehmad/18/merge-5-level
ShayNehmad Jun 11, 2020
5657acb
Add default case for hook if pushing wrong branch
ShayNehmad Jun 11, 2020
8f2a6ee
Add rebase-1 stage
ShayNehmad Jun 11, 2020
b8abc0e
Add tag levels
ShayNehmad Jun 12, 2020
eed42a0
Visual fix for graph, physics made it look too busy
ShayNehmad Jun 12, 2020
5c6d2bb
Update checkers to autofail (shouldn't get to them)
ShayNehmad Jun 12, 2020
8975216
Bugfixed the hook template file and added the first hook level
ShayNehmad Jun 12, 2020
4764c7a
Merge pull request #36 from ShayNehmad/20/rebase-1
ShayNehmad Jun 12, 2020
7b1a72b
Merge branch 'dev' into 22/hooks-1
ShayNehmad Jun 12, 2020
a497bbc
Merge pull request #38 from ShayNehmad/22/hooks-1
ShayNehmad Jun 12, 2020
df1d6eb
Add simpler script for creating random branches
ShayNehmad Jun 12, 2020
49ccb12
Start adding hooks-2, still need to impl and test
ShayNehmad Jun 12, 2020
7393c33
Works and tests pass.
ShayNehmad Jun 12, 2020
34c8c94
Merge pull request #41 from ShayNehmad/23/hooks-2
ShayNehmad Jun 12, 2020
b8d0347
Added remote level + small bugfix in hooks-2 level
ShayNehmad Jun 12, 2020
2225bb5
Merge pull request #42 from ShayNehmad/21/remote-1
ShayNehmad Jun 12, 2020
e6a9af1
Added fzf installation and keybindings.
sandspider2234 Jun 13, 2020
d582834
Improvements to graph
ShayNehmad Jun 13, 2020
c34ee46
Merge pull request #43 from ShayNehmad/feature/fzf
ShayNehmad Jun 13, 2020
7091d2a
Merge pull request #44 from ShayNehmad/improve-graph
ShayNehmad Jun 13, 2020
16712c6
Update clone.md
ShayNehmad Jun 13, 2020
355af97
Update max connection idle time and add some info about how to log on…
ShayNehmad Jun 13, 2020
a740f8f
A lot of content/QoL fixes requested by testers
ShayNehmad Jun 14, 2020
33e0cac
Merge pull request #46 from ShayNehmad/fix-tester-feedback
ShayNehmad Jun 14, 2020
bcc46a0
content fixes
ShayNehmad Jun 19, 2020
425a113
Merge pull request #47 from ShayNehmad/fix-tester-feedback
ShayNehmad Jun 19, 2020
7e00d21
Added support for dumb terminals
ShayNehmad Jun 19, 2020
d01ef64
Added ansible hosts file.
sandspider2234 Aug 29, 2020
abf6fa2
Added Ansible build playbook.
sandspider2234 Aug 29, 2020
c981808
Fixed Ansible playbook CR issues, and updated README.
sandspider2234 Aug 29, 2020
960d299
Merge branch 'dev' into 64/ansible
sandspider2234 Aug 29, 2020
f91004b
Fixed Docker build task and formatted yaml
sandspider2234 Aug 29, 2020
89672aa
Merge pull request #65 from TheCoreMan/64/ansible
TheCoreMan Aug 29, 2020
387fc69
Update Dockerfile
TheCoreMan Sep 4, 2020
7e92831
Merge pull request #66 from TheCoreMan/update-levels-repo-links
TheCoreMan Sep 4, 2020
2e49214
Raise docker images count limit
TheCoreMan Sep 6, 2020
25cc1ba
Added first owasp stage
TheCoreMan Oct 10, 2020
c9aacac
Added owasp stage to graph
TheCoreMan Oct 13, 2020
f2bf27e
Furthur OWASP changes, such as const ssh key
TheCoreMan Oct 17, 2020
d6cb333
adding ssh keys to git. feels wrong but it's OK
TheCoreMan Oct 17, 2020
fd22d09
Added 2nd stage
TheCoreMan Oct 19, 2020
4fbff61
Fixed readme commands and flag format
TheCoreMan Oct 19, 2020
9e409e7
Merge pull request #1 from TheCoreMan/owasp-stages
TheCoreMan Jun 6, 2023
b779c68
Added the new rebase level
TheCoreMan Jun 6, 2023
b241c82
WIP
TheCoreMan Jun 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Generated by Cargo
# will have compiled files and executables
/target/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# For vim
*.swp
113 changes: 113 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
FROM ubuntu:focal

# Users will log into this machine, so we need to unminimize it.
# See https://wiki.ubuntu.com/Minimal
RUN yes | unminimize

# Install dependencies.
RUN apt update -y
RUN apt clean -y
RUN DEBIAN_FRONTEND="noninteractive" apt install -y tzdata
RUN apt clean -y
RUN apt update -y && apt install -y \
git-all \
vim \
nano \
whois \
openssh-server \
curl \
apt-utils \
iputils-ping \
zsh \
tmux \
man \
fzf \
sudo \
jq

# Create the required users. The game master is the `git` account, and the player is the user's account
RUN useradd --comment "GameMaster account" --create-home --password $(mkpasswd -m sha-512 95+mcguffin+STRONG+ainasdf+15) gamemaster
RUN useradd --comment "Player account" --create-home --password $(mkpasswd -m sha-512 player) --shell $(which zsh) player
RUN useradd --comment "Testing account" --create-home --password $(mkpasswd -m sha-512 tester) --shell $(which zsh) tester

# OWASP addition
RUN useradd --comment "1st Flag account" --create-home --password $(mkpasswd -m sha-512 flagger) --shell $(which bash) flagger
RUN useradd --comment "2nd Flag account" --create-home --password $(mkpasswd -m sha-512 flagger_the_second) --shell $(which bash) flagger_the_second
RUN useradd --comment "Build system account" --create-home --password $(mkpasswd -m sha-512 build_system) --shell $(which bash) build_system
RUN mkdir -p /etc/owasp/flags
ARG OWASP_FLAG_1
RUN echo $OWASP_FLAG_1 > /etc/owasp/flags/flag.txt
ARG OWASP_FLAG_2
RUN echo $OWASP_FLAG_2 > /flag.txt
RUN chown --verbose --recursive flagger /etc/owasp
RUN chmod --verbose --recursive 0700 /etc/owasp
RUN chown --verbose flagger_the_second /flag.txt
RUN chmod --verbose 0400 /flag.txt
# OWASP additions
RUN echo "gamemaster ALL=(flagger) NOPASSWD:/usr/bin/whoami, /usr/bin/python3" >> /etc/sudoers
RUN echo "gamemaster ALL=(flagger_the_second) NOPASSWD:/usr/bin/whoami, /usr/bin/cp, /usr/bin/chown" >> /etc/sudoers
RUN echo "gamemaster ALL=(build_system) NOPASSWD: ALL" >> /etc/sudoers
RUN echo "gamemaster ALL=(ALL) NOPASSWD:/usr/bin/chown" >> /etc/sudoers

# Set up the player's SSH keys and copy the public key to /tmp
COPY build/player_entrypoint.sh /home/player
COPY build/keys/id_rsa.player /home/player/.ssh/id_rsa
COPY build/keys/id_rsa.player.pub /home/player/.ssh/id_rsa.pub
RUN chown player:player /home/player/player_entrypoint.sh
RUN chmod 770 /home/player/player_entrypoint.sh
RUN su -c "/home/player/player_entrypoint.sh" - player
COPY build/player_zshrc.sh /home/player/.zshrc
RUN chown player:player /home/player/.zshrc
RUN chmod 770 /home/player/.zshrc

# Do the same for the tester account.
COPY build/tester_entrypoint.sh /home/tester
RUN chown tester:tester /home/tester/tester_entrypoint.sh
RUN chmod 770 /home/tester/tester_entrypoint.sh
RUN su -c "/home/tester/tester_entrypoint.sh" - tester
COPY build/tester_zshrc.sh /home/tester/.zshrc
RUN chown tester:tester /home/tester/.zshrc
RUN chmod 770 /home/tester/.zshrc
# Copy the test files to the tester account
COPY levels/tests /home/tester/tests
RUN chown --recursive tester:tester /home/tester

# Set up SSH
RUN mkdir /var/run/sshd
COPY build/sshd_config /etc/ssh/sshd_config
COPY build/login_banner.txt /etc/motd

RUN /etc/init.d/ssh start && ssh-keyscan -H localhost >> /home/player/.ssh/known_hosts && ssh-keyscan -H localhost >> /home/tester/.ssh/known_hosts

# Set up the git server so that the player can run git clone gamemaster@localhost:/home/gamemaster/ctf-repo
RUN git clone --bare https://github.com/TheCoreMan/make-git-better-levels.git /home/gamemaster/ctf-repo
# Set up the other remote for the remote stages
RUN git clone --bare https://github.com/sandspider2234/make-git-better-levels.git /home/gamemaster/forked-ctf-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
# Make sure that gamemaster owns all of their files
RUN chown --recursive gamemaster:gamemaster /home/gamemaster
# This arg invalidates cache from here on forward. use the current time (no spaces) as a build arg.
ARG CACHE_DATE
RUN echo "This CTF server was built at "$CACHE_DATE"." >> /etc/motd
RUN ls -la "/home/gamemaster"
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/ctf-repo/hooks/checkers
COPY scripts/output/pre-receive /home/gamemaster/ctf-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 their shell to git shell and block their home directory
RUN chsh gamemaster -s $(which git-shell)
RUN chmod 700 -R /home/gamemaster

# Cleanup
RUN rm -rf /tmp/*
RUN rm -rf /home/player/player_entrypoint.sh
RUN rm -rf /root/.ssh/

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
200 changes: 199 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,200 @@
# make-git-better-2
Git CTF 🚩 but good this time

Git CTF 🚩 but good this time.

* [Dependencies](#dependencies)
* [Build](#build)
* [Ansible](#ansible)
* [How to build the challenge Docker manually](#how-to-build-the-challenge-docker-manually)
* [Create the hook script](#create-the-hook-script)
* [powershell](#powershell)
* [sh](#sh)
* [Build and run docker image](#build-and-run-docker-image)
* [Build docker](#build-docker)
* [Run docker](#run-docker)
* [Copy ssh key (for outside cloning)](#copy-ssh-key-for-outside-cloning)
* [Useful oneliner](#useful-oneliner)
* [Connect to the running instance](#connect-to-the-running-instance)
* [How to build the web content](#how-to-build-the-web-content)
* [Build the level browser](#build-the-level-browser)
* [Set up docker-tcp-switchboard](#set-up-docker-tcp-switchboard)
* [Test](#test)
* [Unit tests](#unit-tests)
* [Test levels](#test-levels)
* [Develop](#develop)
* [Add a new stage](#add-a-new-stage)

## Dependencies

- Rust
- Docker
- Python 3.6 (for docker TCP switchboard)
- Ansible (optional)

## Build

### Ansible

Using Ansible, you can build and deploy the game server from nothing.

```bash
cd build/ansible
sed -i 's/ctf.mrnice.dev/your.server.com/g' hosts
ansible-playbook -v -i hosts build.yaml
```

Make sure that you have Ansible configured correctly with your SSH keys.
[Here's the docs](https://docs.ansible.com/ansible/latest/inventory_guide/connection_details.html).

> Note: Remember to expose 22 to your IP. If you're like me with AWS EC2, you
> need to add a rule to the security group. Like this:
>
> `aws ec2 authorize-security-group-ingress --group-id PUT_HERE --protocol tcp --port 22 --cidr "$(curl -s https://wtfismyip.com/json | jq -r '.YourFuckingIPAddress')/32"`

### How to build the challenge Docker manually

#### Create the hook script

`cd` to the `scripts` directory.

##### powershell

```powershell
cargo run --bin generate-pre-receive-hook -- --verbose ..\levels\game-config.toml .\src\bin\templates\hook.tmpl
```

##### sh

```sh
cargo run --bin generate-pre-receive-hook -- --verbose ../levels/game-config.toml src/bin/templates/hook.tmpl
```

#### Build and run docker image

##### Build docker

```sh
docker build --tag mgb:0.1 --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) --build-arg OWASP_FLAG_1="AppSec-IL{g1t_d035_P3rM1t_T0_c0mm1T}" --build-arg OWASP_FLAG_2="AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" .
```

##### Run docker

```sh
docker run --detach --name mgbtest --publish 7777:22 mgb:0.1
```

##### Copy ssh key (for outside cloning)

```sh
docker cp mgbtest:/home/player/.ssh/id_rsa ./id_rsa.player
```

##### Useful oneliner

```sh
docker rm -f mgbtest; docker build --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S%z) --build-arg OWASP_FLAG_1="AppSec-IL{g1t_d035_P3rM1t_T0_c0mm1T}" --build-arg OWASP_FLAG_2="AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" --tag mgb:0.1 . && docker run --detach --name mgbtest --publish 7777:22 mgb:0.1
```

##### Connect to the running instance

Password is `player`.

```sh
ssh player@localhost -p 7777
```

### How to build the web content

#### Build the level browser

```sh
cargo run --bin generate-levels-graph -- -v ../levels/game-config.toml src/bin/templates/graph.tmpl
```

### Set up docker-tcp-switchboard

*Only relevant for the game server, no need to do this for local build*.

```sh
git clone https://github.com/OverTheWireOrg/docker-tcp-switchboard.git
# install deps and then
touch /var/log/docker-tcp-switchboard.log
chmod a+w /var/log/docker-tcp-switchboard.log
```

Copy `build/docker-tcp-switchboard.conf` to `/etc/docker-tcp-switchboard.conf`. Finally, run `python3 docker-tcp-switchboard.py`.

## Test

### Unit tests

```sh
cd scripts
cargo test
```

### Test levels

Login as user `tester` to the built Docker and then:

```sh
cd tests
./run_all_tests.sh
```

Should print something like:

```sh
tester@ad6145e90679:~/tests
> ./run_all_tests.sh
TESTLOG: Testing /home/tester/tests/test-basic-1.sh
TESTLOG: testing level basic-1 branch scorpion-treenware-gestatory
TESTLOG: Test /home/tester/tests/test-basic-1.sh passed
TESTLOG: Testing /home/tester/tests/test-basic-2.sh
TESTLOG: testing level basic-2 branch sidespins-areae-regalio
TESTLOG: Test /home/tester/tests/test-basic-2.sh passed
TESTLOG: Testing /home/tester/tests/test-log-1.sh
TESTLOG: testing level log-1 branch turbulator-feere-reinclined
TESTLOG: Test /home/tester/tests/test-log-1.sh passed
TESTLOG: Testing /home/tester/tests/test-log-2.sh
TESTLOG: testing level log-2 branch insatiably-skyjackers-program
TESTLOG: Test /home/tester/tests/test-log-2.sh passed
TESTLOG: Testing /home/tester/tests/test-log-3.sh
TESTLOG: testing level log-3 branch originates-anagyrine-untolerative
TESTLOG: Test /home/tester/tests/test-log-3.sh passed
TESTLOG: Testing /home/tester/tests/test-log-4.sh
TESTLOG: testing level log-4 branch belialist-interlaying-mize
TESTLOG: Test /home/tester/tests/test-log-4.sh passed
TESTLOG: Testing /home/tester/tests/test-merge-1.sh
TESTLOG: testing level merge-1 branch macrochiropteran-jupon-lutecium
TESTLOG: Test /home/tester/tests/test-merge-1.sh passed
TESTLOG: Testing /home/tester/tests/test-merge-2.sh
TESTLOG: testing level merge-2 branch poseuse-citronwood-manganese
TESTLOG: Test /home/tester/tests/test-merge-2.sh passed
TESTLOG: Testing /home/tester/tests/test-merge-3.sh
TESTLOG: testing level merge-3 branch twee-enfamish-stropharia
TESTLOG: Test /home/tester/tests/test-merge-3.sh passed
TESTLOG: Testing /home/tester/tests/test-merge-4.sh
TESTLOG: testing level merge-4 branch multichord-ethicalism-fenestration
TESTLOG: Test /home/tester/tests/test-merge-4.sh passed
TESTLOG: Testing /home/tester/tests/test-merge-5.sh
TESTLOG: testing level merge-5 branch reappraise-veratroyl-garfishes
TESTLOG: Test /home/tester/tests/test-merge-5.sh passed
TESTLOG: Testing /home/tester/tests/test-revert-1.sh
TESTLOG: testing level revert-1 branch lomentaceous-mididae-hexadecane
TESTLOG: Test /home/tester/tests/test-revert-1.sh passed
TESTLOG: Testing /home/tester/tests/test-start-here.sh
TESTLOG: testing level start-here branch start-here
TESTLOG: Test /home/tester/tests/test-start-here.sh passed
TESTLOG: Out of 13 tests, 13 passed and 0 failed.
```

> Note: Can also run with -v to see all `git` output and random `echo`s as well.

## Develop

### Add a new stage

```powershell powershell
cargo run --bin generate-new-level -- ..\levels\game-config.toml .\src\bin\templates\level_checker.tmpl .\src\bin\templates\level_test.tmpl .\src\bin\templates\level_page.tmpl .\src\bin\resources\words_alpha.txt ..\levels\ -v
```
1 change: 1 addition & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
id_rsa*
55 changes: 55 additions & 0 deletions build/ansible/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
- hosts: ctfservers
tasks:
- name: Pull CTF repo
git:
repo: "https://github.com/TheCoreMan/make-git-better-2.git"
dest: /home/{{ ansible_facts['user_id'] }}/make-git-better-2
version: dev
accept_hostkey: yes

- name: Compile rust
command: /home/{{ ansible_facts['user_id'] }}/.cargo/bin/cargo run --bin generate-pre-receive-hook -- --verbose /home/{{ ansible_facts['user_id'] }}/make-git-better-2/levels/game-config.toml src/bin/templates/hook.tmpl
args:
chdir: /home/{{ ansible_facts['user_id'] }}/make-git-better-2/scripts

- name: Build Docker image
shell: docker build --tag mgb:0.1 --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S%z) --build-arg OWASP_FLAG_1="AppSec-IL{g1t_d035_P3rM1t_T0_c0mm1T}" --build-arg OWASP_FLAG_2="AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" .
args:
chdir: /home/{{ ansible_facts['user_id'] }}/make-git-better-2

- name: Clone docker-tcp-switchboard
git:
repo: "https://github.com/OverTheWireOrg/docker-tcp-switchboard.git"
dest: /home/{{ ansible_facts['user_id'] }}/docker-tcp-switchboard
accept_hostkey: yes

- name: Install docker-tcp-switchboard requirements
pip:
requirements: /home/{{ ansible_facts['user_id'] }}/docker-tcp-switchboard/requirements.txt
executable: pip3

- name: Create switchboard log
file:
path: /var/log/docker-tcp-switchboard.log
mode: a+w
state: touch
become: yes

- name: Copy our switchboard conf to /etc
copy:
src: /home/{{ ansible_facts['user_id'] }}/make-git-better-2/build/docker-tcp-switchboard.conf
dest: /etc/docker-tcp-switchboard.conf
remote_src: yes
become: yes

- name: Kill docker-tcp-switchboard
command: pkill -f "python3 .*docker-tcp-switchboard.py"
ignore_errors: true
become: yes

- name: Start docker-tcp-switchboard
shell: nohup python3 /home/{{ ansible_facts['user_id'] }}/docker-tcp-switchboard/docker-tcp-switchboard.py </dev/null >/dev/null 2>&1 &
# This shell line is required because Ansible sends a kill signal to Python
# when it finishes running. The nohup is there to prevent it, and the redirections
# prevent breaking the process.
become: yes
2 changes: 2 additions & 0 deletions build/ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ctfservers]
[email protected]
Loading