Credential API Hooking

Adversaries may hook into Windows application programming interface (API) functions to collect user credentials. Malicious hooking mechanisms may capture API calls that include parameters that reveal user authentication credentials.(Citation: Microsoft TrojanSpy:Win32/Ursnif.gen!I Sept 2017) Unlike [Keylogging](https://attack.mitre.org/techniques/T1056/001),  this technique focuses specifically on API functions that include parameters that reveal user credentials. 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.(Citation: Microsoft Hook Overview)(Citation: Elastic Process Injection July 2017)
* **Import address table (IAT) hooking**, which use modifications to a process’s IAT, where pointers to imported API functions are stored.(Citation: Elastic Process Injection July 2017)(Citation: Adlice Software IAT Hooks Oct 2014)(Citation: MWRInfoSecurity Dynamic Hooking 2015)
* **Inline hooking**, which overwrites the first bytes in an API function to redirect code flow.(Citation: Elastic Process Injection July 2017)(Citation: HighTech Bridge Inline Hooking Sept 2011)(Citation: MWRInfoSecurity Dynamic Hooking 2015)


Platforms: Windows
Tactics:
phase_name: collection
phase_name: credential-access

Detection:
Monitor for calls to the `SetWindowsHookEx` and `SetWinEventHook` functions, which install a hook procedure.(Citation: Microsoft Hook Overview)(Citation: Volatility Detecting Hooks Sept 2012) Also consider analyzing hook chains (which hold pointers to hook procedures for each type of hook) using tools(Citation: Volatility Detecting Hooks Sept 2012)(Citation: PreKageo Winhook Jul 2011)(Citation: Jay GetHooks Sept 2011) or by programmatically examining internal kernel structures.(Citation: Zairon Hooking Dec 2006)(Citation: EyeofRa Detecting Hooking June 2017)

Rootkits detectors(Citation: GMER Rootkits) can also be used to monitor for various types of hooking activity.

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. Also consider taking snapshots of newly started processes(Citation: Microsoft Process Snapshot) to compare the in-memory IAT to the real addresses of the referenced functions.(Citation: StackExchange Hooks Jul 2012)(Citation: Adlice Software IAT Hooks Oct 2014)

References:
source_name: mitre-attack
description: Microsoft. (2017, September 15). TrojanSpy:Win32/Ursnif.gen!I. Retrieved December 18, 2017.
source_name: Microsoft TrojanSpy:Win32/Ursnif.gen!I Sept 2017
description: Microsoft. (n.d.). Hooks Overview. Retrieved December 12, 2017.
source_name: Microsoft Hook Overview
description: Hosseini, A. (2017, July 18). Ten Process Injection Techniques: A Technical Survey Of Common And Trending Process Injection Techniques. Retrieved December 7, 2017.
source_name: Elastic Process Injection July 2017
description: Tigzy. (2014, October 15). Userland Rootkits: Part 1, IAT hooks. Retrieved December 12, 2017.
source_name: Adlice Software IAT Hooks Oct 2014
description: Hillman, M. (2015, August 8). Dynamic Hooking Techniques: User Mode. Retrieved December 20, 2017.
source_name: MWRInfoSecurity Dynamic Hooking 2015
description: Mariani, B. (2011, September 6). Inline Hooking in Windows. Retrieved December 12, 2017.
source_name: HighTech Bridge Inline Hooking Sept 2011
description: Volatility Labs. (2012, September 24). MoVP 3.1 Detecting Malware Hooks in the Windows GUI Subsystem. Retrieved December 12, 2017.
source_name: Volatility Detecting Hooks Sept 2012
description: Prekas, G. (2011, July 11). Winhook. Retrieved December 12, 2017.
source_name: PreKageo Winhook Jul 2011
description: Satiro, J. (2011, September 14). GetHooks. Retrieved December 12, 2017.
source_name: Jay GetHooks Sept 2011
description: Felici, M. (2006, December 6). Any application-defined hook procedure on my machine?. Retrieved December 12, 2017.
source_name: Zairon Hooking Dec 2006
description: Eye of Ra. (2017, June 27). Windows Keylogger Part 2: Defense against user-land. Retrieved December 12, 2017.
source_name: EyeofRa Detecting Hooking June 2017
description: GMER. (n.d.). GMER. Retrieved December 12, 2017.
source_name: GMER Rootkits
description: Microsoft. (n.d.). Taking a Snapshot and Viewing Processes. Retrieved December 12, 2017.
source_name: Microsoft Process Snapshot
description: Stack Exchange - Security. (2012, July 31). What are the methods to find hooked functions and APIs?. Retrieved December 12, 2017.
source_name: StackExchange Hooks Jul 2012