File inclusions (LFI, RFI)
Last updated
Last updated
A file inclusion vulnerability is a type of web vulnerability that is most commonly found to affect web applications that rely on a scripting run time. This issue is caused when an application builds a path to executable code using an attacker-controlled variable in a way that allows the attacker to control which file is executed at run time.
--
allow_url_include
allow_url_fopen
Example:
If we want to get rid of the enforced .php
extension, we must terminate the string before. Following two ways may let you achieve exactly that.
Terminate string with a null byte: %00
(PHP < 5.3.4).
Add a query parameter.
Above example then becomes path/filename.txt?bla=.php
, the query parameter is ignored and the file is loaded as desired.
If requests are written to a log file and you are able to let a php script read and interpret those logs (LFI) you may even be able to gain remote code execution (RCE).
Connect to the target.
Write some php, that gets written into a log file.
Exploit an LFI to gain RCE.
Use php filter and base64 encoding to bypass php execution and retrieve the source code.
See also .