Path: blob/master/modules/auxiliary/scanner/oracle/tnslsnr_version.rb
19715 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 Service Version Query',15'Description' => %q{16This module simply queries the tnslsnr service for the Oracle build.17},18'Author' => ['CG'],19'License' => MSF_LICENSE,20'DisclosureDate' => '2009-01-07',21'Notes' => {22'Reliability' => UNKNOWN_RELIABILITY,23'Stability' => UNKNOWN_STABILITY,24'SideEffects' => UNKNOWN_SIDE_EFFECTS25}26)27)2829register_options(30[31Opt::RPORT(1521)32]33)34end3536def run_host(ip)37begin38connect3940pkt = tns_packet("(CONNECT_DATA=(COMMAND=VERSION))")4142sock.put(pkt)4344select(nil, nil, nil, 0.5)4546data = sock.get_once4748if (data && data =~ /\\*.TNSLSNR for (.*)/)49ora_version = data.match(/\\*.TNSLSNR for (.*)/)[1]50report_service(51:host => ip,52:port => datastore['RPORT'],53:name => "oracle",54:info => ora_version55)56print_good("#{ip}:#{datastore['RPORT']} Oracle - Version: " + ora_version)57elsif (data && data =~ /\(ERR=(\d+)\)/)58case $1.to_i59when 118960print_error("#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown - Error code #{$1} - The listener could not authenticate the user")61else62print_error("#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown - Error code #{$1}")63end64else65print_error("#{ip}:#{datastore['RPORT']} Oracle - Version: Unknown")66end67disconnect68rescue ::Rex::ConnectionError69rescue ::Errno::EPIPE70end71end72end737475