Defeat advanced WMI hardware sensor evasion checks (al-khaser Bypass) - #172
Open
doomedraven wants to merge 4 commits into
Open
Defeat advanced WMI hardware sensor evasion checks (al-khaser Bypass)#172doomedraven wants to merge 4 commits into
doomedraven wants to merge 4 commits into
Conversation
doomedraven
force-pushed
the
opt/hardware-sensor-spoofer
branch
2 times, most recently
from
August 18, 2026 09:44
46dd137 to
0cf8000
Compare
Surgically implements a fully dynamic "Borrow and Spoof" class hijacking architecture inside hook_wmi.c to defeat advanced motherboard, bios, fan, temperature, slot, and sensor evasion checks: 1. Implements class-hijacking for Win32_Fan, Win32_CacheMemory, Win32_VoltageProbe, Win32_PortConnector, Win32_ThermalZoneInfo, CIM_Memory, CIM_Sensor, CIM_NumericSensor, CIM_TemperatureSensor, CIM_VoltageSensor, CIM_PhysicalConnector, and CIM_Slot. 2. Intercepts ExecQuery/ExecQueryAsync SELECT queries for these typically unsupported VM classes and dynamically rewrites them to "SELECT * FROM Win32_ComputerSystem" strictly before execution to materialize a valid COM enumerator. 3. Shape-shifts the returned objects in WMI_Get by intercepting __CLASS queries to return the original queried class name. 4. Clears WBEM_E_NOT_FOUND errors and spoofs realistic, high-fidelity physical hardware device properties (Status, DeviceID, ActiveCooling, CurrentReading, InstalledSize, ConnectorType, PortType, CurrentTemperature), completely bypassing all VM sensor detection checks.
doomedraven
force-pushed
the
opt/hardware-sensor-spoofer
branch
from
August 18, 2026 11:14
0cf8000 to
8f4eb4b
Compare
Same NULL safety fix pattern as PRs kevoreilly#170 and kevoreilly#171. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
doomedraven
added a commit
to doomedraven/capemon
that referenced
this pull request
Aug 20, 2026
…review findings Based on systematic review of PRs kevoreilly#169-180, add critical safety mandates that were discovered as common vulnerabilities: 1. TLS Macro Safety (CRITICAL): - Document the fallback context pattern (prevents NULL dereferences) - Mandate NULL checks after calloc before TlsSetValue - Note pre-existing hook_tls.c violations as technical debt 2. Ban Magic Numbers: - Require named constants for all API values - Example: ProcessDebugPort instead of literal 7 3. String Buffer Safety: - Mandate defensive null-termination before wcsstr/wcscpy - Require structure size validation via cb member 4. Type Safety: - Require correct Windows SDK types (PDISPLAY_DEVICEW vs PVOID) - Prevents ABI mismatches across compiler versions 5. Code Review Checklist: - 5-section systematic review checklist - Covers TLS, types, strings, hooks, and documentation - Based on real issues found in production PR reviews These patterns directly address the bugs fixed in PRs kevoreilly#169, kevoreilly#170, kevoreilly#171, and kevoreilly#172, ensuring future PRs won't repeat the same vulnerabilities. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…s_index definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a fully dynamic "Borrow and Spoof" class hijacking architecture inside hook_wmi.c to defeat advanced motherboard, bios, fan, temperature, slot, and sensor evasion checks:
The Evasion Challenge: Hardware-Presence Verification
Virtual machines (VMware, VirtualBox, QEMU, Citrix) typically do not emulate low-level motherboard and chassis physical hardware devices such as cooling fans, physical cache slots, voltage probes, or thermal zone
sensors.
Malware calls WMI queries like SELECT * FROM Win32_Fan or SELECT * FROM Win32_VoltageProbe to check for these physical objects. If the WMI service returns zero objects (which is default behavior in a VM), or
returns a WBEM_E_INVALID_CLASS error, the malware instantly infers it is running inside a virtualized sandbox and terminates.
The Solution: The "Borrow & Spoof" Class Hijacking Engine
Because virtual machines genuinely lack these low-level class instances, Old_WMI_ExecQuery would normally return an empty enumerator.
To bypass this without writing thousands of lines of custom COM providers, we engineered a sophisticated "Borrow & Spoof" class-hijacking mechanism:
When ExecQuery or ExecQueryAsync detects a query targeting any of the twelve unpopulated hardware/sensor classes:
It sets a thread-local tracking enum (g_last_seen_fake_class = WMI_FAKE_CLASS_FAN, etc.) and surgically rewrites the SQL query string in memory on-the-fly to "SELECT * FROM Win32_ComputerSystem" before executing
it!
Shape-Shifting the Class Name
When the malware retrieves this object and calls Get(L"__CLASS") to identify what it is, we intercept the call. Instead of returning "Win32_ComputerSystem", we dynamically return the original faked class name
(e.g., "Win32_Fan")!
Answering Missing Hardware Properties
When the malware calls Get to read the sensor's physical readings (which do not exist on Win32_ComputerSystem), the WMI service returns a WBEM_E_NOT_FOUND error.