Files
metasploit-gs/modules/auxiliary/scanner/vmware/vmware_enum_users.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

130 lines
4.7 KiB
Ruby
Raw Normal View History

2012-02-15 22:55:11 -06:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2012-02-15 22:55:11 -06:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2012-02-15 22:55:11 -06:00
include Msf::Exploit::Remote::VIMSoap
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
def initialize
super(
'Name' => 'VMWare Enumerate User Accounts',
'Description' => %Q{
2012-03-18 00:07:27 -05:00
This module will log into the Web API of VMWare and try to enumerate
all the user accounts. If the VMware instance is connected to one or
more domains, it will try to enumerate domain users as well.
},
2012-09-19 21:46:14 -05:00
'Author' => ['theLightCosine'],
2016-01-22 09:54:52 +01:00
'License' => MSF_LICENSE,
'DefaultOptions' => { 'SSL' => true }
2012-02-15 22:55:11 -06:00
)
register_options(
[
Opt::RPORT(443),
OptString.new('USERNAME', [ true, "The username to Authenticate with.", 'root' ]),
OptString.new('PASSWORD', [ true, "The password to Authenticate with.", 'password' ])
])
2012-02-15 22:55:11 -06:00
end
def run_host(ip)
if vim_do_login(datastore['USERNAME'], datastore['PASSWORD']) == :success
# Get local Users and Groups
2012-02-15 22:55:11 -06:00
user_list = vim_get_user_list(nil)
2016-08-10 13:30:09 -05:00
tmp_users = Rex::Text::Table.new(
2012-02-15 22:55:11 -06:00
'Header' => "Users for server #{ip}",
'Indent' => 1,
'Columns' => ['Name', 'Description']
)
2016-08-10 13:30:09 -05:00
tmp_groups = Rex::Text::Table.new(
2012-02-15 22:55:11 -06:00
'Header' => "Groups for server #{ip}",
'Indent' => 1,
'Columns' => ['Name', 'Description']
)
unless user_list.nil?
case user_list
when :noresponse
2017-07-21 07:40:08 -07:00
print_error "Received no response from #{ip}"
2012-02-15 22:55:11 -06:00
when :expired
print_error "The login session appears to have expired on #{ip}"
when :error
2017-07-21 07:40:08 -07:00
print_error "An error occurred while trying to enumerate the users for #{domain} on #{ip}"
2012-02-15 22:55:11 -06:00
else
user_list.each do |obj|
if obj['group'] == 'true'
tmp_groups << [obj['principal'], obj['fullName']]
else
tmp_users << [obj['principal'], obj['fullName']]
end
end
print_good tmp_groups.to_s
2012-02-16 02:19:33 -06:00
store_loot('host.vmware.groups', "text/plain", datastore['RHOST'], tmp_groups.to_csv , "#{datastore['RHOST']}_esx_groups.txt", "VMWare ESX User Groups")
2012-02-15 22:55:11 -06:00
print_good tmp_users.to_s
2012-02-16 02:19:33 -06:00
store_loot('host.vmware.users', "text/plain", datastore['RHOST'], tmp_users.to_csv , "#{datastore['RHOST']}_esx_users.txt", "VMWare ESX Users")
2012-02-15 22:55:11 -06:00
end
end
# Enumerate Domains the Server is connected to
2012-02-15 22:55:11 -06:00
esx_domains = vim_get_domains
case esx_domains
when :noresponse
2017-07-21 07:40:08 -07:00
print_error "Received no response from #{ip}"
2012-02-15 22:55:11 -06:00
when :expired
print_error "The login session appears to have expired on #{ip}"
when :error
2017-07-21 07:40:08 -07:00
print_error "An error occurred while trying to enumerate the domains on #{ip}"
2012-02-15 22:55:11 -06:00
else
# Enumerate Domain Users and Groups
2012-02-15 22:55:11 -06:00
esx_domains.each do |domain|
2016-08-10 13:30:09 -05:00
tmp_dusers = Rex::Text::Table.new(
2012-02-15 22:55:11 -06:00
'Header' => "Users for domain #{domain}",
'Indent' => 1,
'Columns' => ['Name', 'Description']
)
2016-08-10 13:30:09 -05:00
tmp_dgroups = Rex::Text::Table.new(
2012-02-15 22:55:11 -06:00
'Header' => "Groups for domain #{domain}",
'Indent' => 1,
'Columns' => ['Name', 'Description']
)
user_list = vim_get_user_list(domain)
case user_list
when nil
next
when :noresponse
2017-07-21 07:40:08 -07:00
print_error "Received no response from #{ip}"
2012-02-15 22:55:11 -06:00
when :expired
print_error "The login session appears to have expired on #{ip}"
when :error
2017-07-21 07:40:08 -07:00
print_error "An error occurred while trying to enumerate the users for #{domain} on #{ip}"
2012-02-15 22:55:11 -06:00
else
user_list.each do |obj|
if obj['group'] == 'true'
tmp_dgroups << [obj['principal'], obj['fullName']]
else
tmp_dusers << [obj['principal'], obj['fullName']]
end
end
print_good tmp_dgroups.to_s
f = store_loot('domain.groups', "text/plain", datastore['RHOST'], tmp_dgroups.to_csv , "#{domain}_esx_groups.txt", "VMWare ESX #{domain} Domain User Groups")
vprint_status("VMWare domain user groups stored in: #{f}")
2012-02-15 22:55:11 -06:00
print_good tmp_dusers.to_s
f = store_loot('domain.users', "text/plain", datastore['RHOST'], tmp_dgroups.to_csv , "#{domain}_esx_users.txt", "VMWare ESX #{domain} Domain Users")
vprint_status("VMWare users stored in: #{f}")
2012-02-15 22:55:11 -06:00
end
end
end
else
2017-07-21 07:40:08 -07:00
print_error "Login failure on #{ip}"
2012-02-15 22:55:11 -06:00
return
end
end
end