Explanation
Exploit a vulnerable PHP file upload page to view the contents of /flag.txt.
Solving the Challenge
- The upload only allows PNG file types.
- If we add “.png” to the end of a php file (so the file name ends in .php.png), the upload will permit the file.
- The upload also appears to restrict the length of the file.
-
I opened a PNG file and removed the information except for the header and the size information, then added the PHP code to output the contents of /flag.txt:
<?php
echo file_get_contents( "/flag.txt" );
?>
- Upload the file.
- Visit the profile page.
- Right click the profile page, and click Inspect.
- Find the URI for the profile picture.
- Open a new tab.
- Browse to the URI for the profile picture.
Instance address