CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/solaris/gather/checkvm.rb
Views: 1904
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
)
26
)
27
end
28
29
# Run Method for when run command is issued
30
def run
31
print_status('Gathering System info ....')
32
vm = nil
33
kernel_type = cmd_exec('uname -v')
34
35
if kernel_type =~ /Generic_Virtual/i
36
vm = 'Solaris Zone'
37
end
38
39
if !vm
40
41
prt_diag = cmd_exec('/usr/sbin/prtdiag -v').gsub("\n", ' ')
42
43
case prt_diag
44
when /virtualbox/i
45
vm = 'VirtualBox'
46
when /vmware/i
47
vm = 'VMware'
48
when /xen/i
49
vm = 'Xen'
50
when /qemu/i
51
vm = 'Qemu/KVM'
52
end
53
end
54
55
if vm
56
print_good("This appears to be a #{vm} Virtual Machine")
57
else
58
print_status('This appears to be a Physical Machine')
59
end
60
end
61
62
end
63
64