Path: blob/master/modules/auxiliary/scanner/oracle/xdb_sid.rb
19778 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::Exploit::Remote::HttpClient8include Msf::Auxiliary::Scanner910def initialize11super(12'Name' => 'Oracle XML DB SID Discovery',13'Description' => %q{14This module simply makes an authenticated request to retrieve15the sid from the Oracle XML DB httpd server.16},17'References' => [18[ 'URL', 'http://dsecrg.com/files/pub/pdf/Different_ways_to_guess_Oracle_database_SID_(eng).pdf' ],19],20'Author' => [ 'MC' ],21'License' => MSF_LICENSE22)2324register_options(25[26Opt::RPORT(8080),27OptString.new('DBUSER', [ false, 'The db user to authenticate with.', 'scott']),28OptString.new('DBPASS', [ false, 'The db pass to authenticate with.', 'tiger']),29]30)31end3233def run_host(ip)34begin35user_pass = "#{datastore['DBUSER']}:#{datastore['DBPASS']}"3637res = send_request_raw({38'uri' => '/oradb/PUBLIC/GLOBAL_NAME',39'version' => '1.0',40'method' => 'GET',41'headers' =>42{43'Authorization' => "Basic #{Rex::Text.encode_base64(user_pass)}"44}45}, 5)4647if (not res)48vprint_error("Unable to retrieve SID for #{ip}:#{datastore['RPORT']} with #{datastore['DBUSER']} / #{datastore['DBPASS']}...")49return50end5152if (res.code == 200)53if (not res.body.length > 0)54# sometimes weird bug where body doesn't have value yet55res.body = res.bufq56end57sid = res.body.scan(/<GLOBAL_NAME>(\S+)<\/GLOBAL_NAME>/)58report_note(59:host => ip,60:port => datastore['RPORT'],61:proto => 'tcp',62:type => 'oracle_sid',63:data => { :sid => sid },64:update => :unique_data65)66print_status("Discovered SID: '#{sid}' for host #{ip}:#{datastore['RPORT']} with #{datastore['DBUSER']} / #{datastore['DBPASS']}")67else68print_error("Unable to retrieve SID for #{ip}:#{datastore['RPORT']} with #{datastore['DBUSER']} / #{datastore['DBPASS']}...")69end70rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout71rescue ::Timeout::Error, ::Errno::EPIPE72end73end74end757677