2012-02-01 18:05:20 +00:00
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
2012-02-21 01:40:50 +00:00
# web site for more information on licensing and terms of use.
# http://metasploit.com/
2012-02-01 18:05:20 +00:00
##
require 'msf/core'
class Metasploit3 < Msf :: Auxiliary
include Msf :: Exploit :: Remote :: HttpClient
include Msf :: Auxiliary :: Report
include Msf :: Exploit :: Remote :: VIMSoap
include Msf :: Auxiliary :: Scanner
def initialize
super (
'Name' = > 'VMWare Enumerate Virtual Machines' ,
'Description' = > %Q{
2012-03-18 05:07:27 +00:00
This module attempts to discover virtual machines on any VMWare instance
running the web interface . This would include ESX / ESXi and VMWare Server .
} ,
2012-02-01 18:05:20 +00:00
'Author' = > [ 'TheLightCosine <thelightcosine[at]metasploit.com>' ] ,
'License' = > MSF_LICENSE
)
register_options (
[
Opt :: RPORT ( 443 ) ,
OptString . new ( 'USERNAME' , [ true , " The username to Authenticate with. " , 'root' ] ) ,
2012-02-11 09:51:18 +00:00
OptString . new ( 'PASSWORD' , [ true , " The password to Authenticate with. " , 'password' ] ) ,
OptBool . new ( 'SCREENSHOT' , [ true , " Wheter or not to try to take a screenshot " , true ] )
2012-02-01 18:05:20 +00:00
] , self . class )
2012-03-18 05:07:27 +00:00
2012-03-16 00:06:48 +00:00
register_advanced_options ( [ OptBool . new ( 'SSL' , [ false , 'Negotiate SSL for outgoing connections' , true ] ) , ] )
2012-02-01 18:05:20 +00:00
end
def run_host ( ip )
if vim_do_login ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] ) == :success
virtual_machines = vim_get_vms
virtual_machines . each do | vm |
print_good YAML . dump ( vm )
report_note (
:host = > rhost ,
:type = > " vmware.esx.vm " ,
:data = > vm ,
:port = > rport ,
:proto = > 'tcp' ,
:update = > :unique_data
)
2012-02-13 18:07:28 +00:00
next unless datastore [ 'SCREENSHOT' ] and vm [ 'runtime' ] [ 'powerState' ] == 'poweredOn'
print_status " Attempting to take screenshot of #{ vm [ 'name' ] } .... "
screenshot = vim_take_screenshot ( vm , datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] )
case screenshot
when :error
print_error " Screenshot failed "
next
when :expired
vim_do_login ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] )
retry_result = vim_take_screenshot ( vm , datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] )
if retry_result == :error or retry_result == :expired
print_error " Screenshot failed "
else
2012-02-16 08:19:33 +00:00
ss_path = store_loot ( " host.vmware.screenshot " , " image/png " , datastore [ 'RHOST' ] , retry_result , " #{ vm [ 'name' ] } _screenshot.png " , " Screenshot of VM #{ vm [ 'name' ] } " )
2012-02-13 18:07:28 +00:00
print_good " Screenshot Saved to #{ ss_path } "
end
else
2012-02-16 08:19:33 +00:00
ss_path = store_loot ( " host.vmware.screenshot " , " image/png " , datastore [ 'RHOST' ] , screenshot , " screenshot.png " , " Screenshot of VM #{ vm [ 'name' ] } " )
2012-02-13 18:07:28 +00:00
print_good " Screenshot Saved to #{ ss_path } "
end
2012-02-01 18:05:20 +00:00
end
2012-02-16 08:19:33 +00:00
store_loot ( 'host.vmware.vms' , " text/plain " , datastore [ 'RHOST' ] , YAML . dump ( virtual_machines ) , " #{ datastore [ 'RHOST' ] } _esx_vms.txt " , " VMWare ESX Virtual Machines " )
2012-02-01 18:05:20 +00:00
else
print_error " Login Failure on #{ ip } "
return
end
end
end