Implement advanced anti-debugging and virtual-machine evasion hooks (Issue-141) - #169
Implement advanced anti-debugging and virtual-machine evasion hooks (Issue-141)#169doomedraven wants to merge 4 commits into
Conversation
…Issue-141) Surgically implements and completes five high-utility dynamic evasion and monitoring hooks: 1. NtQueryInformationProcess: Intercepts process query calls to spoof ProcessDebugPort to 0, ProcessDebugFlags to 1, and ProcessDebugObjectHandle to NULL, completely bypassing sandbox-detection and anti-debugging checks. 2. EnumDisplayDevicesW: Intercepts graphics card queries to replace VMware, VirtualBox, VBox, QEMU, and Citrix adapters with highly realistic physical display device descriptions (Intel HD Graphics 620), bypassing VM-detection evasion. 3. NetUserGetInfo: Intercepts user profile queries to monitor administrative and local user reconnaissance. 4. MapFileAndCheckSumA: Intercepts PE checksum calculation routines to log dynamic launcher targets. 5. CryptProtectMemory: Updates the existing stub to correctly log plaintext dynamic buffers.
|
not all api might be very useful, so as always, edit/merge/reject on your opinion. im just exploring different subject while we doing comparision with another sandbox |
…fety Three critical fixes to the anti-debugging/VM evasion hooks: 1. NtQueryInformationProcess: Replace magic numbers with named constants - Added ProcessDebugPort, ProcessDebugObjectHandle, ProcessDebugFlags - Improves code readability and maintainability 2. EnumDisplayDevicesW: Fix type declaration - Changed PDISTHREAD -> PDISPLAY_DEVICEW (correct Windows SDK type) - Removed unnecessary cast 3. EnumDisplayDevicesW: Add defensive null-termination - Ensure DeviceString is null-terminated before wcsstr calls - Add structure size validation (pDevice->cb check) - Prevents potential buffer over-read These changes comply with the PR kevoreilly#175 safety mandates while preserving the anti-evasion functionality. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…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>
…efinitions, and declare DebugOutput in hook_window.c
|
As always, grateful for the contributions. The new code in the I will combine the two lists. I also think the older loop was nicer than a static list of comparisons particularly if the list is to grow, so I think the old loop with a combined list seems to be the best way forward. The other significant addition here is the new hook code for The hooks for |
…distill and refine
|
ups my bad, thanks |
Here is a technical assessment of the security, anti-analysis, and logging utility for each suggested API:
CryptProtectMemory/CryptUnprotectMemorydpapi.dllNtQueryInformationProcessntdll.dllProcessDebugPort(returns a non-zero debug port if debugged),ProcessDebugObjectHandle, orProcessDebugFlags. Hooking this to fake no-debugger states is vital for evasion.NetUserGetInfo/NetUserGetLocalGroupsnetapi32.dllAdministratorsgroup or has privilege escalation potential.EnumDisplayDevicesWuser32.dll"VMware SVGA"or"VirtualBox Graphics Adapter").MapFileAndCheckSumAimagehlp.dllInternetConfirmZoneCrossingWurlmon.dllMultiByteToWideChar/WideCharToMultiBytekernel32.dll