CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/vmware/poweron_vm.rb
Views: 11784
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::Remote::HttpClient
8
include Msf::Auxiliary::Report
9
include Msf::Exploit::Remote::VIMSoap
10
11
def initialize
12
super(
13
'Name' => 'VMWare Power On Virtual Machine',
14
'Description' => %Q{
15
This module will log into the Web API of VMWare and try to power on
16
a specified Virtual Machine.
17
},
18
'Author' => ['theLightCosine'],
19
'License' => MSF_LICENSE,
20
'DefaultOptions' => { 'SSL' => true }
21
)
22
23
register_options(
24
[
25
Opt::RPORT(443),
26
OptString.new('USERNAME', [ true, "The username to Authenticate with.", 'root' ]),
27
OptString.new('PASSWORD', [ true, "The password to Authenticate with.", 'password' ]),
28
OptString.new('VM', [true, "The VM to try to Power On"])
29
])
30
end
31
32
def run
33
34
if vim_do_login(datastore['USERNAME'], datastore['PASSWORD']) == :success
35
vm_ref = vim_find_vm_by_name(datastore['VM'])
36
case vm_ref
37
when String
38
return_state = vim_powerON_vm(vm_ref)
39
case return_state
40
when 'success'
41
print_good "VM Powered On Successfully"
42
when 'alreadyON'
43
print_status "The Server says that VM #{datastore['VM']} is already on."
44
else
45
print_error "The server returned an unexpected status #{return_state}"
46
end
47
when :noresponse
48
print_error "The request timed out"
49
when :error
50
print_error @vim_soap_error
51
when nil
52
print_error "Could not locate VM #{datastore['VM']}"
53
end
54
else
55
print_error "Login Failure on #{datastore['RHOST']}"
56
return
57
end
58
end
59
end
60
61