]> git.somenet.org - pub/jan/ctf-seminar.git/blob - writeups/chrztoph/overTheWire2019.md
Improve writeups
[pub/jan/ctf-seminar.git] / writeups / chrztoph / overTheWire2019.md
1 # OverTheWire Advent Bonanza 2019
2
3 ## CTF Retrospective
4
5 I know the Advent of Code but didn't knew that something like that also exists as a CTF. The challenges were really funny designed and there were challenges from easy to hard. I had a lot of fun solving them together with the people on Mattermost.
6
7 ## Challenge 1
8
9 Time: about 4h without writeup
10
11 ### Task description
12
13 ```
14 Santa is stranded on the Christmas Islands and is desperately trying to reach his trusty companion via cellphone. We've bugged the device with a primitive keylogger and have been able to decode some of the SMS, but couldn't make much sense of the last one. Can you give us a hand?
15 ```
16
17 ### Overview
18
19 The challenge was really fun because it was a nice coding challenge and reminded me about the good old times. You are given four `.csv` files produced by the keylogger but only three are already decoded and the task is to decode the last sent message. In a given C header file is information about the keys and their meaning.
20
21 ### Exploitation
22
23 At first I was very confused about the `keys.h` header file. Why do different characters and numbers map to a specific keypad number? After some time I noticed that this keylogger is from a phone like back in the old days where you have to press a button multiple times to get the desired letter. Remember the phones that have real physical buttons. For example if you press the button `2` three times fast enough in a row you get according to `N7110_KEYPAD_TWO_ABC_CHARS   "abc2"` the letter `c`. This is nearly everything that is needed to solve the challenge.
24
25 One thing to put attention at while coding is if you have the same character multiple times in a row. This is the reason why there is a timestamp along with the pressed button. If the time between two button presses is too high but the pressed button is the same as the button pressed before it should be counted as a new button click and therefore a new character.
26
27 The special button `N7110_KEYPAD_MENU_RIGHT` has also been used which deletes on button press the last character entered.
28
29 To execute the code which decrypts the message just run `node challenge1.js` which outputs the following:
30
31 ```
32 alright pal herse ye flag good lucj enteking it with those hooves lol its aotw{l3ts_dr1nk_s0m3_eggn0g_y0u_cr4zy_d33r}0m.. .l ,p
33 ```
34
35 The solution for the challenge is `l3ts_dr1nk_s0m3_eggn0g_y0u_cr4zy_d33r`.
36
37
38
39
40 ## Challenge 4
41
42 Time: about 4h without writeup
43
44 ### Task description
45
46 ```
47 'Moo may represent an idea, but only the cow knows.' - Mason Cooley
48 Service: http://3.93.128.89:1204
49 ```
50
51 ### Overview
52
53 Opening the service located at the given IP you are given an interface where you can enter a message, choose a type of cow and then click `say`. This prints an ASCII cow which says your message. At the bottom of the site the used `cowsay` version is linked (https://packages.ubuntu.com/bionic/cowsay).
54
55 ### Exploitation
56
57 After opening the site and printing the first cow on to the site I noticed that there is an option to select the desired type of cow. The repository of cowsay at https://github.com/schacon/cowsay/tree/master/cows shows that there are per default some cow "skins" available but `custom` is none of them.
58
59 Choosing the `custom` cow you will be presented with a text field to enter your cow. In the manual of `cowsay` (see https://man.cx/cowsay if not installed on your system) is the following written:
60
61 ```
62 A cowfile is made up of a simple block of perl(1) code, which assigns a picture of a cow to the variable $the_cow.
63 ```
64
65 This can also be seen in the example cows previously linked. So I just tried to early end the string with `EOC` and doing a `print system("ls");` to list all the files which worked.
66
67 So the complete code for exploitation is:
68
69 ```
70 EOC
71 print system("ls");
72 ```
73
74 to list all the the files and then
75
76 ```
77 EOC
78 print system("cat flag");
79 ```
80
81 which prints the flag `AOTW{th3_p3rl_c0w_s4ys_M0oO0o0O}`.
82
83
84
85
86 ## Challenge 5
87
88 Time: about 6h without writeup
89
90 ### Task description
91
92 ```
93 Santa's little helpers are notoriously good at solving Sudoku puzzles, so they made a special variant...
94 ```
95
96 ### Overview
97
98 After downloading an archive you are given a `.txt` file with the challenge description. The task is to solve a given Sudoku with 12 equations that must hold for the solved Sudoku. The equations all look similar to this one: `B9 + B8 + C1 + H4 + H4 = 23`.
99
100 ### Exploitation
101
102 To solve the challenge I wrote at first a simple JS function that checks if a valid Sudoku also fulfills the equations given. Therefore I installed a small library which solves a given Sudoku on a random basis. This solution might work but would take forever because the possiblity is high that the generated solutions of the library are often the same as already solved ones.
103
104 I stopped continuing working on the challenge because someone else already solved it with `z3py` by just adopting the Sudoku example (see https://ericpony.github.io/z3py-tutorial/guide-examples.htm). A theorem prover is definitely a better, easier and faster way to solve this challenge.
105
106 My try can still be run with `yarn` and `node challenge5.js`.
107
108
109
110
111 ## Challenge 17
112
113 Time: about 6h without writeup
114
115 ### Task description
116
117 ```
118 It's not just leprechauns that hide their gold at the end of the rainbow, elves hide their candy there too.
119 Service: http://3.93.128.89:1217/
120 ```
121
122 ### Overview
123
124 Opening the website presents you with a simple clicker game where you at first enter your name and are then presented with an UI where you can do the following things:
125
126 - `collect`
127 - `melt`
128 - `upgrade collection speed`
129 - `buy a flag`
130 - `show growth chart`
131 - `erase progress and restart adventure`
132
133 The goal is to collect as many snowflakes as possible or at least this is usually the goal of a clicker game.
134
135 ### Exploitation
136
137 At first the `buy a flag` button got my attention but the button is disabled and it says that you need `10^63` snowflakes. This is too much that you can make it by playing the game. So I tried sending a custom set amount to the server at `http://3.93.128.89:1217/client` with data `{"action": "collect", "amount": 1e63}` and some variations but unfortunately this is checked on the server side and you can only increase the amount of snowflakes by the amount you are supposed to. Also the other endpoints are not very helpful. Another interesting endpoint is `http://3.93.128.89:1217/history/client` where all previously sent requests are shown. But also with this endpoint the amount of snowflakes can not be increased. I also thought that it's maybe possible to do an underflow with the `melt` action but as far as I found out you can only decrease the amount of snowflakes by one at a time and there server is rate limited because if you send too much requests in a short period of time you get the message:
138
139 ```
140 {
141     "error": "Throttled at one request per second. Please note that this challenge does NOT require brute forcing, and does NOT require sending an excessive number of requests."
142 }
143 ```
144
145 I tried sending different data to all the different endpoints in the website uses but no luck. Often the server just throws a `500` but I didn't managed to find a way for exploiting this. The server used is `Werkzeug/0.16.0 Python/2.7.17` as it can be found in the response header but unfortunately the debugging mode is not enabled.
146
147 The challenge is also marked as `crypto` and the only thing that points into that direction is the use of the cookie. To buy the flag there is maybe the cookie of an account needed which has enough snowflakes to buy the flag. But I didn't find a way to get more out of the cookie and haven't found any other cookie in the server responses.
148
149 Later the Mattermost people discovered by bruteforcing that there is another endpoint located at `http://3.93.128.89:1217/history/control`.