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.

Oct 11, 2026 - 07:29
Updated: 
107.3k

Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Explainer

What Is a Keylogger?

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?

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.

TypeHow it worksWhat can find it
API hookingHooks the callbacks that process keystroke dataEndpoint monitoring of hook APIs
Hardware buffer readingReads raw keystroke data from the hardware bufferHarder; behavioural detection
Registry modificationWindows Registry changes to capture inputRegistry monitoring
Custom driverA kernel driver sees input before user spaceDriver load monitoring
Network device firmwareModified system image hooks the OS and reads keystrokes from login sessionsImage integrity verification
Physical hardwareA device between keyboard and computerNothing 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?

  1. Stop typing credentials on that machine. Assume everything typed since the suspicion arose is known.
  2. Change passwords from a different device, never the suspect one, and revoke active sessions.
  3. Prioritise the email account, because it can reset the others.
  4. Check for persistence on the accounts: forwarding rules, linked applications, added MFA devices.
  5. Rebuild the machine rather than cleaning it, if it matters. Detection cannot prove absence, and a toolkit that installed a keylogger installed other things.
  6. 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

Frequently Asked Questions

Software or hardware that records keystrokes, usually alongside the application in focus, window titles and sometimes screenshots. MITRE ATT&CK catalogues it as T1056.001, a sub-technique of Input Capture, under Collection and Credential Access.

ATT&CK describes API hooking, reading raw data from the hardware buffer, Windows Registry modification, custom drivers, and modified network device firmware that captures administrator login sessions. Physical hardware keyloggers are a separate category entirely.

Sometimes, and not reliably. ATT&CK states the technique "cannot be easily mitigated with preventive controls" because it abuses features operating systems provide deliberately, which is why its own detections are behavioural rather than definitive.

No. A physical device between the keyboard and the computer is invisible to everything running on the machine, because the operating system never sees it. The only detection is physical inspection.

ATT&CK’s analytic is non-system processes reading /dev/input/* or using ptrace or evdev syscalls. Run sudo lsof /dev/input/* to see which processes have an input device open, and check autostart directories, cron and user systemd units for persistence.

Review which applications hold Accessibility and Input Monitoring permissions in System Settings, because a keylogger on macOS almost always needs one. ATT&CK also covers event tap creation through Quartz Event Services or IOHID in unexpected processes.

It makes the captured password insufficient, which is the main benefit. A one-time code is also typed and so also captured, so the factor that genuinely helps is one you do not type, such as a passkey or hardware security key.

Yes, because autofilled credentials are not typed and a pure keylogger does not see them. It also refuses to fill a lookalike domain, which defeats the phishing that often delivers the keylogger in the first place.

Not inherently. Employee monitoring and parental control products include the capability and are sold openly. What makes it unlawful is installing it on a device you do not own or administer, or without authority, which engages the Information Technology Act in India.

Rebuild, if the machine matters. Detection cannot prove absence, and a toolkit that installed a keylogger will usually have installed other components alongside it.

Yes, and it is the case most organisations never check. ATT&CK covers modifying the system image of a network device to hook the operating system and read raw keystrokes from login sessions, which captures administrator credentials.

Stop typing credentials on that machine, then change passwords from a different device and revoke active sessions, starting with email because it can reset everything else. Assume anything typed since the suspicion arose is known.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Anjali

I am passionate about technology, invention and big challenging tasks on my to- do list. In terms of the work I am doing also at Bunnyshell, I am most passionate about the technologies that we are using., I'm devoted to delivering content that not only informs but also inspires. Whether you need in- depth analysis pieces, educational attendants, or study- provoking opinion pieces, I draft content that resonates with tech suckers and professionals likewise.