Skip to main content
When reversing malware or vulnerability-research targets you will encounter recurring patterns. Recognising them saves significant analysis time.

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

  1. Find the target PID: CreateToolhelp32Snapshot + Process32Next
  2. Open the process: OpenProcess
  3. Write DLL path: VirtualAllocEx + WriteProcessMemory
  4. Call LoadLibrary remotely: CreateRemoteThread with LoadLibraryA as 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

Detection: Alert on 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 via LoadLibrary). A bootstrap function inside the DLL resolves its own imports, fixes relocations, and calls DllMain. No path is written to disk.

Thread hijacking

  1. Snapshot threads: CreateToolhelp32Snapshot + Thread32First
  2. Suspend target thread: SuspendThread
  3. Write payload: VirtualAllocEx + WriteProcessMemory
  4. Set context to point at payload: SetThreadContext
  5. 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:
  1. Has a tiny .text section with a short stub
  2. Allocates an RWX memory region with VirtualAlloc
  3. Copies compressed/encrypted data into it
  4. Decrypts/decompresses in place
  5. Jumps to the unpacked entry point
Approach: Set a breakpoint just before the final JMP, then dump the unpacked PE from memory.

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.