Malware Analysis

Malware API Reference

Analysis of common Windows API calls used by malware for file operations, process manipulation, registry modifications, and network communication.

Contents

Malware API Reference

Primary Resource: https://malapi.io — Interactive Windows API reference organized by malware behavior categories.


1. What is MalAPI.io?

MalAPI.io is a curated database of Windows API functions commonly abused by malware, organized by ATT&CK technique categories. It maps each API to:

  • What it does
  • Which malware families use it
  • What MITRE ATT&CK technique it corresponds to
  • Example usage patterns

How to Use It

  1. Go to https://malapi.io
  2. Browse by category (Injection, Evasion, Persistence, etc.) or search a specific API name
  3. Click any API to see: description, parameters, related malware, detection notes
  4. Use it alongside your disassembler — when you see an unknown API in imports, look it up on MalAPI

2. API Categories & Key Functions

Process Injection APIs

API FunctionDescriptionRisk Level
VirtualAllocExAllocate memory in another processHigh
WriteProcessMemoryWrite data into another process’s memoryCritical
CreateRemoteThreadCreate a thread in another processCritical
NtMapViewOfSectionMap a section object into a process (stealthy)Critical
QueueUserAPCQueue an APC to a thread (APC injection)High
SetThreadContextModify thread registers (thread hijacking)Critical
NtCreateThreadExLow-level thread creation (ntdll)Critical
RtlCreateUserThreadAnother thread creation (used to bypass hooks)Critical

Memory Manipulation APIs

API FunctionDescriptionRisk Level
VirtualAllocAllocate memory in current processMedium
VirtualProtectChange memory page protections (RWX)High
HeapCreate / HeapAllocHeap allocation (shellcode staging)Medium
NtAllocateVirtualMemoryLow-level memory allocationHigh
VirtualFreeFree allocated memoryLow

Evasion & Anti-Analysis APIs

API FunctionDescriptionWhat Malware Does
IsDebuggerPresentCheck if debugger attachedExit or change behavior
CheckRemoteDebuggerPresentCheck for remote debuggerSame as above
NtQueryInformationProcessQuery debug port, flagsDetect debugger/sandbox
GetTickCount / QueryPerformanceCounterGet system timeTiming-based sandbox detection
NtDelayExecution / SleepDelay executionSandbox evasion (sleep > analysis time)
OutputDebugStringASend string to debuggerCrash certain debuggers
NtSetInformationThreadHide thread from debuggerThreadHideFromDebugger
GetSystemInfoGet CPU/RAM infoDetect VM (low resources = sandbox)
EnumWindowsList all windowsCheck for analysis tools

Persistence APIs

API FunctionDescriptionPersistence Method
RegCreateKeyExACreate registry keyRun key persistence
RegSetValueExASet registry valueWrite to HKCU\...\Run
CreateServiceACreate a Windows serviceService persistence
StartServiceAStart a serviceActivate persistence
CopyFileACopy file to new locationDrop to startup folder
SHGetFolderPathAGet special folder pathsFind Startup folder
CoCreateInstanceCreate COM objectCOM hijacking

File Operations APIs

API FunctionDescriptionMalware Use
CreateFileA/WOpen/create fileDrop payloads
WriteFileWrite data to fileWrite malicious content
ReadFileRead file contentsRead config/steal data
DeleteFileADelete a fileSelf-deletion, anti-forensics
MoveFileAMove/rename fileRelocate payload
FindFirstFile / FindNextFileDirectory enumerationRansomware file discovery
GetTempPathAGet temp directoryCommon drop location

Network Communication APIs

API FunctionDescriptionProtocol
WSAStartupInitialize WinsockRaw sockets
socket / connect / send / recvRaw socket operationsTCP/UDP C2
InternetOpenAInitialize WinINetHTTP/HTTPS
InternetConnectAConnect to serverHTTP C2
HttpOpenRequestACreate HTTP requestHTTP C2
HttpSendRequestASend HTTP requestExfiltration
WinHttpOpenInitialize WinHTTP (modern)HTTPS C2
URLDownloadToFileADownload file from URLStage 2 download
InternetReadFileRead response dataReceive C2 commands

Credential Theft APIs

API FunctionDescriptionWhat It Steals
CredEnumerateAEnumerate stored credentialsWindows credential store
CryptUnprotectDataDecrypt DPAPI-protected dataBrowser passwords, cookies
LsaRetrievePrivateDataRetrieve LSA secretsService passwords
OpenProcessTokenOpen process tokenToken theft
DuplicateTokenExDuplicate access tokenToken impersonation
ImpersonateLoggedOnUserImpersonate userPrivilege escalation

Crypto APIs

API FunctionDescriptionMalware Use
CryptAcquireContextAGet crypto provider handleInitialize encryption
CryptGenKeyGenerate encryption keyRansomware key gen
CryptEncryptEncrypt dataRansomware file encryption
CryptDecryptDecrypt dataDecrypt config/C2 traffic
CryptImportKeyImport crypto keyImport attacker’s public key
BCryptEncryptModern crypto (CNG)Newer ransomware

3. API Resolution Techniques (How Malware Hides APIs)

Static Linking (Normal)

// Visible in Import Address Table
CreateRemoteThread(hProcess, NULL, 0, lpStartAddress, lpParameter, 0, NULL);

Detection: Clearly visible in IAT — easy to spot in PE-bear, IDA, Ghidra

Dynamic Resolution (Common Evasion)

// Only LoadLibrary + GetProcAddress visible in IAT
HMODULE hKernel = LoadLibrary("kernel32.dll");
typedef HANDLE (*pCreateRemoteThread)(...);
pCreateRemoteThread myFunc = (pCreateRemoteThread)GetProcAddress(hKernel, "CreateRemoteThread");
myFunc(hProcess, NULL, 0, lpStartAddress, lpParameter, 0, NULL);

Detection: Only see LoadLibrary + GetProcAddress in IAT — must trace runtime resolution

API Hashing (Advanced Evasion)

// No API names at all in the binary
DWORD hash = 0xAFC1B2D3;  // pre-computed hash of "CreateRemoteThread"
FARPROC func = resolve_api_by_hash(hash);  // walks PEB → DLL list → export table
func(hProcess, NULL, 0, lpStartAddress, lpParameter, 0, NULL);

Detection: No strings, no IAT entries — must reverse the hashing function. Common hash algorithms: djb2, ror13, crc32

Direct Syscalls (Most Advanced)

; Bypass all user-mode hooks entirely
mov r10, rcx
mov eax, 0x3F          ; NtCreateThreadEx syscall number
syscall

Detection: Look for syscall instructions with hardcoded syscall numbers. Tools: SysWhispers, HellsGate, Tartarus Gate


4. Quick Analysis Workflow Using MalAPI

1. Extract imports from binary (PE-bear, CFF Explorer, Ghidra)
2. For each suspicious import → search on malapi.io
3. Group imports by malware behavior category:
   □ Injection?  □ Persistence?  □ Network?
   □ Evasion?    □ File ops?     □ Crypto?
4. If only LoadLibrary + GetProcAddress → it's hiding real APIs
5. Cross-reference with strings analysis (FLOSS output)
6. Map to MITRE ATT&CK techniques
7. Write behavioral summary

5. Essential Online API Lookup Resources

ResourceURLUse Case
MalAPI.iomalapi.ioMalware-focused API reference
MSDNlearn.microsoft.comOfficial API documentation
Undocumented NtAPIntdoc.m417z.comUndocumented ntdll functions
ReactOS Sourcereactos.orgOpen-source Windows API implementation
MITRE ATT&CKattack.mitre.orgMap APIs to threat techniques
Unprotect.itunprotect.itEvasion & anti-analysis techniques