2009-07-16 00:03:50 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# 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-07-16 00:03:50 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Exploit::Remote::TNS
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2010-11-24 19:43:49 +00:00
|
|
|
'Name' => 'Oracle TNS Listener SID Brute Forcer',
|
2009-07-16 00:03:50 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module simply attempts to discover the protected SID.
|
|
|
|
},
|
|
|
|
'Author' => [ 'MC' ],
|
|
|
|
'License' => MSF_LICENSE,
|
2010-09-20 08:06:27 +00:00
|
|
|
'References' =>
|
2009-07-16 00:03:50 +00:00
|
|
|
[
|
|
|
|
[ 'URL', 'https://www.metasploit.com/users/mc' ],
|
|
|
|
[ 'URL' , 'http://www.red-database-security.com/scripts/sid.txt' ],
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Jan 7 2009'))
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(1521),
|
|
|
|
OptString.new('SLEEP', [ false, 'Sleep() amount between each request.', '1']),
|
|
|
|
OptString.new('SIDFILE', [ false, 'The file that contains a list of sids.', File.join(Msf::Config.install_root, 'data', 'wordlists', 'sid.txt')]),
|
|
|
|
], self.class)
|
2009-07-16 00:03:50 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
|
|
|
|
s = datastore['SLEEP']
|
|
|
|
list = datastore['SIDFILE']
|
|
|
|
|
|
|
|
print_status("Starting brute force on #{rhost}, using sids from #{list}...")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-07-01 23:33:07 +00:00
|
|
|
fd = File.open(list, 'rb').each do |sid|
|
|
|
|
login = "(DESCRIPTION=(CONNECT_DATA=(SID=#{sid})(CID=(PROGRAM=)(HOST=MSF)(USER=)))(ADDRESS=(PROTOCOL=tcp)(HOST=#{rhost})(PORT=#{rport})))"
|
|
|
|
pkt = tns_packet(login)
|
|
|
|
|
|
|
|
begin
|
|
|
|
connect
|
|
|
|
rescue => e
|
2012-03-18 01:37:42 +00:00
|
|
|
print_error(e.to_s)
|
2010-07-01 23:33:07 +00:00
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2010-07-01 23:33:07 +00:00
|
|
|
sock.put(pkt)
|
|
|
|
select(nil,nil,nil,s.to_i)
|
|
|
|
res = sock.get_once(-1,3)
|
2009-07-16 00:03:50 +00:00
|
|
|
disconnect
|
|
|
|
|
2010-09-20 08:06:27 +00:00
|
|
|
if ( res and res =~ /ERROR_STACK/ )
|
2009-07-16 00:03:50 +00:00
|
|
|
''
|
|
|
|
else
|
2010-08-18 00:58:20 +00:00
|
|
|
report_note(
|
|
|
|
:host => rhost,
|
2011-11-09 08:51:47 +00:00
|
|
|
:port => rport,
|
2010-08-18 00:58:20 +00:00
|
|
|
:type => 'oracle_sid',
|
2011-11-09 08:51:47 +00:00
|
|
|
:data => "PORT=#{rport}, SID=#{sid.strip}",
|
|
|
|
:update => :unique_data
|
2010-08-18 00:58:20 +00:00
|
|
|
)
|
2011-11-09 08:51:47 +00:00
|
|
|
print_good("#{rhost}:#{rport} Found SID '#{sid.strip}'")
|
2009-07-16 00:03:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("Done with brute force...")
|
|
|
|
fd.close
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|