Input Capture: Credential API Hooking

Adversaries may hook into Windows application programming interface (API) functions and Linux system functions to collect user credentials. Malicious hooking mechanisms may capture API or function calls that include parameters that reveal user authentication credentials.[1] Unlike Keylogging, this technique focuses specifically on API functions that include parameters that reveal user credentials.

In Windows, hooking involves redirecting calls to these functions and can be implemented via:

  • Hooks procedures, which intercept and execute designated code in response to events such as messages, keystrokes, and mouse inputs.[2][3]
  • Import address table (IAT) hooking, which use modifications to a process’s IAT, where pointers to imported API functions are stored.[3][4][5]
  • Inline hooking, which overwrites the first bytes in an API function to redirect code flow.[3][6][5]

In Linux and macOS, adversaries may hook into system functions via the LD_PRELOAD (Linux) or DYLD_INSERT_LIBRARIES (macOS) environment variables, which enables loading shared libraries into a program’s address space. For example, an adversary may capture credentials by hooking into the libc read function leveraged by SSH or SCP.[7]

ID: T1056.004
Sub-technique of:  T1056
Platforms: Linux, Windows, macOS
Version: 1.2
Created: 11 February 2020
Last Modified: 15 April 2025

Procedure Examples

ID Name Description
S0484 Carberp

Carberp has hooked several Windows API functions to steal credentials.[8]

S0363 Empire

Empire contains some modules that leverage API hooking to carry out tasks, such as netripper.[9]

S0182 FinFisher

FinFisher hooks processes by modifying IAT pointers to CreateWindowEx.[10][3]

S0353 NOKKI

NOKKI uses the Windows call SetWindowsHookEx and begins injecting it into every GUI process running on the victim's machine.[11]

G0068 PLATINUM

PLATINUM is capable of using Windows hook interfaces for information gathering such as credential access.[12]

S0416 RDFSNIFFER

RDFSNIFFER hooks several Win32 API functions to hijack elements of the remote system management user-interface.[13]

S0266 TrickBot

TrickBot has the ability to capture RDP credentials by capturing the CredEnumerateA API[14]

S0386 Ursnif

Ursnif has hooked APIs to perform a wide variety of information theft, such as monitoring traffic from browsers.[15]

S1154 VersaMem

VersaMem hooked and overrided Versa's built-in authentication method, setUserPassword, to intercept plaintext credentials when submitted to the server.[16]

S0251 Zebrocy

Zebrocy installs an application-defined Windows hook to get notified when a network drive has been attached, so it can then use the hook to call its RecordToFile file stealing method.[17]

S0330 Zeus Panda

Zeus Panda hooks processes by leveraging its own IAT hooked functions.[18]

S0412 ZxShell

ZxShell hooks several API functions to spawn system threads.[19]

Mitigations

This type of attack technique cannot be easily mitigated with preventive controls since it is based on the abuse of system features.

Detection

ID Data Source Data Component Detects
DS0017 Command Command Execution

Monitor executed commands and arguments associated with modifications to variables and files associated with loading shared libraries such as LD_PRELOAD on Linux and DYLD_INSERT_LIBRARIES on macOS.

DS0022 File File Creation

Monitor for newly constructed files that are added to absolute paths of shared libraries such as LD_PRELOAD on Linux (such as /etc/ld.so.preload) and DYLD_INSERT_LIBRARIES on macOS.

File Modification

Monitor for changes to files associated with loading shared libraries such as LD_PRELOAD on Linux (such as /etc/ld.so.preload) and DYLD_INSERT_LIBRARIES on macOS.

DS0011 Module Module Load

Monitor library metadata, such as a hash, and compare libraries that are loaded at process execution time against previous executions to detect differences that do not correlate with patching or updates.

DS0009 Process OS API Execution

Monitor for API calls to the SetWindowsHookEx and SetWinEventHook functions, which install a hook procedure.[2][20] Also consider analyzing hook chains (which hold pointers to hook procedures for each type of hook) using tools[20][21][22] or by programmatically examining internal kernel structures.[23][24]

Process Metadata

Verify integrity of live processes by comparing code in memory to that of corresponding static binaries, specifically checking for jumps and other instructions that redirect code flow.

References