Linux Gather Virtual Environment Detection - Metasploit
This page contains detailed information about how to use the post/linux/gather/checkvm metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Linux Gather Virtual Environment Detection
Module: post/linux/gather/checkvm
Source code: modules/post/linux/gather/checkvm.rb
Disclosure date: -
Last modification time: 2021-05-23 13:16:22 +0000
Supported architecture(s): -
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module attempts to determine whether the system is running inside of a virtual environment and if so, which one. This module supports detection of Hyper-V, VMWare, VirtualBox, Xen, and QEMU/KVM.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/linux/gather/checkvm
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/linux/gather/checkvm
msf post(checkvm) > show options
... show and set options ...
msf post(checkvm) > set SESSION session-id
msf post(checkvm) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/linux/gather/checkvm")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Locations Checked
There are many locations that are checked for having evidence of being a virtual machine. The follow is a list of them:
- (with root access)
/usr/sbin/dmidecode
/sbin/lsmod
/proc/scsi/scsi
cat /proc/ide/hd*/model
lspci
dmesg
/sys/class/dmi/id/product_name
Verification Steps
- Start msfconsole
- Get a session via exploit of your choice
- Do:
use post/linux/gather/checkvm
- Do:
set session <session>
- Do:
run
- You should get feedback if a virtual machine environment was detected
Options
SESSION
Which session to use, which can be viewed with sessions -l
Scenarios
Typical run against Kali with only one user (root), using ssh_login for initial shell
msf > use auxiliary/scanner/ssh/ssh_login
msf auxiliary(ssh_login) > set username root
username => root
msf auxiliary(ssh_login) > set password "test"
password => example_password
msf auxiliary(ssh_login) > set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf auxiliary(ssh_login) > exploit
[*] SSH - Starting bruteforce
[-] SSH - Could not connect: The connection was refused by the remote host (127.0.0.1:22).
[!] No active DB -- Credential data will not be saved!
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(ssh_login) > exploit
[*] SSH - Starting bruteforce
[+] SSH - Success: 'root:test' 'uid=0(root) gid=0(root) groups=0(root) Linux k 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux '
[!] No active DB -- Credential data will not be saved!
[*] Command shell session 1 opened (127.0.0.1:41521 -> 127.0.0.1:22) at 2016-09-14 00:14:36 -0400
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(ssh_login) > use post/linux/gather/checkvm
msf post(checkvm) > set session 1
session => 1
msf post(checkvm) > run
[*] Gathering System info ....
[+] This appears to be a 'Xen' virtual machine
[*] Post module execution completed
A non-virtual machine will have the following output
msf > use auxiliary/scanner/ssh/ssh_login
msf auxiliary(ssh_login) > set username root
username => root
msf auxiliary(ssh_login) > set password "test"
password => example_password
msf auxiliary(ssh_login) > set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf auxiliary(ssh_login) > exploit
[] SSH - Starting bruteforce [-] SSH - Could not connect: The connection was refused by the remote host (127.0.0.1:22). [!] No active DB -- Credential data will not be saved! [] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed msf auxiliary(ssh_login) > exploit
[] SSH - Starting bruteforce [+] SSH - Success: 'root:test' 'uid=0(root) gid=0(root) groups=0(root) Linux k 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux ' [!] No active DB -- Credential data will not be saved! [] Command shell session 1 opened (127.0.0.1:41521 -> 127.0.0.1:22) at 2016-09-14 00:15:36 -0400 [] Scanned 1 of 1 hosts (100% complete) [] Auxiliary module execution completed msf auxiliary(ssh_login) > use post/linux/gather/checkvm msf post(checkvm) > set session 1 session => 1 msf post(checkvm) > run
[] Gathering System info ....
[] This does not appear to be a virtual machine
[*] Post module execution completed
And a VMwave virtual machine
msf > use auxiliary/scanner/ssh/ssh_login
msf auxiliary(ssh_login) > set username root
username => root
msf auxiliary(ssh_login) > set password "test"
password => example_password
msf auxiliary(ssh_login) > set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf auxiliary(ssh_login) > exploit
[] SSH - Starting bruteforce [-] SSH - Could not connect: The connection was refused by the remote host (127.0.0.1:22). [!] No active DB -- Credential data will not be saved! [] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed msf auxiliary(ssh_login) > exploit
[] SSH - Starting bruteforce [+] SSH - Success: 'root:test' 'uid=0(root) gid=0(root) groups=0(root) Linux k 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux ' [!] No active DB -- Credential data will not be saved! [] Command shell session 1 opened (127.0.0.1:41521 -> 127.0.0.1:22) at 2016-09-14 00:18:36 -0400 [] Scanned 1 of 1 hosts (100% complete) [] Auxiliary module execution completed msf auxiliary(ssh_login) > use post/linux/gather/checkvm msf post(checkvm) > set session 1 session => 1 msf post(checkvm) > run
[] Gathering System info ....
[+] This appears to be a 'VMware' virtual machine
[] Post module execution completed
Go back to menu.
Msfconsole Usage
Here is how the linux/gather/checkvm post exploitation module looks in the msfconsole:
msf6 > use post/linux/gather/checkvm
msf6 post(linux/gather/checkvm) > show info
Name: Linux Gather Virtual Environment Detection
Module: post/linux/gather/checkvm
Platform: Linux
Arch:
Rank: Normal
Provided by:
Carlos Perez <[email protected]>
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Description:
This module attempts to determine whether the system is running
inside of a virtual environment and if so, which one. This module
supports detection of Hyper-V, VMWare, VirtualBox, Xen, and
QEMU/KVM.
Module Options
This is a complete list of options available in the linux/gather/checkvm post exploitation module:
msf6 post(linux/gather/checkvm) > show options
Module options (post/linux/gather/checkvm):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the linux/gather/checkvm post exploitation module:
msf6 post(linux/gather/checkvm) > show advanced
Module advanced options (post/linux/gather/checkvm):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the linux/gather/checkvm module can do:
msf6 post(linux/gather/checkvm) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the linux/gather/checkvm post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(linux/gather/checkvm) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
This does not appear to be a virtual machine
Here is a relevant code snippet related to the "This does not appear to be a virtual machine" error message:
163: end
164:
165: if vm
166: print_good("This appears to be a '#{vm}' virtual machine")
167: report_virtualization(vm)
168: else
169: print_status('This does not appear to be a virtual machine')
170: end
171:
172: end
173: end
Go back to menu.
Related Pull Requests
- #15236 Merged Pull Request: Update checkvm.rb
- #15065 Merged Pull Request: Fix linux checkvm bug
- #8799 Merged Pull Request: Add module to detect Docker, LXC, and systemd-nspawn containers
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #2525 Merged Pull Request: Change module boilerplate
- #2304 Merged Pull Request: Fix load order in posts, hopefully forever
- #1241 Merged Pull Request: Removed all $Id$ and $Revision$ occurences
Go back to menu.
See Also
Check also the following modules related to this module:
- post/linux/gather/checkcontainer
- post/linux/gather/ecryptfs_creds
- post/linux/gather/enum_commands
- post/linux/gather/enum_configs
- post/linux/gather/enum_containers
- post/linux/gather/enum_nagios_xi
- post/linux/gather/enum_network
- post/linux/gather/enum_protections
- post/linux/gather/enum_psk
- post/linux/gather/enum_system
- post/linux/gather/enum_users_history
- post/linux/gather/gnome_commander_creds
- post/linux/gather/gnome_keyring_dump
- post/linux/gather/haserl_read
- post/linux/gather/hashdump
- post/linux/gather/manageengine_password_manager_creds
- post/linux/gather/mimipenguin
- post/linux/gather/mount_cifs_creds
- post/linux/gather/openvpn_credentials
- post/linux/gather/phpmyadmin_credsteal
- post/linux/gather/pptpd_chap_secrets
- post/linux/gather/tor_hiddenservices
- post/linux/gather/vcenter_secrets_dump
Authors
- Carlos Perez <carlos_perez[at]darkoperator.com>
Version
This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.