2012-02-15 08:27:25 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-02-15 08:27:25 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'rex/proto/ntlm/message'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::VIMSoap
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
2012-02-15 08:27:25 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'VMWare Enumerate Active Sessions',
|
|
|
|
'Description' => %Q{
|
|
|
|
This module will log into the Web API of VMWare and try to enumerate
|
|
|
|
all the login sessions.
|
|
|
|
},
|
|
|
|
'Author' => ['theLightCosine'],
|
2016-01-22 08:54:52 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'DefaultOptions' => { 'SSL' => true }
|
2013-08-30 21:28:54 +00:00
|
|
|
)
|
2012-02-15 08:27:25 +00:00
|
|
|
|
2013-08-30 21:28:54 +00: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' ])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-02-15 08:27:25 +00:00
|
|
|
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run_host(ip)
|
|
|
|
if vim_do_login(datastore['USERNAME'], datastore['PASSWORD']) == :success
|
|
|
|
vim_sessions = vim_get_session_list
|
|
|
|
case vim_sessions
|
|
|
|
when :noresponse
|
2017-07-21 14:40:08 +00:00
|
|
|
print_error "Connection error - Received no reply from #{ip}"
|
2013-08-30 21:28:54 +00:00
|
|
|
when :error
|
2017-07-21 14:40:08 +00:00
|
|
|
print_error "An error has occurred"
|
2013-08-30 21:28:54 +00:00
|
|
|
when :expired
|
2017-07-21 14:40:08 +00:00
|
|
|
print_error "The session is no longer authenticated"
|
2013-08-30 21:28:54 +00:00
|
|
|
else
|
|
|
|
output = ''
|
|
|
|
vim_sessions.each do |vsession|
|
|
|
|
tmp_line = "Name: #{vsession['fullName']} \n\t"
|
|
|
|
is_active = vim_session_is_active(vsession['key'],vsession['userName'])
|
|
|
|
if is_active == :error
|
|
|
|
tmp_line << "Active: N/A \n\t"
|
|
|
|
else
|
|
|
|
tmp_line << "Active: #{is_active} \n\t"
|
|
|
|
end
|
|
|
|
tmp_line << "Username: #{vsession['userName']}\n\t"
|
|
|
|
tmp_line << "Session Key: #{vsession['key']}\n\t"
|
|
|
|
tmp_line << "Locale: #{vsession['locale']}\n\t"
|
|
|
|
tmp_line << "Login Time: #{vsession['loginTime']}\n\t"
|
|
|
|
tmp_line << "Last Active Time: #{vsession['lastActiveTime']}\n\n"
|
|
|
|
print_good tmp_line
|
|
|
|
output << tmp_line
|
|
|
|
end
|
|
|
|
unless output.empty?
|
|
|
|
f = store_loot("host.vmware.sessions", "text/plain", datastore['RHOST'], output, "vmware_sessions.txt", "Login Sessions for VMware")
|
2017-07-19 12:02:49 +00:00
|
|
|
vprint_good("Login sessions stored in: #{f}")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2017-07-21 14:40:08 +00:00
|
|
|
print_error "Login failure on #{ip}"
|
2013-08-30 21:28:54 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2012-02-15 08:27:25 +00:00
|
|
|
end
|