What Is a Keylogger? Types, Detection and Real Defences
A keylogger records what you type. MITRE ATT&CK catalogues it as T1056.001, a sub-technique of Input Capture, serving both the Collection and Credential Access tactics on Windows, macOS, Linux and network devices. The uncomfortable part is ATT&CK's own assessment: the technique "cannot be easily mitigated with preventive controls", because capturing keystrokes uses features operating systems provide on purpose.
Topic: Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Explainer
Quick answer: A keylogger records what you type. MITRE ATT&CK catalogues it as T1056.001, a sub-technique of Input Capture, serving both the Collection and Credential Access tactics on Windows, macOS, Linux and network devices. The uncomfortable part is ATT&CK's own assessment: the technique "cannot be easily mitigated with preventive controls", because capturing keystrokes uses features operating systems provide on purpose. That is why the practical defence is not detection but making a stolen password insufficient.
Key takeaways
- ATT&CK T1056.001, a sub-technique of T1056 Input Capture, under Collection and Credential Access.
- It "cannot be easily mitigated with preventive controls", because it abuses legitimate operating system features.
- Hardware keyloggers sit between keyboard and computer and no software on the machine can see them.
- A phishing-resistant second factor makes a captured password far less useful, which is the control that actually works.
- If you suspect one on a machine that matters, rebuild it. Detection cannot prove absence.
Topics covered in this guide: what a keylogger is, the types including hardware and network devices, how they are installed, when they are lawful, how they are detected on each platform, why MFA changes the outcome, what to do if you suspect one, how they fit into larger attacks, and what organisations should do.
Table of Contents
- What Is a Keylogger?
- What Are the Main Types?
- How Do Keyloggers Get Installed?
- Are Keyloggers Always Illegal?
- How Can You Detect a Keylogger?
- Why Detection Is Not the Answer
- Why Does Multi-Factor Authentication Help?
- What Other Defences Work?
- What Should You Do If You Suspect One?
- How Do Keyloggers Fit Into Larger Attacks?
- What Should Organisations Do?
- References
What Is a Keylogger?
A keylogger records keystrokes. Most also capture context that makes the keystrokes useful: which application was focused, window titles, clipboard contents, and often screenshots, because a password is far more valuable when you know which site it was typed into.
MITRE ATT&CK catalogues this as technique T1056.001, Keylogging, a sub-technique of T1056, Input Capture. It is listed under two tactics, Collection and Credential Access, on Linux, Windows, macOS and network devices.
Those two tactics explain why it persists: the same capability serves espionage and account takeover, so it appears in both opportunistic crime and targeted intrusion.
What Are the Main Types?
ATT&CK describes several implementations, and they differ in what can detect them.
| Type | How it works | What can find it |
|---|---|---|
| API hooking | Hooks the callbacks that process keystroke data | Endpoint monitoring of hook APIs |
| Hardware buffer reading | Reads raw keystroke data from the hardware buffer | Harder; behavioural detection |
| Registry modification | Windows Registry changes to capture input | Registry monitoring |
| Custom driver | A kernel driver sees input before user space | Driver load monitoring |
| Network device firmware | Modified system image hooks the OS and reads keystrokes from login sessions | Image integrity verification |
| Physical hardware | A device between keyboard and computer | Nothing on the machine. Physical inspection only |
Two rows deserve emphasis because they are usually omitted.
Network devices. ATT&CK specifically covers modifying the system image of a router or switch to capture keystrokes from administrator login sessions. An organisation that scans endpoints thoroughly and never verifies network device images has a real blind spot, and the credentials captured there are administrative ones.
Hardware. A physical keylogger is invisible to every piece of software on the computer, because the operating system never sees it. The only detection is looking at the back of the machine, which is why this remains effective in shared and public environments.
How Do Keyloggers Get Installed?
- Bundled with other malware, as one module of a larger toolkit.
- Phishing attachments and downloads, the common route for consumer infections.
- Pirated or cracked software, where the user has already disabled protections to install it.
- Browser extensions with excessive permissions.
- Physical access, for hardware devices, which takes seconds.
- Legitimate monitoring software installed deliberately, which is the next section.
Are Keyloggers Always Illegal?
No, and the distinction is consent and authority rather than the technology. Employee monitoring software, parental controls and some corporate data-loss tools include keystroke logging and are sold openly.
What makes the same software unlawful is installing it on a device you do not own or administer, or without the authority to do so. In India, unauthorised access to a computer resource and capturing information from it engage the Information Technology Act, and employee monitoring also raises data protection and employment questions.
This article is general information rather than legal advice. If you are considering deploying monitoring software, take qualified advice on notification, policy and proportionality before you install anything, because the technical step is the easy part and the smallest part of the obligation.
How Can You Detect a Keylogger?
ATT&CK publishes a detection strategy, DET0089, "Behavioral Detection of Keylogging Activity Across Platforms", with different analytics per platform. The commands below follow that logic and let you check your own machine.
Windows. ATT&CK's analytic looks for suspicious use of keyboard-hook and polling APIs in non-UI service processes, especially alongside registry or driver changes.
# what starts automatically, and from where
Get-CimInstance Win32_StartupCommand |
Select-Object Name, Command, Location
# recently installed or non-Microsoft kernel drivers
Get-CimInstance Win32_SystemDriver |
Where-Object { $_.State -eq 'Running' } |
Select-Object Name, PathName | Sort-Object Name
# scheduled tasks that run something at logon
Get-ScheduledTask | Where-Object { $_.State -ne 'Disabled' } |
Select-Object TaskName, TaskPath
Linux. The analytic is non-system processes reading /dev/input/* or using ptrace or evdev syscalls to read keystroke buffers.
# which processes have an input device open? this is the key check
sudo lsof /dev/input/* 2>/dev/null
# anything attached to another process with ptrace
sudo cat /proc/*/status 2>/dev/null | grep -B5 'TracerPid:[^0]' | head -40
# user-level persistence
ls -la ~/.config/autostart/ /etc/xdg/autostart/ 2>/dev/null
crontab -l 2>/dev/null; systemctl --user list-unit-files --state=enabled
macOS. The analytic covers unauthorised TCC access and event tap creation through Quartz Event Services or IOHID in unexpected processes.
# which applications hold Accessibility and Input Monitoring rights
# System Settings > Privacy & Security > Accessibility
# System Settings > Privacy & Security > Input Monitoring
# a keylogger on macOS almost always needs one of these
launchctl list | grep -v com.apple
ls -la ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons
Network devices. Verify the running image against the vendor's published hash. ATT&CK's analytic for this platform is unauthorised system image changes.
Why Detection Is Not the Answer
This is the part most articles on the subject skip, and ATT&CK states it directly: the technique "cannot be easily mitigated with preventive controls", because it abuses legitimate system features.
Reading keyboard input is something operating systems are designed to allow. Accessibility software, input method editors, macro tools, remote desktop and screen readers all legitimately need it. There is no clean signature that separates them, which is why ATT&CK's detections are behavioural and probabilistic rather than definitive.
So the checks above are worth running and will find careless implants. They will not find a competent one, and a clean result does not mean the machine is clean. Any article that gives you a checklist and implies otherwise is misleading you.
That conclusion is useful rather than defeatist, because it points at the control that does work.
Why Does Multi-Factor Authentication Help?
Because it attacks the value of the captured data rather than the capture. A keylogger that records a password has recorded something that is no longer sufficient on its own.
With one qualification that matters here specifically: a one-time code is also typed, so it is also captured. A keylogger operator who is watching in real time can use it within its validity window. What defeats that is an authenticator the user does not type, such as a passkey or a hardware security key, where the secret never passes through the keyboard at all.
That is the single most effective response to this threat, and it is available today on most significant services. Our guides to MFA protocols and where MFA falls short cover the difference.
What Other Defences Work?
- A password manager that autofills. Credentials pasted or autofilled are not typed, so a pure keylogger does not see them. This also defeats phishing, because the manager will not fill a lookalike domain.
- Keep systems patched, which closes the installation routes.
- Restrict administrative rights, since drivers and system-wide hooks need them.
- Control browser extensions, which is an underrated route on managed fleets.
- Physically inspect shared machines, the only control for hardware devices.
- Verify network device images, for the ATT&CK case most organisations never check.
What Should You Do If You Suspect One?
- Stop typing credentials on that machine. Assume everything typed since the suspicion arose is known.
- Change passwords from a different device, never the suspect one, and revoke active sessions.
- Prioritise the email account, because it can reset the others.
- Check for persistence on the accounts: forwarding rules, linked applications, added MFA devices.
- Rebuild the machine rather than cleaning it, if it matters. Detection cannot prove absence, and a toolkit that installed a keylogger installed other things.
- Report it if money moved: in India, call 1930 and complete the portal complaint within 24 hours. Our guide to filing a cyber crime complaint covers it.
How Do Keyloggers Fit Into Larger Attacks?
A keylogger is rarely the objective. ATT&CK places it under Credential Access and Collection, which is to say it is a step: capture credentials, then use them to move somewhere that matters.
The usual sequence is initial access through phishing or a vulnerability, then a toolkit that includes keylogging alongside screenshot capture and clipboard monitoring, then use of the captured credentials to reach systems the original machine could not. This is why rebuilding matters: finding and removing the keylogger addresses one component of something larger. Our guide to malware types covers the toolkits it travels in.
What Should Organisations Do?
- Deploy phishing-resistant MFA, which is the control that survives a successful keylogger.
- Remove local administrator rights from ordinary accounts.
- Use endpoint detection that implements ATT&CK's behavioural analytics, rather than signature matching alone.
- Verify network device images against vendor hashes on a schedule.
- Ensure you have the logs to investigate. CERT-In requires entities to keep logs of all ICT systems "for a rolling period of 180 days", which is what makes an investigation possible at all.
- Rebuild rather than clean, and make that the written policy so the decision is not made under pressure.
Talk to a WebAsha training advisor about batches, syllabus and current fees.
References
- MITRE ATT&CK T1056.001, Keylogging
- MITRE ATT&CK T1056, Input Capture
- NIST SP 800-63B, Digital Identity Guidelines, revision 4
- CERT-In directions under section 70B(6) of the IT Act, 28 April 2022
Related reading
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0