This challenge was a basic SQL injection, let’s follow our methodology and extract the informations in the database. First we need to extract the columns number of the current “SELECT column1, column2 FROM …”
We can clearly see the injection point is located in the 4th columns.
Let’s extract the version now
Extract database name
This is interesting, there is an ECW database. Let’s dig into it by extracting the table name.
Extract columns name
That’s great now we can do a simple “SELECT” query to get the username and password of every users.
Unfortunately there are a lot of flags, we can try them all.. or be a little bit smarter.
Since we can dump the content we can try to export the “comment” section
This one looked promising, and we can validate with it.
Web 100 - Pass Through
At first, I was looking for an SQL injection in order to bypass the login, the following payload worked:
It says the “password is the flag”, damn we need to extract it with a blind injection. After a lot of tries I discovered it was an XPATH injection instead of an SQL. We will use the string-length to check the size of a string, here we know the size of the username, this will help verify our guess.
Now we can script this in order to extract the size of the password, since we know it’s >20 and <40.
The output of this script will give the the length of the password : 37
Now we will extract the characters one by one with the “substring” method, e.g:substring(“ABCD”,2,1)=’B’
With this we get BCPP6f5f5724aa2fa973bb9471746c2cb4a0} which looks like a flag, we can easily correct the first chars : ECW{6f5f5724aa2fa973bb9471746c2cb4a0}
Web 150 - GoldFish
GoldFish was a Web Application written in PHP, where you can write a “post-it” which will self-destroy after 30sec.
For this challenge I created a user named “glopglopglop” this will be needed for the exploitation ;)
First I tried to exploit an XSS, you could write a “Post” with the following input:
The “Post” would be available at “/posts/user/postname” (this URL was found when you submit the same post twice in less than 30sec)
Here is a simple output that triggered the XSS (the payload is from XSSHunter), it was available at https://challenge-ecw.fr/chals/web150/posts/glopglopglop/mymemo
I waited hours and hours, nothing happened..
Then I try to fuzz a little bit the “name” field since we could “rewrite” the URL. I finally managed to find an LFI with the source code reflected in the dashboard inside the memo. Thanks to this we could extract all the source code of the WebApp
The cookie part was interesting, it is decrypting its content with “decryptString”. By looking deeper in the generation of the cookie I discovered it was based on the name of the user but the password wasn’t part of it.
This encrypted string was used in the cookie as follow:
This means we can forge our cookie to be connected as admin since we only need a valid hash based on his name.
The “ID” of admin was ‘1’, after replacing our cookie with the forged one we get the following flag:
Web 175 - Magic Car
The topic of this challenge was the following text: “Notre nouveau système de réservation de covoiturage a été piraté. Le pirate a ajouté un nouveau formulaire d’authentification et a changé le mot de passe administrateur. Nous avons réussi à retrouver le code source de l’interface, mais nous ne pouvons pas récupérer le service sans les informations d’identification valides.
Aide nous à les retrouver.”. We had to find a way to login without a valid username/password. The source code of the challenge was also provided.
So we need to have an MD5 hash equal to 0e413229387827631581229643338212. This is a basic type juggling in PHP, because 0e0123.. is a float representation in PHP we can do the following:
We want a magic hashed in PHP, it’s an hash where the content is only made of integers. WhiteHatSec already done the research for us : https://www.whitehatsec.com/blog/magic-hashes/
We can split the string “240610708” to create a valid authentification.
Then we get the flag ECW{846badef298374cc62934fdfdeee2341}
This challenge reminded me of one I created for the ESE 2016, check out the write-up ! ;)