File Inclusion/Path Traversal

File Inclusion

Remote File Inclusion (RFI): The file is loaded from a remote server (Best: You can write the code and the server will execute it). In php this is disabled by default (allow_url_include). Local File Inclusion (LFI): The sever loads a local file.

The vulnerability occurs when the user can control in some way the file that is going to be load by the server.

Vulnerable PHP functions: require, require_once, include, include_once

Blind - Interesting - LFI2RCE files

wfuzz -c -w ./lfi2.txt --hw 0 http://10.10.10.10/nav.php?page=../../../../../../../FUZZ

Good wordlists for fuzzing

Basic LFI and Bypass Techniques

Top 25 parameters

Here’s list of top 25 parameters that could be vulnerable to local file inclusion (LFI) vulnerabilities (from link):

Basic RFI

LFI / RFI using PHP wrappers & protocols

php://filter

data://

expect://

input://

More protocols

LFI2RCE

Log injection

If the Apache or Nginx server is vulnerable to LFI and you're able to reach the log file, set the user agent or inside a GET parameter a php shell like <?php system($_GET['c']); ?> and include that file. We do this in HTB box Vessel.

Default log paths:

Via /proc/self/environ

Like a log file, send the payload in the User-Agent, it will be reflected inside the /proc/self/environ file

Via PHP sessions

Check if the website use PHP Session (PHPSESSID)

Sessions are stored in /var/lib/php5/sess_[PHPSESSID] by default

Set the cookie to <?php system('cat /etc/passwd');?> or in POST data:

Use the LFI to include the PHP session file

Last updated

Was this helpful?