Keylogging is the capture of keystrokes to collect passwords, messages, commands, financial data, or other sensitive input. It can be implemented through user-mode API hooks, polling functions, browser or form manipulation, kernel drivers, hardware devices, remote-access tools, or compromised network equipment. Because the attacker may wait for valuable input, keylogging should be investigated as an identity incident as well as a malware incident.
Know what you are defending against
MITRE ATT&CK identifies keylogging as Input Capture sub-technique T1056.001 across Windows, macOS, Linux, and network devices. Software keyloggers may call operating-system input APIs, hook event processing, read raw buffers, install drivers, inject into processes, or write captured data to local files before exfiltration. Browser-based attacks can capture form input without observing the keyboard globally. Hardware keyloggers may sit between a keyboard and a computer or be embedded in a modified peripheral.
Legitimate software complicates detection. Accessibility tools, hotkey utilities, testing products, monitoring agents, and remote-support tools may observe input. The question is not simply whether an input API was used; it is whether the process, identity, destination, persistence, and business purpose are expected.
Reduce credential value and endpoint opportunity
Use phishing-resistant MFA and passkeys where possible. A keylogger can still capture typed information, but hardware-backed authentication reduces the value of a password alone. Protect privileged administration with separate accounts and hardened workstations, and avoid entering high-value credentials on general browsing devices. Use password managers to reduce typing, while recognizing that form capture, clipboard theft, or browser compromise may still expose secrets.
Apply operating-system and application updates promptly, restrict local administrator rights, enforce application control, and block untrusted drivers. Limit script interpreters and remote-access tools to approved users and systems. Protect endpoint-security controls against tampering, monitor USB and peripheral changes where risk warrants it, and physically inspect shared kiosks, point-of-sale systems, and sensitive workstations.
Detect behavior and storage
Alert on unusual processes calling keyboard-state or input-hooking APIs, unsigned drivers, injection into browsers or authentication processes, suspicious scheduled tasks, startup entries, and remote-access software outside inventory. Watch for frequent polling loops, hidden windows, new services, and files that accumulate structured keystroke data in temporary or user-profile directories.
Correlate with outbound traffic. A small encrypted upload from a new process, periodic beaconing, or connections to rare domains may be the exfiltration stage. Review process trees, module loads, file creation, registry or launch-agent persistence, driver installation, clipboard access, and browser extensions. On network appliances, changes to system images or management packages can create a keylogging path that endpoint tools cannot see.
User reports also matter: unexpected authentication prompts, security tools closing, unusual cursor behavior, or credentials abused shortly after being entered can provide the first clue. Do not ask a potentially affected user to type a password again for testing.
Respond as an identity compromise
Disconnect the suspected device from networks without powering it off if volatile evidence is needed. Preserve memory, running processes, network connections, loaded modules, drivers, persistence, relevant files, and endpoint telemetry. Photograph and retain suspicious hardware using an evidence process. Hunt for the same indicators and management activity across the fleet.
Identify which credentials and sensitive data may have been typed during the exposure window. From a known-good device, revoke sessions and tokens, rotate passwords and keys, and re-enroll strong authentication where necessary. Review account activity for lateral movement, mailbox rules, cloud changes, repository access, financial actions, and newly registered authenticators. If privileged credentials were entered, expand the scope to every system those credentials could reach.
Remove the malware only when the investigation establishes that cleanup is reliable; otherwise rebuild from trusted media and update firmware where relevant. Replace or quarantine suspicious peripherals. Validate the endpoint, identity, and downstream services before returning the device to use.
Measure the outcome
Closure requires more than deleting a file. Document the capture mechanism, persistence, first and last known activity, affected identities, data types, exfiltration path, rotated secrets, rebuilt systems, and remaining uncertainty. Improve controls that would have shortened detection or reduced credential value. MITRE’s Keylogging technique page provides the canonical behavior and procedure mapping for detection engineering and threat hunting.

