2015-03-19 16:16:04 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex/java/serialization'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2015-03-19 16:16:04 +00:00
|
|
|
|
|
|
|
include Msf::Auxiliary::Report
|
2015-10-09 20:24:34 +00:00
|
|
|
include Msf::Exploit::Remote::Java::Rmi::Client
|
2015-03-19 16:16:04 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2015-03-19 22:33:45 +00:00
|
|
|
'Name' => 'Java RMI Registry Interfaces Enumeration',
|
|
|
|
'Description' => %q{
|
|
|
|
This module gathers information from an RMI endpoint running an RMI registry
|
2015-05-06 19:48:17 +00:00
|
|
|
interface. It enumerates the names bound in a registry and looks up each
|
2015-03-19 22:33:45 +00:00
|
|
|
remote reference.
|
|
|
|
},
|
|
|
|
'Author' => ['juan vazquez'],
|
2015-03-19 16:16:04 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2015-03-19 22:33:45 +00:00
|
|
|
'References' =>
|
2015-03-19 16:16:04 +00:00
|
|
|
[
|
2015-03-19 22:33:45 +00:00
|
|
|
['URL', 'http://docs.oracle.com/javase/8/docs/platform/rmi/spec/rmiTOC.html']
|
|
|
|
]
|
2015-03-19 16:16:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(1099)
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Sending RMI Header...")
|
2015-03-19 16:16:04 +00:00
|
|
|
connect
|
|
|
|
|
|
|
|
send_header
|
|
|
|
ack = recv_protocol_ack
|
|
|
|
if ack.nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to negotiate RMI protocol")
|
2015-03-19 16:16:04 +00:00
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Listing names in the Registry...")
|
2015-03-24 16:44:26 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
names = send_registry_list
|
|
|
|
rescue ::Rex::Proto::Rmi::Exception => e
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("List raised exception #{e.message}")
|
2015-03-24 16:44:26 +00:00
|
|
|
return
|
|
|
|
end
|
2015-03-19 16:16:04 +00:00
|
|
|
|
|
|
|
if names.nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to list names")
|
2015-03-19 16:16:04 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if names.empty?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Names not found in the Registry")
|
2015-03-19 16:16:04 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("#{names.length} names found in the Registry")
|
2015-03-19 16:16:04 +00:00
|
|
|
|
|
|
|
names.each do |name|
|
2015-03-19 22:33:45 +00:00
|
|
|
|
2015-03-24 16:44:26 +00:00
|
|
|
begin
|
|
|
|
remote_reference = send_registry_lookup(name: name)
|
|
|
|
rescue ::Rex::Proto::Rmi::Exception => e
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Lookup of #{name} raised exception #{e.message}")
|
2015-03-24 16:44:26 +00:00
|
|
|
next
|
|
|
|
end
|
2015-03-19 22:57:21 +00:00
|
|
|
|
|
|
|
if remote_reference.nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to lookup #{name}")
|
2015-03-19 22:33:45 +00:00
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("Name #{name} (#{remote_reference[:object]}) found on #{remote_reference[:address]}:#{remote_reference[:port]}")
|
2015-03-19 22:57:21 +00:00
|
|
|
report_service(
|
|
|
|
:host => remote_reference[:address],
|
|
|
|
:port => remote_reference[:port],
|
|
|
|
:name => 'java-rmi',
|
|
|
|
:info => "Name: #{name}, Stub: #{remote_reference[:object]}"
|
|
|
|
)
|
2015-03-19 16:16:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|