C++: Sandbox Detection via Registry
Objective
Detect sandbox environment via Registry keys.
To do list
Research registry keys and values used by virtual machines.
Check keys and values to determine wether environment is sandbox or not.
Registry Keys
Here are the common registry keys / values used by virtual machines:
"HARDWARE\DEVICEMAP\Scsi\Scsi Port 2\Scsi Bus 0\Target Id 0\Logical Unit Id 0\Identifier",
"SYSTEM\CurrentControlSet\Enum\SCSI\Disk&VenVMware&ProdVMware_Virtual_S",
"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\root#vmwvmcihostdev",
"SYSTEM\CurrentControlSet\Control\VirtualDeviceDrivers",
"SYSTEM\ControlSet001\Services\VBoxGuest",
"SYSTEM\ControlSet001\Services\VBoxMouse",
"SYSTEM\ControlSet001\Services\VBoxService",
"SYSTEM\ControlSet001\Services\VBoxSF",
"SYSTEM\ControlSet001\Services\VBoxVideo",
"SOFTWARE\VMWare, Inc.\VMWare Tools",
"SOFTWARE\Oracle\VirtualBox Guest Additions",
"SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters",
"HARDWARE\ACPI\DSDT\VBOX"
"HARDWARE\ACPI\FADT\VBOX"
"HARDWARE\ACPI\RSDT\VBOX", "HARDWARE\ACPI\DSDT\VBOX__"
Functions
RegOpenKeyExA: Try to open a key. If key exists key will be opened.
Header: winreg.h
Definition:LSTATUS RegOpenKeyExA(HKEY hKey,LPCSTR lpSubKey,DWORD ulOptions,REGSAM samDesired,PHKEY phkResult);
hKey: Key root. HKEY_LOCAL_MACHINE. Check references for further information.
lbSubKey: Name of the registry subkey to open. Predefined list will be used in a loop.
ulOptions: 0 as default. Check references for further information.
samDesired: Desired access rights. KEY_READ. Check references for further information.
phkResult: Pointer of the handle to hold results. HKEY hKey;
RegQueryValueExA: Retrieve value from the registry key.
Header: winreg.h
Definition: LSTATUS RegQueryValueExA(HKEY hKey,LPCSTR lpValueName,LPDWORD lpReserved,LPDWORD lpType,LPBYTE lpData,LPDWORD lpcbData);
hKey: Handle to open registry key. Returns from RegOpenKeyExA. hKey.
lpValueName: Name of the registry value. Predefined list will be used in a loop.
lpReserved: NULL as default. Check references for further information.
lpType: NULL as default. Check references for further information.
lpData: A pointer to a buffer that receives the value's data. (LPBYTE)buff.
lpcbData: Pointer of size of the buff used in lpData. *buffSize
RegCloseKey: Closes the key.
Header: winreg.h
Definition: RegCloseKey(HKEY handle)
handle: hKey
Application (sandbox-check.cpp)
References
Last updated
Was this helpful?