File Inclusion
Local File Inclusion
http://<RHOST>/<FILE>.php?file=
http://<RHOST>/<FILE>.php?file=../../../../../../../../etc/passwd
http://<RHOST>/<FILE>/php?file=../../../../../../../../../../etc/passwdNull Byte
%00
0x00Encoded Traversal Strings
../
..\
..\/
%2e%2e%2f
%252e%252e%252f
%c0%ae%c0%ae%c0%af
%uff0e%uff0e%u2215
%uff0e%uff0e%u2216
..././
...\.\Poisoning of apache logs
Modify the User Agent and execute php rce

PHP Wrappers
Filter Wrapper
Using php://filter, we can also display the contents of executable files such as .php, rather than executing them.
The PHP wrapper uses resource as the required parameter to specify the file stream for filtering, which is the filename in our case.
Let's now encode the output with base64 by adding convert.base64-encode. This converts the specified resource to a base64 string.
We can now use the base64 program with the -d flag to decode the encoded data in the terminal.
Data Wrapper
We can use the data:// wrapper to achieve code execution. This wrapper is used to embed data elements as plaintext or base64-encoded data in the running web application's code.
When web application firewalls or other security mechanisms are in place, they may filter strings like "system" or other PHP code elements. In such a scenario, we can try to use the data:// wrapper with base64-encoded data.
However, we need to be aware that the data:// wrapper will not work in a default PHP installation. To exploit it, the allow_url_include setting needs to be enabled.
File Wrapper
PDF PHP Inclusion
Create a file with a PDF header, which contains PHP code.
Remote File Inclusion (RFI)
While LFI vulnerabilities can be used to include local files, RFI vulnerabilities allow us to include files from a remote system over HTTP or SMB. The included file is also executed in the context of the web application.
Kali Linux includes several PHP webshells in the /usr/share/webshells/php/ directory that can be used for RFI. In this example, we will use the simple-backdoor.php webshell to exploit an RFI vulnerability.
Start a listener in our machine
Last updated