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() { int cpu_known_vm_vendors() {
const int count = 4; const int count = 6;
int i; int i;
char cpu_vendor[13]; char cpu_hv_vendor[13];
string strs[count]; string strs[count];
strs[0] = "KVMKVMKVMKVM"; strs[0] = "KVMKVMKVMKVM"; /* KVM */
strs[1] = "Microsoft Hv"; strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */
strs[2] = "VMwareVMware"; strs[2] = "VMwareVMware"; /* VMware */
strs[3] = "XenVMMXenVMM"; strs[3] = "XenVMMXenVMM"; /* Xen */
cpu_write_vendor(cpu_vendor); strs[4] = "prl hyperv "; /* Parallels */
strs[5] = "VBoxVBoxVBox"; /* VirtualBox */
cpu_write_hv_vendor(cpu_hv_vendor);
for (i = 0; i < count; i++) { 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; return FALSE;
} }

View File

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