FCSC - CTF Writeup
FCSC - FRANCE CYBERSECURITY CHALLENGE 2020
Some writeups of severals web challenges from the FCSC 2020.
Challenges’ Writeup
- WEB - EnterTheDungeon
- WEB - Rainbow Pages
- WEB - Rainbow Pages v2
- WEB - Revision
- WEB - Bestiary
- WEB - Lipogramme
- WEB - Flag Checker
- Forensic - Petite frappe 2
- Intro - Babel
- Intro - SuSHi
- Intro - Tarte Tatin
- Intro - Sbox
- Intro - Le Rat Conteur
WEB - EnterTheDungeon
The source code of the check_secret.php is given at view-source:challenges2.france-cybersecurity-challenge.fr:5002/check_secret.txt
. The following code is stripped to keep only the interesting part.
We can clearly see it is about PHP Type Juggling since we are comparing md5($_GET['secret'])
with its value.
In PHP a value starting with 0e and followed by numbers is considered as a float, and some MD5(value) will also result in 0e[0-9]{30}. The comparison will then occured on two float numbers, since the code is using == instead of ===, PHP will only check the object type and not the value.
We can validate the challenge using the value 0e1137126905 : http://challenges2.france-cybersecurity-challenge.fr:5002/check_secret.php?secret=0e1137126905
Flag: FCSC{f67aaeb3b15152b216cb1addbf0236c66f9d81c4487c4db813c1de8603bb2b5b}
WEB - Rainbow Pages
This challenge is a basic GraphQL injection, first we see a request is made to http://challenges2.france-cybersecurity-challenge.fr:5006/index.php?search=[BASE64].
Since most of the tools doesn’t allow to interact with base64 I opted to build to simple proxy in Python using Flask.
Now every request fired to /graphl?query=[SOMETHING]
will be “converted” for the challenge, and the result will be displayed in the page. We can now use every tools to ease our work, I like to use Altair as it’s really beautiful :)
We can send the instrospection query in order to discover the schema of the GraphQL : https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/GraphQL%20Injection#enumerate-database-schema-via-introspection.
It looks like that, once converted : CLICK ME also Altair provide a simple listing of the “object” and can build a query for you.
From there it was easy to click on the “Altair Button” to ask for the flag :P
WEB - Rainbow Pages v2
Another iteration of the GraphQL challenge available at http://challenges2.france-cybersecurity-challenge.fr:5007/. We can reuse our python proxy.
It appears we were inside a query instead of sending the full query like in the 1st challenge. Let’s fuzz the input to see if we can trigger some errors to help understand where we are injecting.
The blockstring """
helps us discover part of the query, we are inside a weird filter like the following request.
Now we can try to recreate the end of the query, and add our evil payload. At first I tried to replicate a GraphQL query using OR in the previous challenge thanks to the proxy.
Then we can try to request the flag, however it is not labelled like the other challenge, but the errors are quite straightforward and will suggest the correct name.
Now let’s get the flag !
WEB - Revision
Once again the source code is provided, we have to upload two files but they must have the same SHA1 hashes.
We find two files with a SHA1 collisions on Corkami’s Github:
- https://github.com/corkami/collisions/blob/master/examples/dualjpg1.pdf
- https://github.com/corkami/collisions/blob/master/examples/dualjpg2.pdf
FCSC{8f95b0fc1a793e102a65bae9c473e9a3c2893cf083a539636b082605c40c00c1}
WEB - Bestiary
Bestiary was a classic Local File Inclusion, abusing the session to execute arbitrary commands on the server.
First we can grab the source code by using a PHP filter : challenges2.france-cybersecurity-challenge.fr:5004/index.php?monster=php://filter/convert.iconv.utf-8.utf-16/resource=index.php
. It will be displayed as UTF16 thus not being interpreted as a PHP code. Here is a curated extract of the code.
We want to include the content of flag.php and bypass the filter strpos($monster, "flag")
which denies us to directly use our wrapper to access flag.php.
The PHP code is changing the default path to save temporary file used to store PHP sessions. In PHP when you have a cookie PHP_SESSID=3ba53bc0ae7fea081347b3f1f8cf0c41
there is a file named sessions/sess_3ba53bc0ae7fea081347b3f1f8cf0c41
containing a “serialized” version of the cookie.
- First we need to put our payload inside our session file :
http://challenges2.france-cybersecurity-challenge.fr:5004/index.php?monster=<?php%20echo%20file_get_contents(%27fl%27.%27ag.php%27);%20?>
. - Then we include our session file
http://challenges2.france-cybersecurity-challenge.fr:5004/index.php?monster=/var/www/html/sessions/sess_3ba53bc0ae7fea081347b3f1f8cf0c41
$flag=”FCSC{83f5d0d1a3c9c82da282994e348ef49949ea4977c526634960f44b0380785622}”;
WEB - Lipogramme
We have the following source code, which implement a filter to limit the code executed on the server.
We have to create a web shell PHP using only special characters, many webshell like that can be found on Github.
Then we execute the commands ls -a
and cat .f*
to bypass the filter and read the flag.
FCSC{53d195522a15aa0ce67954dc1de7c5063174a721ee5aa924a4b9b15ba1ab6948}
WEB - Flag Checker
A simple web asm binary where you could guess the flag cipher. http://challenges2.france-cybersecurity-challenge.fr:5005/index.js
We can find a reference to index.wasm
in the Javascript.
We can find the flag since the format is starting by FCSC.
FCSC{7e2d4e5ba971c2d9e944502008f3f830c5552caff3900ed4018a5efb77af07d3}
Forensic - Petite frappe 2
FCSC{un_clavier_azerty_en_vaut_deux}
Intro - Babel
A simple web intro were we could execute arbitrary commands : view-source:challenges2.france-cybersecurity-challenge.fr:5001/?code=cat%20flag.php
.
Intro - SuSHi
The flag was in a hidden file .flag
.
Intro - Tarte Tatin
Using a simple decompiler such as Ghidra or IDA will give us a “pseudo” code like .
The transform method is simple caesar cipher, we can grab the flag_enc and decrypt it .
A basic cesar -1 python code.
Intro - Le Rat Conteur
The task is giving us the key, the cipher and the IV. We only need to use them.
Intro - Sbox
A very simple “cryptographic” challenge where you only have to follow the boxes
The following truth tables will help
We can reproduce the logic in Python
FCSC{0101}