Path: blob/master/modules/auxiliary/scanner/oracle/tnspoison_checker.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Report7include Msf::Auxiliary::Scanner8include Msf::Exploit::Remote::TNS910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Oracle TNS Listener Checker',15'Description' => %q{16This module checks the server for vulnerabilities like TNS Poison.17Module sends a server a packet with command to register new TNS Listener and checks18for a response indicating an error. If the registration is errored, the target is not19vulnerable. Otherwise, the target is vulnerable to malicious registrations.20},21'Author' => ['ir0njaw (Nikita Kelesis) <nikita.elkey[at]gmail.com>'], # of Digital Security [http://dsec.ru]22'References' => [23[ 'CVE', '2012-1675'],24[ 'URL', 'https://seclists.org/fulldisclosure/2012/Apr/204' ],25],26'DisclosureDate' => '2012-04-18',27'License' => MSF_LICENSE,28'Notes' => {29'Reliability' => UNKNOWN_RELIABILITY,30'Stability' => UNKNOWN_STABILITY,31'SideEffects' => UNKNOWN_SIDE_EFFECTS32}33)34)3536register_options(37[38Opt::RPORT(1521)39]40)41end4243def run_host(ip)44begin45connect46send_packet = tns_packet("(CONNECT_DATA=(COMMAND=service_register_NSGR))")47sock.put(send_packet)48packet = sock.read(100)49if packet50hex_packet = Rex::Text.to_hex(packet, ':')51split_hex = hex_packet.split(':')52find_packet = /\(ERROR_STACK=\(ERROR=/ === packet53if find_packet == true # TNS Packet returned ERROR54print_error("#{ip}:#{rport} is not vulnerable")55elsif split_hex[5] == '02' # TNS Packet Type: ACCEPT56print_good("#{ip}:#{rport} is vulnerable")57elsif split_hex[5] == '04' # TNS Packet Type: REFUSE58print_error("#{ip}:#{rport} is not vulnerable")59else # All other TNS packet types or non-TNS packet type response cannot guarantee vulnerability60print_error("#{ip}:#{rport} might not be vulnerable")61end62else63print_error("#{ip}:#{rport} is not vulnerable")64end65# TODO: Module should report_vuln if this finding is solid.66rescue ::Rex::ConnectionError, ::Errno::EPIPE67print_error("#{ip}:#{rport} unable to connect to the server")68end69end70end717273