Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/vmware/poweroff_vm.rb
Views: 11784
##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' => %Q{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])28end2930def run31if vim_do_login(datastore['USERNAME'], datastore['PASSWORD']) == :success32vm_ref = vim_find_vm_by_name(datastore['VM'])33case vm_ref34when String35return_state = vim_powerOFF_vm(vm_ref)36case return_state37when 'success'38print_good "VM Powered Off Successfully"39when 'alreadyOFF'40print_status "The Server says that VM #{datastore['VM']} is already off."41else42print_error "The server returned an unexpected status #{return_state}"43end44when :noresponse45print_error "The request timed out"46when :error47print_error @vim_soap_error48when nil49print_error "Could not locate VM #{datastore['VM']}"50end51else52print_error "Login Failure on #{datastore['RHOST']}"53return54end55end56end575859