At first, if you launch a dirsearch/dirbuster or anything to list files on server, you find a backup.bak, which contains the source code of the challenge. Alternatively, you click on the link in the hint. It is a zip file that contains:
Interesting files are lib/connection.php, login.php and upload.php.
We can see that project use the AES CBC to encrypt and decrypt a remember_me cookie.
There are 2 vulnerabilities in their AES CBC usage and one classic vulnerability of web developer:
IV = KEY, NEVER NEVER you do that. IV must be random and unique for each encryption.
lib/connection.php (look gen_cookie and check_cookie)
They returns the decoded token to the user if it is bad. They are so kindly.
login.php (follow the $username and $tmp variables)
A SQL injection inside the SQL query to find the user.
With that, we have to encrypt our SQL payload to do the injection and get an admin access.
However, how encrypt our payload without the key? Just recover the key! Easy, isn't it?
For explanations about how can we recover IV (which is equals to key), I used this link to understand the problem and found the right formula: https://cryptopals.com/sets/4/challenges/27
The only to do is to register a user and get his remember_me cookie and script a little to build a forged token to obtain its plain version through website. I used the "aaaa" account created by someone else (thank you).
The next step is to login as admin in the application. To do this, we have to found a user who is admin, or fake the system: ' and 1=0 union select username, 1 from Users where username='aaaa.
The application understand that the "aaaa" user is an admin.
As the flag is store on the website source code, we have to read it through a webshell. Why webshell? Because there is no entry from user on website which can lead to a command exec and the application offers an upload functionality.
upload.php
In order to upload a webshell, we have to create a zip file which contains our PHP webshell (just google it for webshell) and a specific manifest.json.
manifest.json
Upload it.
And get the flag: AceBear{From_Crypt0_m1sus3_t0_Rc3_______}