@@ -3039,7 +3039,6 @@ struct VM {
30393039 * @category Windows
30403040 */
30413041 [[nodiscard]] static bool cursor_check () try {
3042- return true ;
30433042#if (!MSVC)
30443043 return false ;
30453044#else
@@ -4352,8 +4351,7 @@ struct VM {
43524351 // this is added so no sanitizers can potentially cause unwanted delays while measuring rdtsc in a debug compilation
43534352 __attribute__ ((no_sanitize (" address" , " leak" , " thread" , " undefined" )))
43544353#endif
4355- static bool rdtsc_vmexit () try {
4356-
4354+ static bool rdtsc_vmexit () try {
43574355#if (!x86)
43584356 return false ;
43594357#else
@@ -4447,18 +4445,19 @@ struct VM {
44474445 }
44484446
44494447 // technique 3: Check for absence of AMD easter egg for K7 and K8 CPUs
4450- /*
4448+ constexpr u32 AMD_EASTER_EGG = 0x8fffffff ; // this is the CPUID leaf of the AMD easter egg
4449+
4450+ if (!cpu::is_leaf_supported (AMD_EASTER_EGG)) {
4451+ return false ;
4452+ }
4453+
44514454 u32 unused, eax = 0 ;
44524455 cpu::cpuid (eax, unused, unused, unused, 1 );
44534456
4454- constexpr u8 AMD_K7 = 6;
4455- constexpr u8 AMD_K8 = 15;
4456-
44574457 auto is_k7 = [](const u32 eax) -> bool {
44584458 const u32 family = (eax >> 8 ) & 0xF ;
44594459 const u32 model = (eax >> 4 ) & 0xF ;
44604460 const u32 extended_family = (eax >> 20 ) & 0xFF ;
4461- const u32 extended_model = (eax >> 16) & 0xF;
44624461
44634462 if (family == 6 && extended_family == 0 ) {
44644463 if (model == 1 || model == 2 || model == 3 || model == 4 ) {
@@ -4470,21 +4469,28 @@ struct VM {
44704469 };
44714470
44724471 auto is_k8 = [](const u32 eax) -> bool {
4473- // TODO
4472+ const u32 family = (eax >> 8 ) & 0xF ;
4473+ const u32 extended_family = (eax >> 20 ) & 0xFF ;
4474+
4475+ if (family == 0xF ) {
4476+ if (extended_family == 0x00 || extended_family == 0x01 ) {
4477+ return true ;
4478+ }
4479+ }
4480+
4481+ return false ;
44744482 };
44754483
4476- if (family != AMD_K7 && family != AMD_K8 ) {
4484+ if (!( is_k7 (eax) || is_k8 (eax)) ) {
44774485 return false ;
44784486 }
44794487
44804488 u32 ecx_bochs = 0 ;
4481- cpu::cpuid(unused, unused, ecx_bochs, unused, cpu::leaf::amd_easter_egg );
4489+ cpu::cpuid (unused, unused, ecx_bochs, unused, AMD_EASTER_EGG );
44824490
44834491 if (ecx_bochs == 0 ) {
4484- debug("BOCHS_CPU: technique 3 found");
4485- return core::add(BOCHS);
4492+ return true ;
44864493 }
4487- */
44884494 }
44894495
44904496 return false ;
@@ -5035,13 +5041,13 @@ struct VM {
50355041 }
50365042
50375043 return false ;
5038- };
5044+ };
50395045
50405046 return (
50415047 check_usb () ||
50425048 check_general () ||
50435049 check_rom ()
5044- );
5050+ );
50455051#endif
50465052 }
50475053 catch (...) {
@@ -9144,42 +9150,6 @@ struct VM {
91449150
91459151
91469152
9147-
9148-
9149-
9150-
9151- // https://medium.com/@matterpreter/hypervisor-detection-with-systemhypervisordetailinformation-26e44a57f80e
9152-
9153- // idea: maybe try to get the hyper-v version and check for those values in cpuid
9154-
9155- /*
9156- EAX=21h: Reserved for TDX enumerationWhen Intel TDX (Trust Domain Extensions) is active, attempts to execute the CPUID instruction by a TD (Trust Domain) guest will be intercepted by the TDX module. This module will, when CPUID is invoked with EAX=21h and ECX=0 (leaf 21h, sub-leaf 0), return the index of the highest supported sub-leaf for leaf 21h in EAX and a TDX module vendor ID string as a 12-byte ASCII string in EBX,EDX,ECX (in that order). Intel's own module implementation returns the vendor ID string "IntelTDX " (with four trailing spaces)[102] - for this module, additional feature information is not available through CPUID and must instead be obtained through the TDX-specific TDCALL instruction.
9157- */
9158-
9159-
9160- // https://github.com/systemd/systemd/blob/main/src/basic/virt.c
9161-
9162-
9163- /*
9164- In the same way, a lot of these virtual files can provide information on the environment, including –
9165- but not limited to – /proc/sysinfo (in which some distribution expose data about virtual machines),
9166- /proc/device-tree (that lists the devices on the machine), /proc/xen (a file created by the Xen
9167- Server) or /proc/modules (that contains information about the loaded kernel modules, modules
9168- that are used by hypervisors to optimize the guests).
9169- Like procfs (mounted in /proc), sysfs can be useful. Its role is to provide to the user an access to the
9170- devices and their drivers. The file /sys/hypervisor/type, for instance, is sometimes used to store
9171- information about the hypervisor Linux is running on
9172- */
9173-
9174-
9175- // https://unprotect.it/technique/retrieve-hdd-information/
9176-
9177-
9178- // https://github.com/torvalds/linux/blob/31cc088a4f5d83481c6f5041bd6eb06115b974af/arch/x86/kernel/cpu/vmware.c
9179-
9180-
9181-
9182-
91839153 struct core {
91849154 MSVC_DISABLE_WARNING (PADDING)
91859155 struct technique {
@@ -9323,7 +9293,6 @@ struct VM {
93239293 // run the technique
93249294 const bool result = tuple.run ();
93259295
9326-
93279296 // accumulate the points if technique detected a VM
93289297 if (result) {
93299298 points += tuple.points ;
0 commit comments