05. Exploit PoC
Visiting http://10.200.105.100/resources presents a login prompt. The credentials recovered earlier when dumping creds with Mimikatz come in handy here.
Log In
- Potential usernames:
Thomasandtwreath - Potential password:
i<3ruby - Working login:
Thomas:i<3ruby
Test the Upload Filter
Uploading an image with a .jpg extension returns this:
Uploading something outside the whitelist filter returns this:
Craft the Payload
I already know a second extension of .php bypasses the first filter, but the second filter is more challenging. Since the getimagesize() check looks for image attributes, I can satisfy it with a real image while hiding a PHP webshell in the Comment field of the image metadata using exiftool.
Copy a real image to the double extension and inspect it:
cp realimage.jpg shell.jpg.php
exiftool shell.jpg.php
Add a PHP payload into the file's metadata:
exiftool -Comment="<?php echo \"<pre>Test Payload</pre>\"; die(); ?>" shell.jpg.php
After uploading the file and navigating to http://10.200.105.100/resources/uploads/shell.jpg.php:
This is great news because it means I have RCE on the server. I'm going to hold off on uploading a full shell though, since I'm unsure what AV Thomas has on his machine and want to avoid setting off any alarms. I'll revisit this after obfuscating the file to evade AV detection.