Skip to content

Commit b779c68

Browse files
committed
Added the new rebase level
Also updated the OWASP stuff Signed-off-by: Shay Nehmad <[email protected]>
1 parent 9e409e7 commit b779c68

File tree

11 files changed

+225
-68
lines changed

11 files changed

+225
-68
lines changed

Dockerfile

+4-17
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ RUN apt install -y \
2020
tmux \
2121
man \
2222
fzf \
23-
sudo
23+
sudo \
24+
jq
2425

2526
# Create the required users. The game master is the `git` account, and the player is the user's account
2627
RUN useradd --comment "GameMaster account" --create-home --password $(mkpasswd -m sha-512 95+mcguffin+STRONG+ainasdf+15) gamemaster
@@ -68,27 +69,17 @@ RUN chmod 770 /home/tester/.zshrc
6869
# Copy the test files to the tester account
6970
COPY levels/tests /home/tester/tests
7071
RUN chown --recursive tester:tester /home/tester
72+
RUN chmod 770 --recursive tester:tester /home/tester/tests
7173

7274
# Set up SSH
7375
RUN mkdir /var/run/sshd
7476
COPY build/sshd_config /etc/ssh/sshd_config
7577
COPY build/login_banner.txt /etc/motd
7678

77-
RUN mkdir -p /root/.ssh && \
78-
chmod 0700 /root/.ssh && \
79-
ssh-keyscan github.com > /root/.ssh/known_hosts
80-
COPY build/id_rsa_mgbp_docker /root/.ssh/id_rsa
81-
COPY build/id_rsa_mgbp_docker.pub /root/.ssh/id_rsa.pub
82-
RUN chmod 0600 /root/.ssh/* && \
83-
eval "$(ssh-agent -s)" && \
84-
ssh-add /root/.ssh/id_rsa
85-
8679
RUN /etc/init.d/ssh start && ssh-keyscan -H localhost >> /home/player/.ssh/known_hosts && ssh-keyscan -H localhost >> /home/tester/.ssh/known_hosts
8780

8881
# Set up the git server so that the player can run git clone gamemaster@localhost:/home/gamemaster/ctf-repo
89-
RUN eval "$(ssh-agent -s)" && \
90-
ssh-add /root/.ssh/id_rsa && \
91-
git clone --bare [email protected]:TheCoreMan/make-git-better-levels-private.git /home/gamemaster/ctf-repo
82+
RUN git clone --bare https://github.com/TheCoreMan/make-git-better-levels.git /home/gamemaster/ctf-repo
9283
# Set up the other remote for the remote stages
9384
RUN git clone --bare https://github.com/sandspider2234/make-git-better-levels.git /home/gamemaster/forked-ctf-repo
9485
# This file adds the player's ssh public key from before
@@ -102,10 +93,6 @@ ARG CACHE_DATE
10293
RUN echo "This CTF server was built at "$CACHE_DATE"." >> /etc/motd
10394
RUN ls -la "/home/gamemaster"
10495
RUN su -c "/home/gamemaster/gamemaster_entrypoint.sh" - gamemaster
105-
RUN eval "$(ssh-agent -s)" && \
106-
ssh-add /root/.ssh/id_rsa && \
107-
cd /home/gamemaster/ctf-repo/ && \
108-
git fetch origin +refs/heads/*:refs/heads/* --prune
10996
# Set up the hooks for the actual gameplay in the repo
11097
COPY levels/checkers /home/gamemaster/ctf-repo/hooks/checkers
11198
COPY scripts/output/pre-receive /home/gamemaster/ctf-repo/hooks

build/sshd_config

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ UsePAM no
1919
PrintMotd yes
2020

2121
# OWASP addition - hardning server
22-
DenyUsers player tester build_system flagger flagger_the_second
22+
# DenyUsers player tester build_system flagger flagger_the_second

levels/checkers/rebase-2.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
source $(dirname $0)/checkers-lib.sh
4+
5+
read old new ref </dev/stdin
6+
7+
dump_dir=$(dump-commit-to-directory $new)
8+
9+
pushd $dump_dir
10+
# Check files here
11+
if [ ! -f first.md ]; then
12+
reject-solution "first.md is missing."
13+
fi
14+
15+
if [ ! -f second.md ]; then
16+
reject-solution "second.md is missing."
17+
fi
18+
19+
if [ ! -f third.md ]; then
20+
reject-solution "third.md is missing."
21+
fi
22+
23+
# Check history here
24+
25+
popd
26+
27+
# level info
28+
## title rebase-2
29+
## branch downfalling-bumbled-sootiness -> That means the tag is downfalling-bumbled-sootiness-tag
30+
31+
# Check the order. It should be first, second, third.
32+
FIRST_COMMIT_MESSAGE=$(git log --pretty=format:%s HEAD~2 -n 1)
33+
SECOND_COMMIT_MESSAGE=$(git log --pretty=format:%s HEAD~1 -n 1)
34+
THIRD_COMMIT_MESSAGE=$(git log --pretty=format:%s HEAD -n 1)
35+
if grep -q "$FIRST_COMMIT_MESSAGE" "first"; then
36+
reject-solution "The first commit should be \"Who's on first\", but saw $FIRST_COMMIT_MESSAGE."
37+
fi
38+
if grep -q "$SECOND_COMMIT_MESSAGE" "second"; then
39+
reject-solution "The second commit should be \"What's on second\", but saw $SECOND_COMMIT_MESSAGE."
40+
fi
41+
if grep -q "$THIRD_COMMIT_MESSAGE" "third"; then
42+
reject-solution "The third commit should be \"I don't know's on third\", but saw $THIRD_COMMIT_MESSAGE."
43+
fi
44+
45+
log_n=5
46+
echo "git log of last $log_n commits..."
47+
git log --decorate --oneline --graph -n $log_n "$new"

levels/game-config.toml

+14-24
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
title = 'clone'
33
branch = 'master'
44
solution_checker = 'echo No pushing to master. Read the README file; exit 1'
5-
flags = [
6-
'start-here',
7-
'owasp-ctf-1',
8-
'owasp-ctf-2',
9-
]
5+
flags = ['start-here', 'owasp-ctf-1', 'owasp-ctf-2']
106

117
[[levels]]
128
title = 'start-here'
@@ -24,22 +20,19 @@ flags = ['basic-2']
2420
title = 'basic-2'
2521
branch = 'sidespins-areae-regalio'
2622
solution_checker = 'hooks/checkers/basic-2.sh'
27-
flags = ['merge-1']
23+
flags = ['merge-1', 'log-1']
2824

2925
[[levels]]
3026
title = 'merge-1'
3127
branch = 'macrochiropteran-jupon-lutecium'
3228
solution_checker = 'hooks/checkers/merge-1.sh'
33-
flags = [
34-
'merge-2',
35-
'log-1',
36-
]
29+
flags = ['merge-2']
3730

3831
[[levels]]
3932
title = 'merge-2'
4033
branch = 'poseuse-citronwood-manganese'
4134
solution_checker = 'hooks/checkers/merge-2.sh'
42-
flags = ['merge-3']
35+
flags = ['merge-3', 'rebase-1']
4336

4437
[[levels]]
4538
title = 'log-1'
@@ -75,10 +68,7 @@ flags = []
7568
title = 'merge-3'
7669
branch = 'twee-enfamish-stropharia'
7770
solution_checker = 'hooks/checkers/merge-3.sh'
78-
flags = [
79-
'merge-4',
80-
'revert-1',
81-
]
71+
flags = ['merge-4', 'revert-1']
8272

8373
[[levels]]
8474
title = 'revert-1'
@@ -102,10 +92,7 @@ flags = ['merge-levels-done-you-win']
10292
title = 'tag-1'
10393
branch = 'redamage-bundh-passerina'
10494
solution_checker = 'hooks/checkers/tag-1.sh'
105-
flags = [
106-
'tag-2',
107-
'hooks-1',
108-
]
95+
flags = ['tag-2', 'hooks-1']
10996

11097
[[levels]]
11198
title = 'tag-2'
@@ -117,16 +104,13 @@ flags = []
117104
title = 'hooks-1'
118105
branch = 'hands-trooshlach-nongassy'
119106
solution_checker = 'hooks/checkers/hooks-1.sh'
120-
flags = [
121-
'rebase-1',
122-
'hooks-2',
123-
]
107+
flags = ['hooks-2', 'remote-1']
124108

125109
[[levels]]
126110
title = 'rebase-1'
127111
branch = 'parallelizing-barnhardtite-base'
128112
solution_checker = 'hooks/checkers/rebase-1.sh'
129-
flags = ['remote-1']
113+
flags = ['rebase-2']
130114

131115
[[levels]]
132116
title = 'hooks-2'
@@ -151,3 +135,9 @@ title = 'owasp-ctf-2'
151135
branch = 'aghastness-subhead-cyrtometer'
152136
solution_checker = 'hooks/checkers/owasp-ctf-2.sh'
153137
flags = ['AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}']
138+
139+
[[levels]]
140+
title = 'rebase-2'
141+
branch = 'downfalling-bumbled-sootiness'
142+
solution_checker = 'hooks/checkers/rebase-2.sh'
143+
flags = ['rebase-levels-done-you-win']

levels/pages/owasp-ctf-1.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ twitter:
1313
image: "https://i.imgur.com/ROzkHYp.png"
1414
---
1515

16-
[Click here.](https://appsecil2020.ctf.today/)
16+
This level was a part of OWASP CTF 2020.
1717

18-
```
18+
{{< levelgraph >}}
19+
20+
The focus of this level is AppSec, and specifically, `git` security. But not
21+
`git` fundamentals, like the rest of the levels in this CTF. So you should
22+
_probably_ solve the rest of the levels first.
23+
24+
![OWASP logo](/images/OWASP-IL-Icon.png "OWASP logo")
25+
26+
```txt
1927
_____ _ _ ___ ___________
2028
| _ || | | |/ _ \ / ___| ___ \
2129
| | | || | | / /_\ \\ `--.| |_/ /
@@ -25,8 +33,16 @@ twitter:
2533
2634
```
2735

28-
## ALL LEVELS WHICH DON'T START WITH "OWASP" ARE NOT A PART OF THE APPSECIL2020 CTF! THEY ARE NOT WORTH POINTS!!!
36+
[~~Click here~~](https://appsecil2020.ctf.today/). In the past, this link worked.
37+
The CTF is over now, so it doesn't work anymore. Here are the instructions to
38+
start:
2939

30-
You can try to play the open source, free, and non-affiliated CTF - `make-git-better` - on your own, if you want. [Start here](https://mrnice.dev/ctf).
40+
`git checkout headmistresses-tiptoes-bezzled`.
3141

32-
{{< levelgraph >}}
42+
## 🧩 Hints
43+
44+
Click on the hint to see it.
45+
46+
{{% expand "Writeup" %}}
47+
[Solved by JCTF Team](https://jctf.team/AppSec-IL-2020/come-and-git-it-1/).
48+
{{% /expand %}}

levels/pages/owasp-ctf-2.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ twitter:
1313
image: "https://i.imgur.com/ROzkHYp.png"
1414
---
1515

16+
This level was a part of OWASP CTF 2020.
1617

17-
[Click here.](https://appsecil2020.ctf.today/)
18+
{{< levelgraph >}}
1819

19-
```
20+
The focus of this level is AppSec, and specifically, `git` security. But not
21+
`git` fundamentals, like the rest of the levels in this CTF. So you should
22+
_probably_ solve the rest of the levels first.
23+
24+
![OWASP logo](/images/OWASP-IL-Icon.png "OWASP logo")
25+
26+
```txt
2027
_____ _ _ ___ ___________
2128
| _ || | | |/ _ \ / ___| ___ \
2229
| | | || | | / /_\ \\ `--.| |_/ /
@@ -26,9 +33,16 @@ twitter:
2633
2734
```
2835

29-
## ALL LEVELS WHICH DON'T START WITH "OWASP" ARE NOT A PART OF THE APPSECIL2020 CTF! THEY ARE NOT WORTH POINTS!!!
36+
[~~Click here~~](https://appsecil2020.ctf.today/). In the past, this link worked.
37+
The CTF is over now, so it doesn't work anymore. Here are the instructions to
38+
start:
3039

31-
You can try to play the open source, free, and non-affiliated CTF - `make-git-better` - on your own, if you want. [Start here](https://mrnice.dev/ctf).
40+
`git checkout aghastness-subhead-cyrtometer`.
3241

33-
{{< levelgraph >}}
42+
## 🧩 Hints
43+
44+
Click on the hint to see it.
3445

46+
{{% expand "Writeup" %}}
47+
[Solved by JCTF Team](https://jctf.team/AppSec-IL-2020/come-and-git-it-2/).
48+
{{% /expand %}}

levels/pages/rebase-2.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: "rebase-2"
3+
date: 2020-05-23T13:04:22+03:00
4+
draft: false
5+
scripts:
6+
- "/js/vis-network.min.js"
7+
twitter:
8+
card: "summary_large_image"
9+
site: "@ShayNehmad"
10+
creator: "@ShayNehmad"
11+
title: "mrnice.dev"
12+
description: "mrnice.dev: Shay Nehmad's blog 🧔"
13+
image: "https://i.imgur.com/ROzkHYp.png"
14+
---
15+
16+
{{< levelgraph >}}
17+
18+
![who's on first?](/images/whos-on-first.gif "who's on first?")
19+
20+
In this level, the commits are all out of order. Reorder them using an
21+
interactive rebase, and push them in the correct order.
22+
23+
In case you've never watch the classic sketch "Who's on First?", The correct
24+
order is:
25+
26+
> First base: Who
27+
>
28+
> Second base: What
29+
>
30+
> Third base: I Don't Know
31+
32+
(By the way, if you haven't watched it, you should. It's a classic.)
33+
34+
{{< youtube id="kTcRRaXV-fg" >}}
35+
36+
## 🧩 Hints
37+
38+
Click on the hint to see it.
39+
40+
{{% expand "I'm getting `! [rejected]` | part 1" %}}
41+
Read the error message carefully, and think about what you're actually trying to
42+
do. We are the tip of the current branch behind the remote? No one else is
43+
pushing content to this branch right now...
44+
{{% /expand %}}
45+
46+
{{% expand "I'm getting `! [rejected]` | part 2" %}}
47+
You need to force push. Why? Because you're rewriting history. And that's OK.
48+
{{% /expand %}}
49+
50+
{{% expand "I'm getting `! [rejected]` | part 3" %}}
51+
`git push --force-with-lease`. See [the documentation](https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-with-lease).
52+
{{% /expand %}}
53+
54+
{{% expand "Interactive rebase?" %}}
55+
[Really very good Documentation](https://git-scm.com/docs/git-rebase#_interactive_mode).
56+
{{% /expand %}}
57+
58+
{{% expand "Wait, isn't this rewriting history?" %}}
59+
[Yep. And that's OK](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
60+
{{% /expand %}}

levels/tests/test-owasp-ctf-1.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ sed -i 's/\[REDACTED\]/\/etc\/owasp\/flags\/flag.txt/g' capture_the_flag.py
1818
git add --all
1919
git commit -m "fixed path"
2020

21-
git push > push_result 2>&1
21+
git push >push_result 2>&1
2222

2323
# check_results
24-
if [ $(grep "AppSec_IL" push_result | wc -l) -gt 0 ]; then
25-
git reset --hard > /dev/null 2>&1
26-
git clean -f -d > /dev/null 2>&1
24+
if [ $(grep "AppSec-IL" push_result | wc -l) -gt 0 ]; then
25+
git reset --hard >/dev/null 2>&1
26+
git clean -f -d >/dev/null 2>&1
2727
exit 0
28-
else
29-
git reset --hard > /dev/null 2>&1
30-
git clean -f -d > /dev/null 2>&1
28+
else
29+
git reset --hard >/dev/null 2>&1
30+
git clean -f -d >/dev/null 2>&1
3131
exit 1
3232
fi

levels/tests/test-owasp-ctf-2.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ git clean -f -d
1212

1313
# PUT TEST CODE HERE, like git add + git commit
1414
git config --local user.name "Johnny Cash" && git config --local user.email "[email protected]"
15-
mkdir .build && echo "cat \$TMP_BUILD_SYSTEM_DIR/flag.txt" > .build/build.sh
15+
mkdir -p .build && echo "cat \$TMP_BUILD_SYSTEM_DIR/flag.txt" >.build/build.sh
1616
git add --all && git commit -m "a message"
1717
# Only the timezone is important here
1818
GIT_COMMITER_DATE="Mon Oct 19 20:19:19 2020 -1200" git commit --amend --no-edit --date "Mon Oct 19 20:19:19 2020 -1200"
1919

20-
21-
git push > push_result 2>&1
20+
git push >push_result 2>&1
2221

2322
# check_results
24-
if [ $(grep "AppSec_IL" push_result | wc -l) -gt 0 ]; then
25-
git reset --hard > /dev/null 2>&1
26-
git clean -f -d > /dev/null 2>&1
23+
if [ $(grep "AppSec-IL" push_result | wc -l) -gt 0 ]; then
24+
git reset --hard >/dev/null 2>&1
25+
git clean -f -d >/dev/null 2>&1
2726
exit 0
28-
else
29-
git reset --hard > /dev/null 2>&1
30-
git clean -f -d > /dev/null 2>&1
27+
else
28+
cat push_result
29+
git reset --hard >/dev/null 2>&1
30+
git clean -f -d >/dev/null 2>&1
3131
exit 1
3232
fi

0 commit comments

Comments
 (0)