Windows API patterns
Malware on Windows relies heavily on a small set of Win32 APIs. Recognising the import table or dynamic resolution of these names is often the first step in understanding what a sample does.Networking
Many modern loaders wrap their TCP stream in
SslStream and pin the server certificate against an embedded copy. Bot payloads are often GZip-compressed and fragmented into ~16 KB chunks to evade size-based heuristics.Persistence
Stealth and injection
Injection techniques
DLL injection
- Find the target PID:
CreateToolhelp32Snapshot+Process32Next - Open the process:
OpenProcess - Write DLL path:
VirtualAllocEx+WriteProcessMemory - Call
LoadLibraryremotely:CreateRemoteThreadwithLoadLibraryAas the start routine
Process hollowing (RunPE)
Launches a legitimate process suspended, removes its image, and maps a malicious PE in its place. The malicious code runs under the cover of a signed Microsoft binary.1
Create suspended process
2
Unmap original image
NtUnmapViewOfSection(pi.hProcess, originalBase);3
Allocate and write payload
VirtualAllocEx at the same base, then WriteProcessMemory for headers and each section.4
Redirect instruction pointer and resume
CREATE_SUSPENDED processes that are immediately followed by NtUnmapViewOfSection → VirtualAllocEx → WriteProcessMemory across process boundaries.
Reflective DLL injection
The DLL is mapped directly into memory (not viaLoadLibrary). A bootstrap function inside the DLL resolves its own imports, fixes relocations, and calls DllMain. No path is written to disk.
Thread hijacking
- Snapshot threads:
CreateToolhelp32Snapshot+Thread32First - Suspend target thread:
SuspendThread - Write payload:
VirtualAllocEx+WriteProcessMemory - Set context to point at payload:
SetThreadContext - Resume:
ResumeThread
Hooking techniques
Anti-analysis tricks
Anti-debugging
Locale / keyboard layout guards
Many stealers abort on CIS-country locales:Emulator fingerprinting
Some malware detects Microsoft Defender’s internal emulator by scanning for its exported function names at runtime:Common packing patterns
A packed binary typically:- Has a tiny
.textsection with a short stub - Allocates an RWX memory region with
VirtualAlloc - Copies compressed/encrypted data into it
- Decrypts/decompresses in place
- Jumps to the unpacked entry point
Encryption in malware
Common encryption API usage patterns:
Strings are often RC4 or XOR encrypted on a per-string basis, only decrypted immediately before use, to prevent static analysis from extracting IOCs.