]> git.somenet.org - pub/jan/ctf-seminar.git/blob - writeups/smashing/ctfzone19.md
added writeups
[pub/jan/ctf-seminar.git] / writeups / smashing / ctfzone19.md
1 # Retrospective
2 The goal of this CTF was to be as realistic as possible. I think they met their goal somehow but the web challenges were really not enjoyable due to a lot of guesswork. Especially the `bathhouse` which was a multi-stage challenge lead from one guessing part to another.
3
4 Time spent: ~15 hours
5 # bathhouse (solved)
6 ## Overview
7 A user can book an appointment for a bathhouse and needs to provide some data like the phone number and the amount of time to be there. 
8
9 ## Approach
10 The form was vulnerable to SQLi which allowed us to dump the database. The dumped database contained an `username` and `password` which is needed to login under `/set_price` found in the `robots.txt`. There we were able to change the price of a receipt which was generated with `wkhtmltopdf 0.12.1`. This version of `wkhtmltopdf` was vulnerable to file inclusion and therefore we were able to include data from the system. After messing around with different inclusion techniques we found that  `wkhtmltopdf` executes JS which allowed us to read files from the system and include its content into the generated pdf. 
11 ```
12 <script> 
13         x=new XMLHttpRequest;
14         x.onload=function() {
15                 document.write(this.responseText)
16         };
17         x.open("GET","file:///etc/passwd");
18         x.send();
19 </script>
20 ```
21 From this one an unnecessary search for the flag begun since the flag was not in an usual location like e.g. `/flag` and the structure of the project was unknown. After digging around on the server and looking for anything which could give a hint @lavish tried to find additional routes with `DirBuster` and eventually found another endpoint `/status/` containing the path to the app and used modules.
22
23 Afterwards we were able to extract the source code of the app which and one of the views yielded another hint to `http://syncdata/sync.html`. Unfortunately this path was not fetchable with our previous approach and again some time passed looking for other possible hints.
24 Eventually `syncdata` actually contained  the flag but was only accessible via an iframe which did not work for the other files on the filesystem.
25 Finally `<div><p>Report Heading</p><iframe src=http://syncdata/sync.html height="500" width="500">` as payload revealed the flag.