Path: blob/master/modules/post/solaris/gather/checkvm.rb
19516 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Solaris::Priv89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Solaris Gather Virtual Environment Detection',14'Description' => %q{15This module attempts to determine whether the system is running16inside of a virtual environment and if so, which one. This17module supports detection of Solaris Zone, VMWare, VirtualBox, Xen,18and QEMU/KVM.19},20'License' => MSF_LICENSE,21'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],22'Platform' => [ 'solaris' ],23'SessionTypes' => [ 'shell' ],24'Notes' => {25'Stability' => [CRASH_SAFE],26'SideEffects' => [],27'Reliability' => []28}29)30)31end3233# Run Method for when run command is issued34def run35print_status('Gathering System info ....')36vm = nil37kernel_type = cmd_exec('uname -v')3839if kernel_type =~ /Generic_Virtual/i40vm = 'Solaris Zone'41end4243if !vm4445prt_diag = cmd_exec('/usr/sbin/prtdiag -v').gsub("\n", ' ')4647case prt_diag48when /virtualbox/i49vm = 'VirtualBox'50when /vmware/i51vm = 'VMware'52when /xen/i53vm = 'Xen'54when /qemu/i55vm = 'Qemu/KVM'56end57end5859if vm60print_good("This appears to be a #{vm} Virtual Machine")61else62print_status('This appears to be a Physical Machine')63end64end6566end676869