There's a nasty malware infecting our visitors. We were unable to find out where it's coming from and what it's doing. Do us a solid and find that out!
Note: You will see a red square saying 'Pwned' when the malware runs.
Launch Firefox debugger (CTRL + SHIFt + S), wait some time, and soon an additionnal script called www.malware.com/md5.js appears where there is a flag() function returning rqtWBTPbJ8cXgYSX.
10 years has passed since MD5 was broken, yet it is still frequently used in web applications, particularly PHP powered applications (maybe because there's a function after it?). Break it again to prove the point!
Here is the source code of the challenge:
Usually when talking about type juggling in php with md5 we have something more like if (0==md5($input)) or if ('0e123456789012345678912345678901'==md5($input)) so it's easy. But here we have if ($input==md5($input)).
So we can't use easy input or md5 magic hash.
We are talking about type juggling between two strings so we need that the text (input) and its md5 hash match /^0e[0-9]+$/ to fool php.
Apparently that malware you just found was a first in a wave of new malwares. They have struck again, this time on our partner service.
This malware is a little tricky and does not trigger all the time. We guess that it only runs on certain conditions. Find it for us please!
Note: You will see a red square saying 'Pwned' when the malware runs.
We reloaded the page until the malware appears to be loaded.
When the red square saying Pwned appears we know the javascript code will be in the Firefox debugger (CTRL + SHIFt + S).
The content of forensics/eluware2/www.youtube.com/?random=9.551122063861918 seems packed / obfuscated.
After beautification we get:
Instead of taking a long time to unpack this piece of code. We will try to evaluate the part giving the flag.
For that I used a Firefox addon called javascript-deobfuscator in order to execute/compile/evaluate the obfuscated code on the fly.
So now our Firefox Web Developer console has one more tab: Deobfuscator.
In the Console tab we can now paste the malware code to make it executed whenever we want and then the red square saying Pwned appears.
So just after we forced the malware to be executed we can go back into the Deobfuscator tab to see running scripts.
The 2nd line of each evaluated script show its source. We can see several script with debugger eval code:1 indicating that this is the script we just evaluated.
The first pane on the left showing debugger eval code:1 is the code we pasted, the 2nd pane is just the content of the main function, the 3rd if the content of the second f = function, the 4th is the div that show the red square and contains this:
So the first part of the flag is random=6.66 willtell (that give us 30/150 points).
The first time we saw the malware appear is was forensics/eluware2/www.youtube.com/?random=9.551122063861918 and know the partial flag tell use random=6.66.
Searching for random in the debugger show there is a local script rpc-shindig_random.js overridding the google API one with the same name.
So I tried to see the difference between the two scripts. There was a lot of them (93 lines, once code was unminified) but there was one variable existing on the local script that didn't exist on the true google api: "lexps": [81, 97, 99, 122, 123, 30, 79, 127].
On the main page we can see something looking like the malware but this isn't the same code:
Let's evaluated that piece of code and observe it in the Deobfuscator tab.
Now we can see why the malware is not triggered everytime:
So the malware will be loaded 1 time over 10.
But we can't use directly
because the malware know we launched it manually.
I didn't manage to request ?random=6.66 successfully, I always got 33.3.
There's this system that has a hardcoded admin user/password, in a way that can not be brute forced or cracked. We desperately need to acquire access to this system, can you help us?
Note: Source code inside challenge
So the source of the challenge is:
What do we want? if (hasher($user)==hasher($password) and $user!=$password). So we need different $user and $password but an equal hasher() return. In fact we don't need hasher() to return the same result thanks to == that will allow us to do some PHP Magic Tricks: Type Juggling as we already saw in challenge MD5 Games 1.
In fact we want hasher($user) and hasher($password) to match /^0e[0-9]{8}$/.
The next thing to see is extract($_POST);. That will allow us to override $admin as I explained in my post about c99.php web shell.
If this still seems ununderstandable to you read my MD5 Games 1 write-up above.
This time I didn't write a ruby script but re-used the php source code to write a php script:
I executed my script and it resulted as the following:
So I just needed to send this POST request with HackBar (you can do it with whatever proxy you like, ex: BurpSuite).
POST data: password=56392&user=29588. Here is the result: Welcome! Flag is: g1diXbB2kfaGjS0V.