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.

134 lines
4.8 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' => %(
This module will log into the Web API of VMware and try to enumerate
2012-03-18 00:07:27 -05:00
all the user accounts. If the VMware instance is connected to one or
more domains, it will try to enumerate domain users as well.
),
'Author' => ['theLightCosine'],
'License' => MSF_LICENSE,
'DefaultOptions' => { 'SSL' => true },
'Notes' => {
'Stability' => [CRASH_SAFE],
'SideEffects' => [],
'Reliability' => []
}
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(
'Header' => "Users for server #{ip}",
'Indent' => 1,
2012-02-15 22:55:11 -06:00
'Columns' => ['Name', 'Description']
)
2016-08-10 13:30:09 -05:00
tmp_groups = Rex::Text::Table.new(
'Header' => "Groups for server #{ip}",
'Indent' => 1,
2012-02-15 22:55:11 -06:00
'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']]
2012-02-15 22:55:11 -06:00
end
end
print_good tmp_groups.to_s
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
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(
'Header' => "Users for domain #{domain}",
'Indent' => 1,
2012-02-15 22:55:11 -06:00
'Columns' => ['Name', 'Description']
)
2016-08-10 13:30:09 -05:00
tmp_dgroups = Rex::Text::Table.new(
'Header' => "Groups for domain #{domain}",
'Indent' => 1,
2012-02-15 22:55:11 -06:00
'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']]
2012-02-15 22:55:11 -06:00
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