Virtual Machine Detection

December 27, 2024 · View on GitHub

ID B0009
Objective(s) Anti-Behavioral Analysis
Related ATT&CK Techniques Virtualization/Sandbox Evasion (T1497, T1633)
Anti-Analysis Type Detection
Version 2.4
Created 1 August 2019
Last Modified 27 December 2024

Virtual Machine Detection

Malware checks whether it is being executed inside a virtual environment. In performing reconnaissance of its environment, the malware will check on a variety of user or system based artifacts. Examples include:

  • monitoring for user action as reflected by scrolling
  • verifying system characteristics through Windows Management Interface (WMI) queries, e.g., for MAC address
  • observing whether tool artifacts represented by strings or processes exist, e.g., VirtualBox.exe or joeboxserver.exe
  • checking specific registry keys or values [1]

Upon detection of the virtual machine, conditional execution will change the malware’s behavior. For example, execution may terminate, or activity may appear benign, e.g., connecting to a benign domain.

The related Virtualization/Sandbox Evasion (T1497, T1633) ATT&CK techniques were defined subsequent to this MBC behavior.

Methods

NameIDDescription
Check File and Directory ArtifactsB0009.001Virtual machines create files on the file system (e.g., VMware creates files in the installation directory C:\Program Files\VMware\VMware Tools). Malware can check the different folders to find virtual machine artifacts (e.g., Virtualbox has the artifact VBoxMouse.sys). [2]
Check Memory ArtifactsB0009.002VMware leaves many artifacts in memory. Some are critical processor structures, which, because they are either moved or changed on a virtual machine, leave recognizable footprints. Malware can search through physical memory for the strings VMware, commonly used to detect memory artifacts. [2]
Check Named System ObjectsB0009.003Virtual machines often include specific named system objects by default, such as Windows device drivers, which can be detected by testing for specific strings, whether found in the Windows registry or other places.
Check ProcessesB0009.004The VMware Tools use processes like VMwareServices.exe or VMwareTray.exe, to perform actions on the virtual environment. Malware can list the processes and searches for the VMware string. Processes related to Virtualbox can be detected by the malware by querying the process list. [2] This method is related to Unprotect technique U1334.
Check Registry KeysB0009.005Virtual machines register artifacts in the registry, which can be detected by malware. For example, a search for "VMware" or "VBOX" in the registry might reveal keys that include information about a virtual hard drive, adapters, running services, or a virtual mouse. [2] Example registry key value artifacts include "HARDWARE\Description\System (SystemBiosVersion) (VBOX)" and "SYSTEM\ControlSet001\Control\SystemInformation (SystemManufacturer) (VMWARE)"; example registry key artifacts include "SOFTWARE\VMware, Inc.\VMware Tools (VMWARE)" and "SOFTWARE\Oracle\VirtualBox Guest Additions (VBOX)". [5]
Check Running ServicesB0009.006VMwareService.exe runs the VMware Tools Service as a child of services.exe. It can be identified by listing services. [2]
Check SoftwareB0009.007Malware may check software version; for example, to determine whether the software is relatively current.
Check Virtual DevicesB0009.008The presence of virtual devices can indicate a virtualized environment (e.g., "\.\VBoxTrayIPC"). [5]
Check WindowsB0009.009Malware may check windows for VM-related characteristics.
Check Windows - Title barsB0009.022Malware may check windows for VM-related characteristics. May inject malicious code to svchost.exe to check all open window title bar text to a list of strings indicating virtualized environment.
Check Windows - Unique windowsB0009.021Malware may check windows for VM-related characteristics. May check for the presence of known windows from analysis tools running in a VM.
Check Windows - Window sizeB0009.020Malware may check windows for VM-related characteristics. Tiny window size may indicate a VM.
Check Username or HostnameB0009.039Malware checks for hostnames or session usernames that indicate the use of a virtual machine.
Guest Process TestingB0009.010Virtual machines offer guest additions that can be installed to add functionality such as clipboard sharing. Detecting the process responsible for these tasks, via its name or other methods, is a technique employed by malware for detecting whether it is being executed in a virtual machine.
HTML5 Performance Object CheckB0009.011In three browser families, it is possible to extract the frequency of the Windows performance counter frequency, using standard HTML and Javascript. This value can then be used to detect whether the code is being executed in a virtual machine, by detecting two specific frequencies commonly used in virtual but not physical machines.
Human User CheckB0009.012Detects whether there is any "user" activity on the machine, such as the movement of the mouse cursor, non-default wallpaper, or recently opened Office files. Directories or file might be counted. If there is no human activity, the machine is suspected to be a virtualized machine and/or sandbox. Other items used to detect a user: mouse clicks (single/double), DialogBox, scrolling, color of background pixel, change in foreground window [5]. This method is very similar to ATT&CK's Virtualization/Sandbox Evasion: User Activity Based Checks sub-technique.
Instruction TestingB0009.029The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2]
Instruction Testing - CPUIDB0009.034The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] Checking the CPU ID found within the registry can provide information to system type. This method is related to Unprotect technique U1324.
Instruction Testing - INB0009.035The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] This method is related to Unprotect technique U1323.
Instruction Testing - RDTSCB0009.036The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2]
Instruction Testing - SGDT/SLDT (no pill)B0009.031The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] The No Pill technique relies on the fact that the LDT structure is assigned to a processor not an Operating System. The LDT location on a host machine will be zero and on a virtual machine will be non-zero. This method is related to Unprotect technique U1327.
Instruction Testing - SIDT (red pill)B0009.030The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] Red Pill is an anti-VM technique that executes the SIDT instruction to grab the value of the IDTR register. The virtual machine monitor must relocate the guest's IDTR to avoid conflict with the host's IDTR. Since the virtual machine monitor is not notified when the virtual machine runs the SIDT instruction, the IDTR for the virtual machine is returned. This method is related to Unprotect technique U1328.
Instruction Testing - SMSWB0009.032The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] This method is related to Unprotect technique U1326.
Instruction Testing - STRB0009.033The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] This method is related to Unprotect technique U1325.
Instruction Testing - VMCPUIDB0009.037The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] This method is related to Unprotect technique U1322.
Instruction Testing - VPCEXTB0009.038The execution of certain x86 instructions will result in different values when executed inside of a VM instead of on bare metal. Accordingly, these can be used to detect the execution of the malware in a VM. [2] This method is related to Unprotect technique U1321.
Modern Specs CheckB0009.013Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment.
Modern Specs Check - Drive sizeB0009.015Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment. Most modern machines have at least 80 GB disks. May use DeviceloControl (IOCTL_DISK_GET_LENGTH_INFO) or GetDiskFreeSpaceEx (TotalNumberOfBytes) [5]. This method is related to Unprotect technique U1312.
Modern Specs Check - Keyboard layoutB0009.019Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment. Check keyboard layout.
Modern Specs Check - PrinterB0009.017Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment. Checks whether there is a potential connected printer or default Windows printers; if not a virtual environment is suspected. This method is related to Unprotect technique U1309.
Modern Specs Check - Processor countB0009.018Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment. Checks number of processors; single CPU machines are suspect. This method is related to Unprotect technique U1340.
Modern Specs Check - Total physical memoryB0009.014Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment. Most modern machines have at leave 4 GB of memory. (GlobalMemoryStatusEx) [5]. This method is related to Unprotect technique U1313.
Modern Specs Check - USB driveB0009.016Different aspects of the hardware are inspected to determine whether the machine has modern characteristics. A machine with substandard specifications indicates a virtual environment. Checks whether there is a potential USB drive; if not a virtual environment is suspected. This method is related to Unprotect technique U1310.
Unique Hardware/Firmware CheckB0009.023Malware may check for hardware characteristics unique to being virtualized, allowing the malware to detect the virtual environment.
Unique Hardware/Firmware Check - BIOSB0009.024Malware may check for hardware characteristics unique to being virtualized, allowing the malware to detect the virtual environment. Characteristics of the BIOS, such as version, can indicate virtualization.
Unique Hardware/Firmware Check - CPU LocationB0009.027Malware may check for hardware characteristics unique to being virtualized, allowing the malware to detect the virtual environment. When an Operating System is virtualized, the CPU is relocated. [2]
Unique Hardware/Firmware Check - CPU NameB0009.026Malware may check for hardware characteristics unique to being virtualized, allowing the malware to detect the virtual environment. Checks the CPU name to determine virtualization.
Unique Hardware/Firmware Check - I/O Communication PortB0009.025Malware may check for hardware characteristics unique to being virtualized, allowing the malware to detect the virtual environment. VMware uses virtual I/O ports for communication between the virtual machine and the host operating system to support functionality like copy and paste between the two systems. The port can be queried and compared with a magic number VMXh to identify the use of VMware. This method is related to Unprotect technique U1336.
Unique Hardware/Firmware Check - MAC AddressB0009.028Malware may check for hardware characteristics unique to being virtualized, allowing the malware to detect the virtual environment. VMware uses specific virtual MAC address that can be detected. The usual MAC address used started with the following numbers: "00:0C:29", "00:1C:14", "00:50:56", "00:05:69". Virtualbox uses specific virtual MAC address that can be detected by Malware. The usual MAC address used started with the following numbers: 08:00:27. [2] This method is related to Unprotect technique U1335.

Use in Malware

NameDateMethodDescription
GravityRAT2018--GravityRAT checks system temperature by recording thermal readings for detecting VMs. Heat levels indicate whether the system is a VM. [3]
GravityRAT2018B0009.018GravityRAT determines the machine is a VM if the core count is 1. [3]
GravityRAT2018B0009.023GravityRAT checks if the manufacturer field in the Win32_Computer entry (in WMI) contains "Virtual," "Vmware," or "Virtualbox." [3]
GravityRAT2018B0009.024GravityRAT creates a WMI request to identify the BIOS version. [13]
GravityRAT2018B0009.028GravityRAT checks if the MAC address starts with a well-known hexadecimal number used by various VM developers. [3]
WebCobra2018B0009.022WebCobra injects malicious code in to svchost.exe and uses an infinite loop to check all open windows and to compare each window’s title bar text with a set of strings to determine whether it is running in a VM. [4]
Redhip2011--Redhip detects VMWare, Virtual PC, and Virtual Box. It also detects VM environments in general by considering time lapses. [6]
Emotet2018B0009.010Emotet checks for various processes that are associated with various virtual machines by comparing hash values of the process names with the hash values of the list of running process names. [7]
Vobfus2016--Vobfus checks for the presence of virtualization software by querying the system registry. [8]
Matanbuchus2021B0009.003Malware checks if it is running in a sandbox. If it is, the malware exits. [9] [10]
Ursnif2016B0009.004The malware checks if there are virtual machine processes running (Vbox, vmware, etc). [11]
Dark Comet2008B0009.012The malware checks for an unmoving mouse cursor. [12]

Detection

Tool: capaMappingAPIs
check for sandbox and av modulesVirtual Machine Detection (B0009)GetModuleHandle
check for Windows sandbox via genuine stateVirtual Machine Detection (B0009)SLIsGenuineLocal, UuidFromString
reference anti-VM strings targeting ParallelsVirtual Machine Detection (B0009)--
check for unmoving mouse cursorVirtual Machine Detection::Human User Check (B0009.012)--
reference anti-VM strings targeting VirtualPCVirtual Machine Detection (B0009)--
reference anti-VM strings targeting VMWareVirtual Machine Detection (B0009)--
check for foreground window switchVirtual Machine Detection::Human User Check (B0009.012)Sleep
detect VM via disk hardware WMI queriesVirtual Machine Detection::Unique Hardware/Firmware Check (B0009.023)--
reference anti-VM strings targeting QemuVirtual Machine Detection (B0009)--
reference anti-VM strings targeting XenVirtual Machine Detection (B0009)--
check for sandbox username or hostnameVirtual Machine Detection (B0009)--
check for Windows sandbox via process nameVirtual Machine Detection (B0009)--
check for Windows sandbox via dns suffixVirtual Machine Detection (B0009)GetAdaptersAddresses
check for Windows sandbox via deviceVirtual Machine Detection (B0009)--
reference anti-VM strings targeting VirtualBoxVirtual Machine Detection (B0009)--
check for Windows sandbox via registryVirtual Machine Detection (B0009)RegOpenKeyEx, RegEnumValue
reference anti-VM stringsVirtual Machine Detection (B0009)--
Tool: CAPEMappingAPIs
antivm_generic_diskVirtual Machine Detection (B0009)DeviceIoControl, NtClose, NtCreateFile, NtDuplicateObject, NtOpenFile, NtDeviceIoControlFile
antivm_generic_diskVirtual Machine Detection::Modern Specs Check - Drive size (B0009.015)DeviceIoControl, NtClose, NtCreateFile, NtDuplicateObject, NtOpenFile, NtDeviceIoControlFile
antivm_vpc_mutexVirtual Machine Detection (B0009)--
antivm_directory_objectsVirtual Machine Detection (B0009)NtQueryDirectoryObject, NtOpenDirectoryObject
antivm_directory_objectsVirtual Machine Detection::Check File and Directory Artifacts (B0009.001)NtQueryDirectoryObject, NtOpenDirectoryObject
antivm_network_adaptersVirtual Machine Detection (B0009)GetAdaptersAddresses
antivm_generic_cpuVirtual Machine Detection (B0009)--
antivm_generic_cpuVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_generic_cpuVirtual Machine Detection::Unique Hardware/Firmware Check - BIOS (B0009.024)--
antivm_vbox_provnameVirtual Machine Detection (B0009)WNetGetProviderNameW
antivm_vbox_provnameVirtual Machine Detection::Check File and Directory Artifacts (B0009.001)WNetGetProviderNameW
antivm_generic_biosVirtual Machine Detection (B0009)--
antivm_generic_biosVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_generic_biosVirtual Machine Detection::Unique Hardware/Firmware Check - BIOS (B0009.024)--
antivm_vbox_keysVirtual Machine Detection (B0009)--
antivm_vbox_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_vmware_eventsVirtual Machine Detection (B0009)NtOpenEvent, NtCreateEvent
antivm_vbox_devicesVirtual Machine Detection (B0009)--
antivm_vbox_devicesVirtual Machine Detection::Check Virtual Devices (B0009.008)--
antivm_vmware_devicesVirtual Machine Detection (B0009)--
antivm_vmware_devicesVirtual Machine Detection::Check Virtual Devices (B0009.008)--
antivm_hyperv_keysVirtual Machine Detection (B0009)--
antivm_hyperv_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_vbox_filesVirtual Machine Detection (B0009)--
antivm_vbox_filesVirtual Machine Detection::Check Virtual Devices (B0009.008)--
antisandbox_mouse_hookVirtual Machine Detection (B0009)SetWindowsHookExA, SetWindowsHookExW
antisandbox_mouse_hookVirtual Machine Detection::Human User Check (B0009.012)SetWindowsHookExA, SetWindowsHookExW
antivm_generic_scsiVirtual Machine Detection (B0009)RegOpenKeyExW, RegQueryValueExA, RegQueryValueExW, RegOpenKeyExA
antivm_generic_scsiVirtual Machine Detection::Check Registry Keys (B0009.005)RegOpenKeyExW, RegQueryValueExA, RegQueryValueExW, RegOpenKeyExA
antivm_vmware_libsVirtual Machine Detection (B0009)LdrLoadDll
antivm_vmware_libsVirtual Machine Detection::Check File and Directory Artifacts (B0009.001)LdrLoadDll
antivm_xen_keysVirtual Machine Detection (B0009)--
antivm_xen_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_parallels_keysVirtual Machine Detection (B0009)--
antivm_parallels_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_generic_diskregVirtual Machine Detection (B0009)--
antivm_generic_diskregVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_vpc_keysVirtual Machine Detection (B0009)--
antivm_vpc_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_bochs_keysVirtual Machine Detection (B0009)--
antivm_bochs_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_vpc_filesVirtual Machine Detection (B0009)--
antivm_vpc_filesVirtual Machine Detection::Check File and Directory Artifacts (B0009.001)--
antivm_vmware_mutexesVirtual Machine Detection (B0009)--
antivm_vbox_libsVirtual Machine Detection (B0009)LdrLoadDll
antivm_vbox_libsVirtual Machine Detection::Check File and Directory Artifacts (B0009.001)LdrLoadDll
antivm_generic_systemVirtual Machine Detection (B0009)--
antivm_generic_systemVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_vmware_filesVirtual Machine Detection (B0009)--
antivm_vmware_filesVirtual Machine Detection::Check File and Directory Artifacts (B0009.001)--
antivm_generic_servicesVirtual Machine Detection::Check Registry Keys (B0009.005)RegOpenKeyExW, RegEnumKeyExW, RegEnumKeyExA, RegOpenKeyExA
antivm_generic_servicesVirtual Machine Detection::Check Running Services (B0009.006)RegOpenKeyExW, RegEnumKeyExW, RegEnumKeyExA, RegOpenKeyExA
antivm_generic_disk_setupapiVirtual Machine Detection (B0009)SetupDiGetClassDevsA, SetupDiGetClassDevsW
antisandbox_sboxie_objectsVirtual Machine Detection (B0009)NtOpenDirectoryObject
antivm_vmware_keysVirtual Machine Detection (B0009)--
antivm_vmware_keysVirtual Machine Detection::Check Registry Keys (B0009.005)--
antivm_vbox_windowVirtual Machine Detection (B0009)--
antivm_vbox_windowVirtual Machine Detection::Check Windows (B0009.009)--

Code Snippets

B0009.029 Snippet

Virtual Machine Detection::Instruction Testing SHA256: cfaf863181e49906df33f9104795678f2fb41a007a8fd066a84fd99f613d7ef3
asm
; ___unwind { // __except handler4
push ebp
mov ebp, esp
push 0FFFFFFFEh
push offset stru_413980
push offset __except handler4
mov eax, large fs:0
push eax
sub esp, 14h
push ebx
push esi
push edi
mov eax, ___security_cookie
xor [epb+ms_exc.registration.ScopeTable], eax
xor eax, ebp
push eax
lea eax, [ebp+ms_exc.registration]
mov large fs:0 eax
mov [ebp+var_19], al
;  __try { // __except at loc_401CB8
mov [ebp+ms_exc.registration.TryLevel], eax
push ebx
mov ebx, 0
mov eax, 1
vpcext 7, 08h
test ebx, ebx
setz [ebp+var_19]
pop ebx
jmp short loc_401CBB

References

[1] Check Point Research,"CP: Evasion Techniques," evasions.checkpoint.com, [Online]. Available: https://evasions.checkpoint.com.

[2] https://search.unprotect.it/category/sandbox-evasion/

[3] https://blog.talosintelligence.com/2018/04/gravityrat-two-year-evolution-of-apt.html

[4] https://www.mcafee.com/blogs/other-blogs/mcafee-labs/webcobra-malware-uses-victims-computers-to-mine-cryptocurrency/

[5] https://github.com/LordNoteworthy/al-khaser

[6] https://web.archive.org/web/20161025013916/https://web.archive.org/web/20200815134441/https://www.fireeye.com/blog/threat-research/2011/01/the-dead-giveaways-of-vm-aware-malware.html

[7] https://securelist.com/the-banking-trojan-emotet-detailed-analysis/69560/

[8] https://securitynews.sonicwall.com/xmlpost/revisiting-vobfus-worm-mar-8-2013/

[9] https://www.0ffset.net/reverse-engineering/matanbuchus-loader-analysis/

[10] https://www.cyberark.com/resources/threat-research-blog/inside-matanbuchus-a-quirky-loader

[11] https://www.proofpoint.com/us/threat-insight/post/ursnif-banking-trojan-campaign-sandbox-evasion-techniques

[12] capa v4.0, analyzed at MITRE on 10/12/2022

[12] https://www.hackread.com/gravityrat-malware-evades-detection-targets-india/