2009-05-01 22:01:21 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-05-01 22:01:21 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-05-01 22:01:21 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2009-05-01 22:01:21 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Oracle XML DB SID Discovery',
|
|
|
|
'Description' => %q{
|
|
|
|
This module simply makes a authenticated request to retrieve
|
|
|
|
the sid from the Oracle XML DB httpd server.
|
|
|
|
},
|
2009-07-23 02:55:51 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-05-01 22:01:21 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'URL', 'http://dsecrg.com/files/pub/pdf/Different_ways_to_guess_Oracle_database_SID_(eng).pdf' ],
|
|
|
|
],
|
|
|
|
'Author' => [ 'MC' ],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(8080),
|
|
|
|
OptString.new('DBUSER', [ false, 'The db user to authenticate with.', 'scott']),
|
|
|
|
OptString.new('DBPASS', [ false, 'The db pass to authenticate with.', 'tiger']),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
begin
|
|
|
|
|
|
|
|
user_pass = "#{datastore['DBUSER']}:#{datastore['DBPASS']}"
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-05-01 22:01:21 +00:00
|
|
|
res = send_request_raw({
|
|
|
|
'uri' => '/oradb/PUBLIC/GLOBAL_NAME',
|
|
|
|
'version' => '1.0',
|
|
|
|
'method' => 'GET',
|
|
|
|
'headers' =>
|
|
|
|
{
|
|
|
|
'Authorization' => "Basic #{Rex::Text.encode_base64(user_pass)}"
|
|
|
|
}
|
|
|
|
}, 5)
|
|
|
|
|
2010-03-11 22:55:37 +00:00
|
|
|
if( not res )
|
2012-01-30 19:08:35 +00:00
|
|
|
vprint_error("Unable to retrieve SID for #{ip}:#{datastore['RPORT']} with #{datastore['DBUSER']} / #{datastore['DBPASS']}...")
|
2010-03-11 22:55:37 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2009-05-01 22:01:21 +00:00
|
|
|
if (res.code == 200)
|
2010-04-30 08:40:19 +00:00
|
|
|
if (not res.body.length > 0)
|
2010-03-11 22:55:37 +00:00
|
|
|
# sometimes weird bug where body doesn't have value yet
|
|
|
|
res.body = res.bufq
|
|
|
|
end
|
|
|
|
sid = res.body.scan(/<GLOBAL_NAME>(\S+)<\/GLOBAL_NAME>/)
|
2009-05-01 22:01:21 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
2011-11-09 08:51:47 +00:00
|
|
|
:port => datastore['RPORT'],
|
2009-05-01 22:01:21 +00:00
|
|
|
:proto => 'tcp',
|
2011-11-09 08:51:47 +00:00
|
|
|
:type => 'oracle_sid',
|
2012-03-18 01:37:42 +00:00
|
|
|
:data => sid,
|
2011-11-09 08:51:47 +00:00
|
|
|
:update => :unique_data
|
2010-04-30 08:40:19 +00:00
|
|
|
)
|
2010-03-11 22:55:37 +00:00
|
|
|
print_status("Discovered SID: '#{sid}' for host #{ip}:#{datastore['RPORT']} with #{datastore['DBUSER']} / #{datastore['DBPASS']}")
|
2009-05-01 22:01:21 +00:00
|
|
|
else
|
2010-03-11 22:55:37 +00:00
|
|
|
print_error("Unable to retrieve SID for #{ip}:#{datastore['RPORT']} with #{datastore['DBUSER']} / #{datastore['DBPASS']}...")
|
2009-05-01 22:01:21 +00:00
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|