2012-02-15 02:44:11 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-02-15 02:44:11 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Exploit::Remote::VIMSoap
|
2012-02-15 02:44:11 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'VMWare Power On Virtual Machine',
|
|
|
|
'Description' => %Q{
|
|
|
|
This module will log into the Web API of VMWare and try to power on
|
|
|
|
a specified Virtual Machine.
|
|
|
|
},
|
|
|
|
'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 02:44:11 +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' ]),
|
|
|
|
OptString.new('VM', [true, "The VM to try to Power On"])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-02-15 02:44:11 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run
|
2012-02-15 02:44:11 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if vim_do_login(datastore['USERNAME'], datastore['PASSWORD']) == :success
|
|
|
|
vm_ref = vim_find_vm_by_name(datastore['VM'])
|
|
|
|
case vm_ref
|
|
|
|
when String
|
|
|
|
return_state = vim_powerON_vm(vm_ref)
|
|
|
|
case return_state
|
|
|
|
when 'success'
|
|
|
|
print_good "VM Powered On Successfully"
|
|
|
|
when 'alreadyON'
|
|
|
|
print_status "The Server says that VM #{datastore['VM']} is already on."
|
|
|
|
else
|
|
|
|
print_error "The server returned an unexpected status #{return_state}"
|
|
|
|
end
|
|
|
|
when :noresponse
|
|
|
|
print_error "The request timed out"
|
|
|
|
when :error
|
|
|
|
print_error @vim_soap_error
|
|
|
|
when nil
|
|
|
|
print_error "Could not locate VM #{datastore['VM']}"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print_error "Login Failure on #{datastore['RHOST']}"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2012-02-15 02:44:11 +00:00
|
|
|
end
|