fix #47 add hypervisor vendor checking

This commit is contained in:
Alberto Ortega 2016-03-02 20:59:19 +01:00
parent 6264d96ca2
commit d4ca81c7a5
2 changed files with 13 additions and 11 deletions

View File

@ -137,17 +137,19 @@ void cpu_write_brand(char * brand) {
}
int cpu_known_vm_vendors() {
const int count = 4;
const int count = 6;
int i;
char cpu_vendor[13];
char cpu_hv_vendor[13];
string strs[count];
strs[0] = "KVMKVMKVMKVM";
strs[1] = "Microsoft Hv";
strs[2] = "VMwareVMware";
strs[3] = "XenVMMXenVMM";
cpu_write_vendor(cpu_vendor);
strs[0] = "KVMKVMKVMKVM"; /* KVM */
strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */
strs[2] = "VMwareVMware"; /* VMware */
strs[3] = "XenVMMXenVMM"; /* Xen */
strs[4] = "prl hyperv "; /* Parallels */
strs[5] = "VBoxVBoxVBox"; /* VirtualBox */
cpu_write_hv_vendor(cpu_hv_vendor);
for (i = 0; i < count; i++) {
if (!memcmp(cpu_vendor, strs[i], 12)) return TRUE;
if (!memcmp(cpu_hv_vendor, strs[i], 12)) return TRUE;
}
return FALSE;
}

View File

@ -107,10 +107,10 @@ int main(void)
exec_check("Checking hypervisor bit in cpuid feature bits", &cpu_hv,
"CPU VM traced by checking hypervisor bit in cpuid feature bits",
"hi_CPU_VM_hypervisor_bit");
exec_check("Checking cpuid vendor for known VM vendors",
exec_check("Checking cpuid hypervisor vendor for known VM vendors",
&cpu_known_vm_vendors,
"CPU VM traced by checking cpuid vendor for known VM vendors",
"hi_CPU_VM_vendor_name");
"CPU VM traced by checking cpuid hypervisor vendor for known VM vendors",
"hi_CPU_VM_hv_vendor_name");
/* Generic sandbox detection tricks */
print_check_group("Generic sandbox detection");