Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/solaris/gather/checkvm.rb
19516 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
include Msf::Post::File
8
include Msf::Post::Solaris::Priv
9
10
def initialize(info = {})
11
super(
12
update_info(
13
info,
14
'Name' => 'Solaris Gather Virtual Environment Detection',
15
'Description' => %q{
16
This module attempts to determine whether the system is running
17
inside of a virtual environment and if so, which one. This
18
module supports detection of Solaris Zone, VMWare, VirtualBox, Xen,
19
and QEMU/KVM.
20
},
21
'License' => MSF_LICENSE,
22
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
23
'Platform' => [ 'solaris' ],
24
'SessionTypes' => [ 'shell' ],
25
'Notes' => {
26
'Stability' => [CRASH_SAFE],
27
'SideEffects' => [],
28
'Reliability' => []
29
}
30
)
31
)
32
end
33
34
# Run Method for when run command is issued
35
def run
36
print_status('Gathering System info ....')
37
vm = nil
38
kernel_type = cmd_exec('uname -v')
39
40
if kernel_type =~ /Generic_Virtual/i
41
vm = 'Solaris Zone'
42
end
43
44
if !vm
45
46
prt_diag = cmd_exec('/usr/sbin/prtdiag -v').gsub("\n", ' ')
47
48
case prt_diag
49
when /virtualbox/i
50
vm = 'VirtualBox'
51
when /vmware/i
52
vm = 'VMware'
53
when /xen/i
54
vm = 'Xen'
55
when /qemu/i
56
vm = 'Qemu/KVM'
57
end
58
end
59
60
if vm
61
print_good("This appears to be a #{vm} Virtual Machine")
62
else
63
print_status('This appears to be a Physical Machine')
64
end
65
end
66
67
end
68
69