Skip to main content
T1056Collectionmedium difficulty

Input Capture

Input Capture (T1056) is malware reading what the user types before it ever hits an application: a hidden process registers a low-level keyboard hook or polls key state directly through the Windows API, siphoning credentials, wallet seed phrases, and payment data at the source. Detection hinges on PowerShell Script Block Logging (Event 4104) and endpoint telemetry that flags hook-registration or key-state-polling calls outside expected tooling.

Practice detecting Input Capture on realistic SIEM, XDR alerts in SOCSimulator Operations.

SIEMXDR

What is Input Capture?

Input Capture is documented as technique T1056 in MITRE ATT&CK® v19.1 under the Collection tactic. Detection requires visibility into SIEM, XDR telemetry.

Windows keylogging comes down to one of two API paths. The hook path calls SetWindowsHookEx (or its Nt/A/W variants) with WH_KEYBOARD_LL to install a low-level keyboard hook that receives every keystroke system-wide, chained through CallNextHookEx so the legitimate handler still runs and nothing looks broken. The polling path skips hooks entirely and calls GetAsyncKeyState or GetKeyboardState in a tight loop, checking the state of each key many times a second and logging the transitions. Attackers increasingly do this in PowerShell rather than a compiled binary: Get-ProcAddress resolves the raw user32.dll function pointers at runtime, so the script never touches disk as an executable and never triggers a signature match on a dropped file, only on the script content itself.

A working keylogger almost never stops at raw keys. It also calls GetForegroundWindow and GetWindowTextA/W to capture the title of whatever window currently has focus, so the operator can label a burst of keystrokes as "corporate VPN login" versus "personal webmail" versus "crypto wallet unlock" without having to guess from the raw character stream. That labeling step is what turns a firehose of keystrokes into a usable credential dump, and it is also a strong detection anchor because window-title APIs have no reason to appear next to keyboard-hook APIs in benign automation scripts.

The captured output has to go somewhere before it is useful, so it is written to a log file, usually under a Temp or AppData path with an innocuous name, then periodically compressed and pushed out over an existing C2 channel or a one-off HTTP POST. On non-Windows endpoints the same idea shows up through different primitives: macOS malware abuses Quartz Event Services (CGEventTapCreate) or IOHID access, and Linux keyloggers read raw scancodes from /dev/input/* or attach via ptrace, but the Windows hook-and-poll pattern remains the one SOC analysts encounter most often because it requires no elevated privilege and blends into routine script execution.

Where Input Capture fits in an attack

Input capture sits in the Collection and Credential Access tactics, which means it is rarely the opening move. By the time a keylogging script executes, the attacker already has code running on the host, usually from a macro-laced document, a trojanized installer, or an already-resident stealer, and is looking for a lower-effort way to harvest credentials than dumping LSASS or hunting for saved browser passwords. Keylogging is patient collection: it waits for the user to type something valuable rather than extracting what is already stored, which makes it especially effective against services that use hardware tokens or short-lived session cookies where a static credential dump would come up empty.

The tooling lineage matters for detection. Both the SigmaHQ and Elastic rules cited above trace back to Empire's Get-Keystrokes.ps1 collection module and the Atomic Red Team emulation of it, a widely reused open-source pattern that shows up repackaged inside commodity crimeware as often as in red-team engagements, which is why VirusTotal-submitted samples referenced in the Elastic rule share the same IsKeyDown/GetAsyncKeyState fingerprint as the original offensive tool. Once keystrokes are captured, the next step is almost always credential reuse or direct theft: a harvested webmail or VPN password feeds further lateral movement, while a captured wallet passphrase or exchange login goes straight to account takeover, which is the pattern the free SOCSimulator StealC room walks an analyst through end to end.

Detection Strategies

The following detection strategies help SOC analysts identify Input Capture activity. These methods apply across SIEM, XDR environments and can be implemented as detection rules, correlation queries, or behavioral analytics in your security platform.

SPL
index=* source="WinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104
  (ScriptBlockText="*GetAsyncKeyState*" OR ScriptBlockText="*NtUserGetAsyncKeyState*"
   OR ScriptBlockText="*GetKeyboardState*" OR ScriptBlockText="*Get-Keystrokes*")
  NOT SubjectUserSid="S-1-5-18"
| table _time, ComputerName, SubjectUserName, ScriptBlockId, ScriptBlockText

Matches PowerShell Script Block Logging (Event 4104) content against the key-state polling primitives named in both SigmaHQ's Powershell Keylogging rule and Elastic's PowerShell Keylogging Script analytic, excluding SYSTEM to cut routine tooling noise.

Simulated example generated by SOCSimulator Research
EventID: 4104
UtcTime: 2026-07-15 09:41:07
ComputerName: FIN-WK-22.corp.local
SubjectUserName: CORP\jmartin
ScriptBlockId: 8e2f19a3-7b4c-4e11-9c2a-5d61f0a8b3d2
ScriptBlockText: while ($true) { $k = [PSKeylog]::GetAsyncKeyState(0x41); if ($k -band 0x8000) { Add-Content -Path "$env:APPDATA\Local\Temp\wu.log" -Value "A" }; Start-Sleep -Milliseconds 20 }

Tuning and false positives

The APIs behind keylogging are also behind a lot of legitimate software. Accessibility tools and screen readers hook the keyboard to provide alternative input methods. Hotkey managers like AutoHotkey, gaming overlays, and streaming software poll key state to trigger macros or push-to-talk. Remote-support and kiosk applications hook input so they can intercept and forward it. PowerShell developers debugging their own scripts sometimes trip the same signatures, which is why Elastic's rule explicitly excludes script blocks that pair a hook or key-state call with Set-PSBreakpoint, a recognizable debugging workflow rather than credential theft.

The tuning move is to require recurrence and context rather than suppressing on the API name alone. Allow-list the specific signed binaries, script paths, and user/host pairings your accessibility, hotkey, and remote-support tools legitimately run from, and require that same pairing to show up across prior alerts before you write an exception; a first-time hit from an unfamiliar script path or an account with no history of that workflow should still escalate even if it superficially resembles known-good tooling. Keep SYSTEM deprioritized rather than fully excluded, since a keylogger running under a compromised service account is designed to look exactly like routine background automation.

Example Alerts

These realistic alert examples show what Input Capture looks like in your security tools. Use them to tune detection rules and train analysts to recognize true positives versus false positives in live environments.

HighXDR

PowerShell Script Registers Low-Level Keyboard Hook

A PowerShell script block on WS-ACC-07 called Get-ProcAddress against user32.dll to resolve SetWindowsHookEx and GetForegroundWindow in the same block, then wrote output to a hidden file under %APPDATA%\Local\Temp. The pairing matches SigmaHQ's Powershell Keylogging analytic and indicates an active hook-based keylogger rather than a benign UI script.

MediumSIEM

Script Block Logging Captures GetAsyncKeyState Polling Loop

Event 4104 on FIN-WK-22 recorded a script block calling GetAsyncKeyState in a tight loop against the alphanumeric key range, with no corresponding change ticket for the account. Continuous key-state polling from a finance workstation matches the Get-Keystrokes technique documented in Empire's collection module.

CriticalXDR

Keylogger Output Staged and Compressed Before Upload

Following a flagged keylogging script block on HR-LT-03, the same PowerShell process created a ZIP archive containing a renamed .log file and opened an outbound connection to a previously unseen IP on port 443 within two minutes. The stage-then-upload pattern indicates the captured keystrokes, likely including a payroll portal login, were being exfiltrated.

Responding to Input Capture

The first question is whether the script content shows active intent or is just an inert reference to the API names, something that happens in documentation, training material, and security-tool signature databases. Pull the full script by reconstructing every fragment sharing the same ScriptBlockId, since script block logging can split one script across multiple 4104 events and the polling loop, the window-labeling call, and the output path often land in separate fragments. Then recover the process launch chain: what spawned PowerShell, whether it came from a document, browser, or scheduled task, and whether the account and host pairing has a legitimate reason to run input-capture code.

If the script pairs hook registration or key-state polling with window labeling, writes to a hidden log path, or is followed by an archive and an outbound connection, treat it as confirmed collection rather than a maintenance false positive, and move fast: keystroke capture implies whatever the user typed next, including a password reset or a wallet unlock, is already compromised. Preserve the reconstructed script, the written log or archive artifacts, and any destination IP or domain before doing anything destructive. Reset credentials for the affected account as a precaution rather than waiting for confirmation of reuse, hunt for the same script-block fingerprint or file pattern on other hosts, and isolate the endpoint if there is evidence the captured data already left the network.

Frequently Asked Questions

How do SOC analysts detect Input Capture?
Detection centers on SIEM, XDR telemetry for the collection phase of the attack. Enable PowerShell Script Block Logging (Event 4104) and alert when ScriptBlockText references GetAsyncKeyState, NtUserGetAsyncKeyState, GetKeyboardState, or the commodity Get-Keystrokes function name, the exact primitives Empire's collection module and the FunnyKeylogger sample use to poll key state. Flag scripts that pair SetWindowsHookEx (or its NtUserSetWindowsHookEx/A/W variants) with GetForegroundWindow, GetWindowTextA/W, or hook-callback strings like WH_KEYBOARD_LL and CallNextHookEx in the same block, because that combination is registering a low-level keyboard hook and labeling the active window, the signature of a working keylogger rather than a stray API reference in documentation.
What does a Input Capture alert look like?
A representative XDR detection is "PowerShell Script Registers Low-Level Keyboard Hook" (high severity): A PowerShell script block on WS-ACC-07 called Get-ProcAddress against user32.dll to resolve SetWindowsHookEx and GetForegroundWindow in the same block, then wrote output to a hidden file under %APPDATA%\Local\Temp. The pairing matches SigmaHQ's Powershell Keylogging analytic and indicates an active hook-based keylogger rather than a benign UI script.
Which tools detect Input Capture, and how can I practice?
Input Capture (T1056) is best surfaced with SIEM, XDR telemetry, which exposes the collection signals described above. Practice detecting it on those exact consoles in SOCSimulator Operations, free.
Glossary

What is Exfiltration? SOC Glossary

Data exfiltration is the unauthorized transfer of sensitive data out of a victim environment to attacker-controlled infr…

Read more
Glossary

What is DLP? SOC Glossary

Data Loss Prevention (DLP) is a set of technologies and policies that detect and prevent unauthorized transmission, stor…

Read more
Glossary

What is SIEM? SOC Glossary

Security Information and Event Management (SIEM) is a platform that aggregates, normalizes, and correlates log data from…

Read more
Glossary

What is Log Management? SOC Glossary

Log management is the process of collecting, normalizing, storing, retaining, and analyzing log data from across the IT …

Read more
Career Path

DFIR Analyst Career Guide: Salary & Skills

DFIR Analysts combine forensic investigation with incident response. You collect and analyze digital evidence from compr…

Read more
Career Path

Incident Responder Career Guide: Salary & Skills

Incident Responders lead the technical response when confirmed breaches happen. You coordinate containment, run forensic…

Read more
Tool

SIEM Training Console: SOCSimulator

The SIEM console in SOCSimulator replicates the workflow of enterprise platforms like Splunk Enterprise Security, Micros…

Read more
Tool

XDR Training Console: SOCSimulator

The XDR console in SOCSimulator replicates the investigation workflow of platforms like CrowdStrike Falcon, Microsoft De…

Read more
Comparison

SOCSimulator Vs. Letsdefend: Platform Comparison

SOCSimulator wins on operational realism. You get multi-tool shift simulation with SLA pressure, noise injection, and al…

Read more
Glossary

SOC Glossary: Security Operations Terminology

Complete glossary of Security Operations Center terminology for aspiring SOC analysts.

Read more
Feature

Shift Mode: Real-Time SOC Simulation

Practice alert triage under realistic time pressure with SLA timers and noise injection.

Read more
Feature

Operations: Guided Training Operations

Structured CTF-style investigation operations covering real-world attack scenarios.

Read more