Path: blob/master/modules/auxiliary/admin/vmware/poweroff_vm.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report8include Msf::Exploit::Remote::VIMSoap910def initialize11super(12'Name' => 'VMWare Power Off Virtual Machine',13'Description' => %(14This module will log into the Web API of VMWare and try to power off15a specified Virtual Machine.),16'Author' => ['theLightCosine'],17'License' => MSF_LICENSE,18'DefaultOptions' => { 'SSL' => true }19)2021register_options(22[23Opt::RPORT(443),24OptString.new('USERNAME', [ true, 'The username to Authenticate with.', 'root' ]),25OptString.new('PASSWORD', [ true, 'The password to Authenticate with.', 'password' ]),26OptString.new('VM', [true, 'The VM to try to Power Off'])27]28)29end3031def run32if vim_do_login(datastore['USERNAME'], datastore['PASSWORD']) == :success33vm_ref = vim_find_vm_by_name(datastore['VM'])34case vm_ref35when String36return_state = vim_powerOFF_vm(vm_ref)37case return_state38when 'success'39print_good 'VM Powered Off Successfully'40when 'alreadyOFF'41print_status "The Server says that VM #{datastore['VM']} is already off."42else43print_error "The server returned an unexpected status #{return_state}"44end45when :noresponse46print_error 'The request timed out'47when :error48print_error @vim_soap_error49when nil50print_error "Could not locate VM #{datastore['VM']}"51end52else53print_error "Login Failure on #{datastore['RHOST']}"54return55end56end57end585960