How to detect if my application is running in a virtual machine?

前端 未结 10 1261
青春惊慌失措
青春惊慌失措 2020-11-28 05:52

How can I detect (.NET or Win32) if my application is running in a virtual machine?

10条回答
  •  情深已故
    2020-11-28 06:10

    Remember you should not just check popular VM model,manufacturer name from wmi, You should also check difference between reality and virtualization.
    VM don't have much features.
    1) check-if-cpu-temperature-information-is-available

    wmic /namespace:\\root\WMI path MSAcpi_ThermalZoneTemperature get CurrentTemperature
    //On Real PC
    //CurrentTemperature
    //3147
    
    //On VM
    //Node - Admin
    //Error:
    //Description not supported
    

    Tested on vmware,virtualbox,windows server,app.any.run sandbox.

    2) Win32_PortConnector

    Get-WmiObject Win32_PortConnector
    //On Vm it is null
    
    //On real pc it looks something like that
    Tag                         : Port Connector 0
    ConnectorType               : {23, 3}
    SerialNumber                :
    ExternalReferenceDesignator :
    PortType                    : 2
    
    

提交回复
热议问题