Keystroke logging, often referred to askeylogging orkeyboard capturing, is the action of recording (logging) the keys struck on akeyboard,[1][2] typically covertly, so that a person using the keyboard is unaware that their actions are being monitored. Data can then be retrieved by the person operating the logging program. Akeystroke recorder orkeylogger can be eithersoftware orhardware.
While the programs themselves are legal,[3] with many designed to allow employers to oversee the use of their computers, keyloggers are most often used for stealing passwords and otherconfidential information.[4][5] Keystroke logging can also be utilized to monitor activities of children in schools or at home and by law enforcement officials to investigate malicious usage.[6]
In the mid-1970s, theSoviet Union developed and deployed a hardware keylogger targetingUS Embassytypewriters. Termed the "selectric bug", it transmitted the typed characters onIBM Selectric typewriters via magnetic detection of the mechanisms causing rotation of the print head.[8] An early keylogger was written byPerry Kivolowitz and posted to theUsenet newsgroup net.unix-wizards, net.sources on November 17, 1983.[9] The posting seems to be a motivating factor in restricting access to/dev/kmem onUnix systems. Theuser-mode program operated by locating and dumping character lists (clients) as they were assembled in the Unix kernel.
In the 1970s, spies installed keystroke loggers in theUS Embassy and Consulate buildings inMoscow.[10][11]They installed the bugs inSelectric II and Selectric III electric typewriters.[12]
Soviet embassies used manual typewriters, rather than electric typewriters, forclassified information—apparently because they are immune to such bugs.[12]As of 2013, Russian special services still use typewriters.[11][13][14]
A keylogger example of a screen capture, which holds potentially confidential and private information. The image below holds the corresponding keylogger text result.Alogfile from a software-based keylogger, based on the screen capture above
A software-based keylogger is a computer program designed to record any input from the keyboard.[15] Keyloggers are used inIT organizations to troubleshoot technical problems with computers and business networks. Families and businesspeople use keyloggers legally to monitor network usage without their users' direct knowledge.Microsoft publicly stated thatWindows 10 has a built-in keylogger in its final version "to improve typing and writing services".[16] However, malicious individuals can use keyloggers on public computers to steal passwords or credit card information. Most keyloggers are not stopped byHTTPS encryption because that only protectsdata in transit between computers; software-based keyloggers run on the affected user's computer, reading keyboard inputs directly as the user types.
From a technical perspective, there are several categories:
Hypervisor-based: The keylogger can theoretically reside in amalwarehypervisor running underneath the operating system, which thus remains untouched. It effectively becomes avirtual machine.Blue Pill is a conceptual example.
Kernel-based: A program on the machine obtainsroot access to hide in the OS and intercepts keystrokes that pass through the kernel. This method is difficult both to write and to combat. Such keyloggers reside at thekernel level, which makes them difficult to detect, especially for user-mode applications that do not have root access. They are frequently implemented asrootkits that subvert the operating system kernel to gain unauthorized access to the hardware. This makes them very powerful. A keylogger using this method can act as a keyboarddevice driver, for example, and thus gain access to any information typed on the keyboard as it goes to the operating system.
API-based: These keyloggershook keyboardAPIs inside a running application. The keylogger registers keystroke events as if it was a normal piece of the application instead of malware. The keylogger receives anevent each time the user presses or releases a key. The keylogger simply records it.
Windows APIs such asGetAsyncKeyState(),GetForegroundWindow(), etc. are used to poll the state of the keyboard or to subscribe to keyboard events.[17] A more recent[when?] example simply polls theBIOS for pre-boot authenticationPINs that have not been cleared from memory.[18]
Form grabbing based:Form grabbing-based keyloggers logWeb form submissions by recording the form data on submit events. This happens when the user completes a form and submits it, usually by clicking a button or pressing enter. This type of keylogger records form data before it is passed over the Internet.
JavaScript-based: A malicious script tag is injected into a targeted web page, and listens for key events such asonKeyUp(). Scripts can be injected via a variety of methods, includingcross-site scripting,man-in-the-browser,man-in-the-middle, or a compromise of the remote website.[19]
Memory-injection-based: Memory Injection (MitB)-based keyloggers perform their logging function by altering the memory tables associated with the browser and other system functions. By patching the memory tables or injecting directly into memory, this technique can be used by malware authors to bypass Windows UAC (User Account Control). TheZeus andSpyEye trojans use this method exclusively.[20] Non-Windows systems have protection mechanisms that allow access to locally recorded data from a remote location.[21] Remote communication may be achieved when one of these methods is used:
Data is uploaded to a website, database or anFTP server.
Data is periodically emailed to a pre-definedemail address.
Data iswirelessly transmitted employing an attached hardware system.
The software enables a remote login to the local machine from the Internet or the local network, for data logs stored on the target machine.
Since 2006, keystroke logging has been an established research method for the study of writing processes.[22][23] Different programs have been developed to collect online process data of writing activities,[24] includingInputlog, Scriptlog, Translog and GGXLog.
Keystroke logging is used legitimately as a suitable research instrument in several writing contexts. These include studies on cognitive writing processes, which include
descriptions of writing strategies; the writing development of children (with and without writing difficulties),
spelling,
first and second language writing, and
specialist skill areas such as translation and subtitling.
Keystroke logging can be used to research writing, specifically. It can also be integrated into educational domains for second language learning, programming skills, and typing skills.
Software keyloggers may be augmented with features that capture user information without relying on keyboard key presses as the sole input. Some of these features include:
Clipboard logging. Anything that has been copied to theclipboard can be captured by the program.
Screen logging.Screenshots are taken to capture graphics-based information. Applications with screen logging abilities may take screenshots of the whole screen, of just one application, or even just around the mouse cursor. They may take these screenshots periodically or in response to user behaviors (for example, when a user clicks the mouse). Screen logging can be used to capture data inputted with an on-screen keyboard.
Programmatically capturing the text in acontrol. TheMicrosoft WindowsAPI allows programs to request the text 'value' in some controls. This means that some passwords may be captured, even if they are hidden behind password masks (usually asterisks).[25]
The recording of every program/folder/window opened including a screenshot of every website visited.
Hardware-based keyloggers do not depend upon any software being installed as they exist at a hardware level in a computer system.
Firmware-based:BIOS-levelfirmware that handles keyboard events can be modified to record these events as they are processed. Physical and/orroot-level access is required to the machine, and the software loaded into the BIOS needs to be created for the specific hardware that it will be running on.[26]
Keyboard hardware: Hardware keyloggers are used for keystroke logging utilizing a hardware circuit that is attached somewhere in between thecomputer keyboard and the computer, typically inline with the keyboard's cable connector. There are alsoUSB connector-based hardware keyloggers, as well as ones for laptop computers (theMini-PCI card plugs into the expansion slot of a laptop). More stealthy implementations can be installed or built into standard keyboards so that no device is visible on the external cable. Both types log all keyboard activity to theirinternal memory, which can be subsequently accessed, for example, by typing in a secret key sequence. Hardware keyloggers do not require any software to be installed on a target user's computer, therefore not interfering with the computer's operation and less likely to be detected by software running on it. However, its physical presence may be detected if, for example, it is installed outside the case as an inline device between the computer and the keyboard. Some of these implementations can be controlled and monitored remotely using a wireless communication standard.[27]
Wireless keyboard and mousesniffers: These passive sniffers collect packets of data being transferred from a wireless keyboard and its receiver. As encryption may be used to secure the wireless communications between the two devices, this may need to be cracked beforehand if the transmissions are to be read. In some cases, this enables an attacker to type arbitrary commands into a victim's computer.[28]
Keyboard overlays: Criminals have been known to use keyboard overlays onATMs to capture people's PINs. Each keypress is registered by the keyboard of the ATM as well as the criminal's keypad that is placed over it. The device is designed to look like an integrated part of the machine so that bank customers are unaware of its presence.[29]
Acoustic keyloggers:Acoustic cryptanalysis can be used to monitor the sound created by someone typing on a computer. Each key on the keyboard makes a subtly different acoustic signature when struck. It is then possible to identify which keystroke signature relates to which keyboard character viastatistical methods such asfrequency analysis. The repetition frequency of similar acoustic keystroke signatures, the timings between different keyboard strokes and other context information such as the probable language in which the user is writing are used in this analysis to map sounds to letters.[30] A fairly long recording (1000 or more keystrokes) is required so that a large enoughsample is collected.[31]
Electromagnetic emissions: It is possible to capture theelectromagnetic emissions of a wired keyboard from up to 20 metres (66 ft) away, without being physically wired to it.[32] In 2009, Swiss researchers tested 11 differentUSB,PS/2 and laptop keyboards in a semi-anechoic chamber and found them all vulnerable, primarily because of the prohibitive cost of addingshielding during manufacture.[33] The researchers used a wide-bandreceiver to tune into the specific frequency of the emissions radiated from the keyboards.
Optical surveillance: Optical surveillance, while not a keylogger in the classical sense, is nonetheless an approach that can be used to capture passwords orPINs. A strategically placed camera, such as a hiddensurveillance camera at anATM, can allow a criminal to watch a PIN or password being entered.[34][35]
Physical evidence: For a keypad that is used only to enter a security code, the keys which are in actual use will have evidence of use from many fingerprints. A passcode of four digits, if the four digits in question are known, is reduced from 10,000 possibilities to just 24 possibilities (104 versus 4! [factorial of 4]). These could then be used on separate occasions for a manual "brute force attack".
Smartphone sensors: Researchers have demonstrated that it is possible to capture the keystrokes of nearby computer keyboards using only the commodityaccelerometer found in smartphones.[36] The attack is made possible by placing a smartphone near a keyboard on the same desk. The smartphone's accelerometer can then detect the vibrations created by typing on the keyboard and then translate this raw accelerometer signal into readable sentences with as much as 80 percent accuracy. The technique involves working through probability by detecting pairs of keystrokes, rather than individual keys. It models "keyboard events" in pairs and then works out whether the pair of keys pressed is on the left or the right side of the keyboard and whether they are close together or far apart on theQWERTY keyboard. Once it has worked this out, it compares the results to a preloaded dictionary where each word has been broken down in the same way.[37] Similar techniques have also been shown to be effective at capturing keystrokes on touchscreen keyboards[38][39][40] while in some cases, in combination withgyroscope[41][42] or with the ambient-light sensor.[43]
Body keyloggers: Body keyloggers track and analyze body movements to determine which keys were pressed. The attacker needs to be familiar with the keys layout of the tracked keyboard to correlate between body movements and keys position, although with a suitably large sample this can be deduced. Tracking audible signals of the user' interface (e.g. a sound the device produce to informs the user that a keystroke was logged) may reduce the complexity of the body keylogging algorithms, as it marks the moment at which a key was pressed.[44]
Writing simple software applications for keylogging can be trivial, and like any nefarious computer program, can be distributed as atrojan horse or as part of avirus. What is not trivial for an attacker, however, is installing a covert keystroke logger without getting caught and downloading data that has been logged without being traced. An attacker that manually connects to a host machine to download logged keystrokes risks being traced. A trojan that sends keylogged data to a fixed e-mail address orIP address risks exposing the attacker.
Researchers Adam Young and Moti Yung discussed several methods of sending keystroke logging. They presented a deniable password snatching attack in which the keystroke logging trojan is installed using a virus orworm. An attacker who is caught with the virus or worm can claim to be a victim. Thecryptotrojan asymmetrically encrypts the pilfered login/password pairs using thepublic key of the trojan author and covertly broadcasts the resultingciphertext. They mentioned that the ciphertext can besteganographically encoded and posted to a public bulletin board such asUsenet.[45][46]
In 2000, theFBI used FlashCrest iSpy to obtain thePGPpassphrase ofNicodemo Scarfo, Jr., son of mob bossNicodemo Scarfo.[47]Also in 2000, the FBI lured two suspected Russiancybercriminals to the US in an elaborate ruse, and captured their usernames and passwords with a keylogger that was covertly installed on a machine that they used to access their computers inRussia. The FBI then used these credentials to gain access to the suspects' computers in Russia to obtain evidence to prosecute them.[48]
The effectiveness of countermeasures varies because keyloggers use a variety of techniques to capture data and the countermeasure needs to be effective against the particular data capture technique. In the case of Windows 10 keylogging by Microsoft, changing certain privacy settings may disable it.[49] An on-screen keyboard will be effective against hardware keyloggers; transparency[clarification needed] will defeat some—but not all—screen loggers. Ananti-spyware application that can only disable hook-based keyloggers will be ineffective against kernel-based keyloggers.
Keylogger program authors may be able to update their program's code to adapt to countermeasures that have proven effective against it.
Ananti-keylogger is a piece ofsoftware specifically designed to detect keyloggers on a computer, typically comparing all files in the computer against a database of keyloggers, looking for similarities which might indicate the presence of a hidden keylogger. As anti-keyloggers have been designed specifically to detect keyloggers, they have the potential to be more effective than conventional antivirus software; some antivirus software do not consider keyloggers to be malware, as under some circumstances a keylogger can be considered a legitimate piece of software.[50]
Rebooting the computer using aLive CD or write-protectedLive USB is a possible countermeasure against software keyloggers if the CD is clean of malware and the operating system contained on it is secured and fully patched so that it cannot be infected as soon as it is started. Booting a different operating system does not impact the use of a hardware or BIOS based keylogger.
Manyanti-spyware applications can detect some software based keyloggers and quarantine, disable, or remove them. However, because many keylogging programs are legitimate pieces of software under some circumstances, anti-spyware often neglects to label keylogging programs as spyware or a virus. These applications can detect software-based keyloggers based on patterns inexecutable code,heuristics and keylogger behaviors (such as the use ofhooks and certainAPIs).
No software-based anti-spyware application can be 100% effective against all keyloggers.[51] Software-based anti-spyware cannot defeat non-software keyloggers (for example, hardware keyloggers attached to keyboards will always receive keystrokes before any software-based anti-spyware application).
The particular technique that the anti-spyware application uses will influence its potential effectiveness against software keyloggers. As a general rule, anti-spyware applications withhigher privileges will defeat keyloggers with lower privileges. For example, a hook-based anti-spyware application cannot defeat a kernel-based keylogger (as the keylogger will receive the keystroke messages before the anti-spyware application), but it could potentially defeat hook- and API-based keyloggers.
Network monitors (also known as reverse-firewalls) can be used to alert the user whenever an application attempts to make a network connection. This gives the user the chance to prevent the keylogger from "phoning home" with their typed information.
Automatic form-filling programs may prevent keylogging by removing the requirement for a user to type personal details and passwords using the keyboard.Form fillers are primarily designed forWeb browsers to fill in checkout pages and log users into their accounts. Once the user's account andcredit card information has been entered into the program, it will be automatically entered into forms without ever using the keyboard orclipboard, thereby reducing the possibility that private data is being recorded. However, someone with physical access to the machine may still be able to install software that can intercept this information elsewhere in the operating system or while in transit on the network. (Transport Layer Security (TLS) reduces the risk that data in transit may be intercepted bynetwork sniffers andproxy tools.)
Usingone-time passwords may prevent unauthorized access to an account which has had its login details exposed to an attacker via a keylogger, as each password is invalidated as soon as it is used. This solution may be useful for someone using a public computer. However, an attacker who has remote control over such a computer can simply wait for the victim to enter their credentials before performing unauthorized transactions on their behalf while their session is active.
Another common way to protect access codes from being stolen by keystroke loggers is by asking users to provide a few randomly selected characters from their authentication code. For example, they might be asked to enter the 2nd, 5th, and 8th characters. Even if someone is watching the user or using a keystroke logger, they would only get a few characters from the code without knowing their positions.[52]
Use ofsmart cards or othersecurity tokens may improve security againstreplay attacks in the face of a successful keylogging attack, as accessing protected information would require both the (hardware) security token as well as the appropriate password/passphrase. Knowing the keystrokes, mouse actions, display, clipboard, etc. used on one computer will not subsequently help an attacker gain access to the protected resource. Some security tokens work as a type of hardware-assisted one-time password system, and others implement a cryptographicchallenge–response authentication, which can improve security in a manner conceptually similar to one time passwords.Smartcard readers and their associated keypads forPIN entry may be vulnerable to keystroke logging through a so-calledsupply chain attack[53] where an attacker substitutes the card reader/PIN entry hardware for one which records the user's PIN.
Most on-screen keyboards (such as the on-screen keyboard that comes withWindows XP) send normal keyboard event messages to the external target program to type text. Software key loggers can log these typed characters sent from one program to another.[54]
Keystroke interference software is also available.[55]These programs attempt to trick keyloggers by introducing random keystrokes, although this simply results in the keylogger recording more information than it needs to. An attacker has the task of extracting the keystrokes of interest—the security of this mechanism, specifically how well it stands up tocryptanalysis, is unclear.
Similar to on-screen keyboards,speech-to-text conversion software can also be used against keyloggers, since there are no typing or mouse movements involved. The weakest point of using voice-recognition software may be how the software sends the recognized text to target software after the user's speech has been processed.
ManyPDAs and latelytablet PCs can already convert pen (also called stylus) movements on theirtouchscreens to computer understandable text successfully.Mouse gestures use this principle by using mouse movements instead of a stylus. Mouse gesture programs convert these strokes to user-definable actions, such as typing text. Similarly,graphics tablets andlight pens can be used to input these gestures, however, these are becoming less common.[timeframe?]
The same potential weakness of speech recognition applies to this technique as well.
With the help of many programs, a seemingly meaningless text can be expanded to a meaningful text and most of the time context-sensitively, e.g. "en.wikipedia.org" can be expanded when a web browser window has the focus. The biggest weakness of this technique is that these programs send their keystrokes directly to the target program. However, this can be overcome by usingthe 'alternating' technique described below, i.e. sending mouse clicks to non-responsive areas of the target program, sending meaningless keys, sending another mouse click to the target area (e.g. password field) and switching back-and-forth.
Alternating between typing the login credentials and typing characters somewhere else in the focus window[56] can cause a keylogger to record more information than it needs to, but this could be easily filtered out by an attacker. Similarly, a user can move their cursor using the mouse while typing, causing the logged keystrokes to be in the wrong order e.g., by typing a password beginning with the last letter and then using the mouse to move the cursor for each subsequent letter. Lastly, someone can also usecontext menus to remove,cut, copy, and paste parts of the typed text without using the keyboard. An attacker who can capture only parts of a password will have a largerkey space to attack if they choose to execute abrute-force attack.
Another very similar technique uses the fact that any selected text portion is replaced by the next key typed. e.g., if the password is "secret", one could type "s", then some dummy keys "asdf". These dummy characters could then be selected with the mouse, and the next character from the password "e" typed, which replaces the dummy characters "asdf".
These techniques assume incorrectly that keystroke logging software cannot directly monitor the clipboard, the selected text in a form, or take a screenshot every time a keystroke or mouse click occurs. They may, however, be effective against some hardware keyloggers.
^"Keylogger". Oxford dictionaries. Archived fromthe original on 2013-09-11. Retrieved2013-08-03.
^Keyloggers: How they work and how to detect them (Part 1),Secure List, "Today, keyloggers are mainly used to steal user data relating to various online payment systems, and virus writers are constantly writing new keylogger Trojans for this very purpose."
^K.P.H. Sullivan & E. Lindgren (Eds., 2006), Studies in Writing: Vol. 18. Computer Key-Stroke Logging and Writing: Methods and Applications. Oxford: Elsevier.
^V. W. Berninger (Ed., 2012), Past, present, and future contributions of cognitive writing research to cognitive psychology. New York/Sussex: Taylor & Francis.ISBN9781848729636
^Marquardt, Philip; Verma, Arunabh; Carter, Henry; Traynor, Patrick (2011).(sp)iPhone: decoding vibrations from nearby keyboards using mobile phone accelerometers. Proceedings of the 18th ACM conference on Computer and communications security. ACM. pp. 561–562.doi:10.1145/2046707.2046771.
^Owusu, Emmanuel; Han, Jun; Das, Sauvik; Perrig, Adrian; Zhang, Joy (2012).ACCessory: password inference using accelerometers on smartphones. Proceedings of the Thirteenth Workshop on Mobile Computing Systems and Applications. ACM.doi:10.1145/2162081.2162095.
^Aviv, Adam J.; Sapp, Benjamin; Blaze, Matt; Smith, Jonathan M. (2012). "Practicality of accelerometer side channels on smartphones".Proceedings of the 28th Annual Computer Security Applications Conference on - ACSAC '12. Proceedings of the 28th Annual Computer Security Applications Conference. ACM. p. 41.doi:10.1145/2420950.2420957.ISBN9781450313124.
^Xu, Zhi; Bai, Kun; Zhu, Sencun (2012).TapLogger: inferring user inputs on smartphone touchscreens using on-board motion sensors. Proceedings of the fifth ACM conference on Security and Privacy in Wireless and Mobile Networks. ACM. pp. 113–124.doi:10.1145/2185448.2185465.
^Miluzzo, Emiliano; Varshavsky, Alexander; Balakrishnan, Suhrid; Choudhury, Romit Roy (2012).Tapprints: your finger taps have fingerprints. Proceedings of the 10th international conference on Mobile systems, applications, and services. ACM. pp. 323–336.doi:10.1145/2307636.2307666.
^Spreitzer, Raphael (2014).PIN Skimming: Exploiting the Ambient-Light Sensor in Mobile Devices. Proceedings of the 4th ACM Workshop on Security and Privacy in Smartphones & Mobile Devices. ACM. pp. 51–62.arXiv:1405.3760.doi:10.1145/2666620.2666622.
^Hameiri, Paz (2019)."Body Keylogging".Hakin9 IT Security Magazine.14 (7):79–94.
^Young, Adam; Yung, Moti (1997). "Deniable password snatching: On the possibility of evasive electronic espionage".Proceedings. 1997 IEEE Symposium on Security and Privacy (Cat. No.97CB36097). pp. 224–235.doi:10.1109/SECPRI.1997.601339.ISBN978-0-8186-7828-8.S2CID14768587.