Skip to content

Commit

Permalink
Added power capabilities checks.
Browse files Browse the repository at this point in the history
The GetPwrCapabilities API can be used to test for certain power capabilities of the system. Most VMs don't support CPU power states S1-S4 or thermal control
  • Loading branch information
gsuberland committed May 28, 2018
1 parent 59558e8 commit 4b71d41
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Please, if you encounter any of the anti-analysis tricks which you have seen in
- VMWare
- VBOX
- VIRTUAL HD
- Power policies (S1-S4 states, thermal control)
- **System Firmware Tables**
- SMBIOS string checks (VirtualBox)
- SMBIOS string checks (VMWare)
Expand Down
1 change: 1 addition & 0 deletions al-khaser/Al-khaser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int main(void)
exec_check(&manufacturer_computer_system_wmi, TEXT("Checking Manufacturer from ComputerSystem using WMI: "));
exec_check(&current_temperature_acpi_wmi, TEXT("Checking Current Temperature using WMI: "));
exec_check(&process_id_processor_wmi, TEXT("Checking ProcessId using WMI: "));
exec_check(&power_capabilities, TEXT("Checking power capabilities: "));
}

/* VirtualBox Detection */
Expand Down
20 changes: 20 additions & 0 deletions al-khaser/Anti VM/Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,5 +822,25 @@ BOOL process_id_processor_wmi()
}
}

return bFound;
}

/*
Check what power states are enabled.
Most VMs don't support S1-S4 power states whereas most hardware does, and thermal control is usually not found either.
This has been tested on VirtualBox and Hyper-V, as well as a physical desktop and laptop.
*/
BOOL power_capabilities()
{
SYSTEM_POWER_CAPABILITIES powerCaps;
BOOL bFound = FALSE;
if (GetPwrCapabilities(&powerCaps) == TRUE)
{
if ((powerCaps.SystemS1 | powerCaps.SystemS2 | powerCaps.SystemS3 | powerCaps.SystemS4) == FALSE)
{
bFound = (powerCaps.ThermalControl == FALSE);
}
}

return bFound;
}
6 changes: 5 additions & 1 deletion al-khaser/Anti VM/Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <winioctl.h> // IOCTL
#include <intrin.h> // cpuid()

#include <powrprof.h> // check_power_modes()
#pragma comment(lib, "powrprof.lib")


#include <SetupAPI.h>
#pragma comment(lib, "setupapi.lib")
Expand Down Expand Up @@ -32,4 +35,5 @@ BOOL serial_number_bios_wmi();
BOOL model_computer_system_wmi();
BOOL manufacturer_computer_system_wmi();
BOOL current_temperature_acpi_wmi();
BOOL process_id_processor_wmi();
BOOL process_id_processor_wmi();
BOOL power_capabilities();
Binary file modified al-khaser_x64.exe
Binary file not shown.
Binary file modified al-khaser_x86.exe
Binary file not shown.

0 comments on commit 4b71d41

Please sign in to comment.