Skip to content

Commit f216841

Browse files
committed
Update enum_vbox
1 parent c20d2a1 commit f216841

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

modules/post/multi/gather/enum_vbox.rb

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def initialize(info={})
1616
super( update_info(info,
1717
'Name' => 'Multi Gather VirtualBox VM Enumeration',
1818
'Description' => %q{
19-
This module will attempt to enumerate any VirtualBox VMs on the target machine.
20-
Due to the nature of VirtualBox, this module can only enumerate VMs registered
21-
for the current user, thereforce, this module needs to be invoked from a user context.
22-
},
19+
This module will attempt to enumerate any VirtualBox VMs on the target machine.
20+
Due to the nature of VirtualBox, this module can only enumerate VMs registered
21+
for the current user, thereforce, this module needs to be invoked from a user context.
22+
},
2323
'License' => MSF_LICENSE,
2424
'Author' => ['theLightCosine'],
2525
'Platform' => %w{ bsd linux osx unix win },
@@ -29,27 +29,37 @@ def initialize(info={})
2929

3030
def run
3131
if session.platform =~ /win/
32-
res = session.shell_command_token_win32('"c:\Program Files\Oracle\VirtualBox\vboxmanage" list -l vms') || ''
33-
if res.include? "The system cannot find the path specified"
34-
print_error "VirtualBox does not appear to be installed on this machine"
35-
return nil
36-
elsif res == "\n"
37-
print_status "VirtualBox is installed but this user has no VMs registered. Try another user."
38-
return nil
32+
if session.type == 'meterpreter'
33+
begin
34+
res = cmd_exec('c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage', 'list -l vms')
35+
rescue ::Rex::Post::Meterpreter::RequestError
36+
print_error('VirtualBox does not appear to be installed on this machine')
37+
return nil
38+
end
39+
40+
if res.empty?
41+
print_status('VirtualBox is installed but this user has no VMs registered. Try another user.')
42+
return nil
43+
end
44+
else
45+
res = cmd_exec('"c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage" list -l vms')
46+
if res.empty?
47+
print_error('VirtualBox isn\'t installed or this user has no VMs registered')
48+
return nil
49+
end
3950
end
4051
elsif session.platform =~ /unix|linux|bsd|osx/
41-
res = session.shell_command('vboxmanage list -l vms')
42-
unless res.start_with? "Sun VirtualBox"
43-
print_error "VirtualBox does not appear to be installed on this machine"
44-
return nil
45-
end
46-
unless res.include? "Name:"
47-
print_status "VirtualBox is installed but this user has no VMs registered. Try another user."
52+
res = cmd_exec('vboxmanage list -l vms')
53+
54+
unless res.start_with?('Sun VirtualBox') || res.include?('Name:')
55+
print_error('VirtualBox isn\'t installed or this user has no VMs registered')
4856
return nil
4957
end
5058
end
51-
print_good res
52-
store_loot('virtualbox_vms', "text/plain", session, res, "virtualbox_vms.txt", "Virtualbox Virtual Machines")
59+
60+
vprint_status(res)
61+
store_path = store_loot('virtualbox_vms', "text/plain", session, res, "virtualbox_vms.txt", "Virtualbox Virtual Machines")
62+
print_good("#{peer} - File successfully retrieved and saved on #{store_path}")
5363
end
5464

5565

0 commit comments

Comments
 (0)