Local file inclusion vulnerabilities

Local file exploits or vulnerabilities allow us to read any file that is within the same server as the vulnerability; even if the file exists outside the /var/www directory, we'll be able to read the information within it.

A vulnerability is critical because we can read any files, such as important files or password files. Also, if there are a number of websites on the same server and we managed to find a website that we're not targeting, then we might be able to access files related to the website that we're targeting and then further exploit the website from there.

We are going to exploit the vulnerability through the URL. So, usually in our code execution examples, we write the code in the textbox. Sometimes, we might find the code vulnerability in the URL, which will have keywords such as cmd.

The same old process continues. Click on the File Inclusion tab on the DWVA server and the URL we get is http://10.0.2.4/dvwa/vulnerabilities/fi/?page=include.php.

We can see that the file already has a page. The include.php command will again load another page. As in the previous example, we will again see the URL with the IP address and the same ping command, as explained in the previous section. Here, in our example, the objective is to open a file using include.php. After removing the page term from the URL, the URL now will be visible as http://10.0.2.4/dvwa/vulnerabilities/fi/include.php. There is a fatal error generated, as shown in the following screenshot:

We can see a file named include.php on the page, which is in the same working directory. Let's try and see whether we can read a file called /etc/passwd that is stored in the computer. It's the file containing all the user passwords present on the current web server and all the users using the current OS. Let's go to the Terminal and run some commands. For example, running cat/etc/passwd on Kali returns the following output:

We will see all the users that we have been on the current computer and their default paths on the current OS. We will now try to read the passwd file. To do this, go back to the current location in the fi directory, which was mentioned before. Referring to the previous screenshot, when in /var/www/dvwa/vulnerabilities/fi/include.php, we are in the fi directory; we need to go back five places back to get to /etc/passwd.

As explained, we will need to go five places back by adding double dots. So, the URL changes to http://10.0.2.4/dvwa/vulnerabilities/fi/?page=../../../../../../etc/passwd. The output will be seen once we hit Enter is as follows:

We will be able to see the /etc/passwd files. To understand and read the data, copy the data on a notepad. By doing so, we will get more information about the targeted websites. We can also access different, sensitive files, or files of other websites on the same server. The next section will help us understand remote file inclusion using Metasploitable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.152.251