0

Is it possible to detect if my MacOS app is running on a virtual machine? (I don't mean the simulator, just some VM like VirtualBox or anything else..)

Witterquick
  • 6,048
  • 3
  • 26
  • 50
  • 1
    Related http://stackoverflow.com/questions/154163/detect-virtualized-os-from-an-application and http://stackoverflow.com/questions/498371/how-to-detect-if-my-application-is-running-in-a-virtual-machine and multiple others. – Sulthan Mar 26 '17 at 10:54

1 Answers1

2

I only have VMWare but the techniques I used can be extended to VirtualBox. Besides below simple techniques, each VM vendor has an interface to talk to host system. However they may require higher privileges.

VMware

  1. VMWare Tools If VMWare Tools is installed, you may check following files.

GFX card

You can check whether VmTools is installed. Particulary the presence of VMwareGfx.kext inside /Library/Extensions folder

VMware Tools Daemon Launcher

/Library/LaunchDaemons/com.vmware.launchd.vmware-tools-userd

VMware Tools Daemon

/Library/Application Support/VMware Tools/vmware-tools-daemon

You can also check if there is VMware Graphics card present by checking IORegistry
Since VMware GFX has following

Device ID: 0x0405 Revision ID: 0x0000 Vendor ID: 0x15ad

  1. Model Identifier You can get all information about device with system_profiler

For example system_profiler SPHardwareDataType gives following information

Hardware Overview:

  Model Name: Apple device
  Model Identifier: VMware7,1
  Processor Speed: 3.23 GHz
  Number of Processors: 2
  Total Number of Cores: 2
  L2 Cache (per Processor): 256 KB
  L3 Cache (per Processor): 6 MB
  Memory: 2 GB
  Boot ROM Version: VMW71.00V.0.B64.1507021939
  SMC Version (system): 2.8f0
  Serial Number (system): VMiZVX4JH1rt
  Hardware UUID: 564D8995-57E0-91F5-AEDF-1968AB31F81E

Model Identifier and Boot ROM can be used to find out VMware

system_profiler SPHardwareDataType | awk '/Model Identifier/ {print $3}'

  1. Other virtual devices

    • VMware Virtual SATA Hard Drive
    • VMware Virtual USB
    • VMware Virtual SATA CDRW Drive
Meanteacher
  • 2,031
  • 3
  • 17
  • 48