PHP - LFI and RFI
How to Exploit PHP LFI/RFI and Methods:
1) Basic Local File Inclusion and Remote File Inclusion 2) Null Byte 3) Base64 Encoded 4) PHP Input Wrapper 5) PHP Zip Wrapper 6) proc/self/environ 7) Log File Contamination 8) Email Revese Shell 9) phpinfo LFI
Basic Local File Inclusion and Remote File Inclusion
Null Byte
Base64 Encoded
PHP Input Wrapper - POST
Example 1:
Example 2:
PHP Zip Wrapper
The zip wrapper processes uploaded .zip files server side allowing a penetration tester to upload a zip file using a vulnerable file upload function and leverage he zip filter via an LFI to execute. A typical attack example would look like:
1. Create a PHP reverse shell 2. Compress to a .zip file 3. Upload the compressed shell payload to the server 4. Use the zip wrapper to extract the payload using:
5. The above will extract the zip file to shell, if the server does not append .php rename it to shell.php instead
proc/self/environ
Log File Contamination
Email Revese Shell
phpinfo() LFI
1 - Check if upload is enabled
2 - Execute the POST with Content Type and check for PHP variables. Below are two examples.
Example 1 from the documentation:
Example 2 from IPPSEC - POISON
2 - The script is located at PayLoadAllTheThings - PHP LFI Path.
3 - Start the listener and get it done
References: https://secf00tprint.github.io/blog/payload-tester/lfirfi/en https://www.hackingarticles.in/5-ways-exploit-lfi-vulnerability/ https://highon.coffee/blog/lfi-cheat-sheet/ https://www.rcesecurity.com/2017/08/from-lfi-to-rce-via-php-sessions/
Last updated