![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
IRM Plc's Key Logging Research FindingsDownload a PDF of this whitepaper here Executive SummaryHardware keylogger technology poses a real risk to the confidentiality of data processed by PCs and other devices that utilise a keyboard. During this investigation a selection of common keyloggers were tested to discover if they could be detected after being introduced to a system. After extensive testing the following observations were made: Many keyloggers are shipped with default passwords, which, if not changed could result in keyloggers being detected by typing these passwords at the keyboard. However, the investigation was unable to discover any way to automate this process. Initially it was surmised that when the memory of keylogger devices was filled, recording would restart at the beginning, overwriting the previously recorded data. This appeared not to be the case for the devices tested. The KeyKatcher device stopped recording once the memory was full and the KeyGhost and Amecisco keyloggers overwrote data, but at the end of memory rather than the beginning. Furthermore, as the Amecisco keylogger recorded control commands such as those sent when a user presses the caps lock key, the device could be filled automatic al ly using software. The detection of devices using current and voltage measurements was also tested and it was discovered that the introduction of a keylogger typically results in an extra 10mA of current being drawn from the PC, which could easily be detected by a hardware-based detection solution. However, the current drawn and subsequent change in voltage could not be detected by embedded motherboard sensors. The investigation highlighted the difficulties associated with the detection of hardware-based keyloggers and therefore the following recommendations should be followed: Users should remain vigilant and report any unusual devices connected to their keyboards in addition to any spurious text that suddenly appears within one of their documents for no apparent reason (which would occur if a user unwittingly typed the keylogger password). Software-based keyboards could be used for the entry of sensitive information such as authentication credenti al s, which would result in the information not being recorded by a hardware keylogger. The most robust solution with respect to authentication systems would be the introduction of additional factors such as token-based devices, smartcards or biometric sensors. AbstractThis paper provides an analysis of how hardware-based keyloggers work and offers suggestions as to how they may be detected. In addition, active countermeasures are proposed that may be used to reduce the impact of keyloggers that may be installed but can not be detected. Due to limited available resources and timescales the research that resulted in this paper is not exhaustive, but the intention is to promote further research in this area, as little has been written on the subject previously. IntroductionThe recent high profile attack on the Japanese Bank, Sumitomo Mitsui and subsequent discovery that the attack utilised hardware keystroke logger (keylogger) technology has dramatic al ly increased interest by the banking community in this area of attack. Hardware Keyloggers OverviewThese are small (a few centimetres long) devices that are either inserted between the keyboard plug and the socket in the back of the computer or are embedded within the case of the keyboard. Commercial devices can store up to and in some cases in excess of two million keystrokes. The data is retrieved from the device by entering a user-selected password while the keyboard is connected to a computer and a text editor (such as Windows 'notepad') is running. The device releases the information into the text editor so that it can be saved into a file. Some companies, for example, Amecisco are now providing a service whereby they will install a hardware keylogger into any make of keyboard that is sent to them. Products TestedThere are a range of hardware-based keyloggers available; however, the following are considered to be among the market leaders and therefore those concentrated on in this assessment: • KeyKatcher (PS/2 external device) 1 • KeyGhost (PS/2 external device) 2 • Amecisco (Embedded) 3 How Does a PC Keyboard Work?To understand how to detect a keylogger, first it is important to have an understanding of how a PC keyboard works under norm al circumstances. A keyboard consists of a number of keys arranged in a matrix. The state of these keys (pressed, released or held down) is monitored by the 'keyboard encoder' (norm al ly based on the Intel 8048), which sends the appropriate data associated with key state to the PC 'keyboard controller' (based on the Intel 8042). This controller decodes the data received from the keyboard and translates the data into meaningful information about which key has been pressed. When a key state changes, a 'scan code' is generated by the keyboard encoder and sent to the controller, which is norm al ly embedded within the motherboard of the PC. There are two types of scan codes; 'make' (sent when a key is pressed or held down) and 'break' codes (sent when a key is released). The set of make and break codes for every key comprises a 'scan code set'. There are three standard scan code sets, named one, two, and three; however, most modern keyboards default to set two. Although the original keyboard controllers used the Intel 8042 device, newer PCs used compatible devices and the controller in the PC used for the tests performed during this investigation was an Intel 8742. 4 The Low Level Keyboard Command SetAs well as interpreting scancodes, the controller can al so send commands to the keyboard to modify certain characteristics or perform various diagnostic tests. The low level control of the keyboard controller can be accessed via Ports 0x60, 0x61 and 0x64 using Disk Operating System (DOS) ; an overview of how these can be used is provided in the tables below. This information was obtained from various low level keyboard programming resources on the Internet. 5 6 Port 0x60 This is used to issue commands to the keyboard and read scancodes and command responses back from the keyboard.
Table 1 - Summary of port 0x60 commands Port 0x61 This port is used to acknowledge that a scan code had been received. It does this by disabling and then immediately re-enabling the keyboard
Table 2 - Summary of port 0x61 commands Port 0x64 This port is used for data and status and control purposes:
Table 3 - Summary of port 0x64 commands How do Hardware Keyloggers Work?Essentially a hardware keylogger just taps into the data line within the keyboard cable and records all scancodes and control information sent between the keyboard and PC. For legal reasons, during this investigation no devices were reverse-engineered, as each of the manufacturers expressly prohibit any tampering with the devices. A section of the KeyKatcher user agreement is shown below: 'This license is limited to the rights above. Therefore, you are expressly prohibited from taking any other action with the Device, including but not limited to: a) modify, reverse engineer, de-compile or disassemble the Device or the Program; b) make any attempts to defeat the code protection which is in place on the internal microcontroller; c) make any attempts to read or copy the Program; d) attempt to cut open the casing around the Device;' As the commercial devices could not be reverse engineered to reveal the internals of a keylogger, an open source product has been used. The company Keelog.com provide instructions to build a DIY hardware keylogger on their web site 7 and they kindly allowed the details to be reproduced here. DIY Keylogger Parts ListThe following easily-available components are required in order to construct a DIY hardware keylogger:
DIY Keylogger Circuit Diagram - Figure 1 - DIY Keylogger circuit diagram
DIY Keylogger SoftwareThe software required to be programmed into the Atmel microcontroller is provided as source code 8 and software that will retrieve the captured keystrokes is available as an executable file 9 . The previous two sections have served to provide an overview of the technology and protocols associated with the use of keyboards under normal circumstances and with keylogger technology. The next stage is to identify areas of investigation based on this information that may reveal the presence of such a device from either a software or hardware perspective. Hardware Keylogger DetectioneThe keyboard protocol command set provides a great deal of scope for communication between the PC and the keyboard and therefore the possibility of anomalies introduced by keylogging hardware. Do keyloggers introduce anomalies in command responses?Software tools were created to send each known command to the keyboard and the responses were then recorded, both with and without the various keylogger attached. Examples of commands sent included:
Using these standard control commands there were no differences in the responses when keyloggers were introduced. Next tools were created to 'fuzz' the protocol. Fuzzing is a technique whereby every possible combination of control and data messages are constructed in order to test the responses when unusual combinations are used. However, again, there were no differences in any of the responses when keyloggers were present. Command Responses Timing Issues?Although the actu al responses from the keyboard were no different regardless of whether a keylogger was present, it was surmised that the addition al circuitry may introduce a delay. The previously written tools were therefore modified in order to identify if any timing differences could be detected in the responses when a keylogger was introduced. The timing routines used had a resolution of milliseconds; however, no consistent timing differences were observed. It may be the case that a time delay is introduced by keyloggers, but it was not possible to detect as it was so small. Emulating KeypressesOne of the commands available (0xd1, which is sent to port 0x64) enables keypresses to be emulated. The scancodes associated with the keypresses to be emulated are sent to port 0x60 after the 0xd1 command has been issued. The intention here was to be able to create software-generated keypresses so that a dictionary attack could be performed on a keylogger in order to gain access to the administration interface. Unfortunately, although the generated scancodes resulted in text being displayed on the screen, as they were generated by the keyboard controller the data never passed through the keyloggers and was therefore never interpreted or recorded by them. The Authentication Mechanism and Menu SystremsAll the tested keyloggers had a text-based administration interface, driven by a menu that was accessible by typing a password while a text editor was running. The keyloggers produce the interactive menu by generating scancodes that are sent to the keyboard controller (as if they were typed on the keyboard). Default PasswordsMany of the keyloggers tested were delivered with default passwords for the administration interface; these are listed in Table 4.
Table 4 - Summary of default passwords In the instruction manuals for each of the devices tested it explained that if the password was changed and subsequently forgotten then the devices would be rendered useless and would need to be returned to the manufacturer for reprogramming. Therefore, users may be inclined not to change the password from the default value. This information could be used in an incident response situation where a keylogger device has been discovered and the decision is made to attempt to gain access to discover what information has been recorded. Changing the Keylogger PasswordFor each of the devices examined the password was changed in order to attempt to deduce any information from the way the mechanism worked. The findings are detailed in Table 5. Table 5 - The password change process for each keylogger The only information that could be gleaned from the password change process was that the KeyGhost appeared to store the password in a different way to the others, as a full memory erasure was required when the password was changed. As the devices were required to be returned to the manufacturer if a password was forgotten, it was surmised that there may be a simple process that the manufacturer used to perform this technique. Hardware-based Password Reset SolutionsOne simple solution that could be employed to reset the password involves the use of the two spare pins on a PS/2 connector. Figure 2 details the pin allocations for PS/2 connectors:
Figure 2 - The PS/2 physical interface As can be seen, pins 2 and 6 are not implemented and could therefore be used as part of mechanism for resetting the password. The following tests were performed on the keyloggers tested:
However, none of the techniques resulted in the password being reset. Software-based Password Reset SolutionsAnother mechanism that could be employed to reset the password is a 'backdoor' system password that is hard-coded into the software. As these could be any difficult-to-guess key combination it was not surprising that no passwords of this nature were identified during the evaluation. The only definitive way to establish if hard-coded passwords were present would be to reverse-engineer the device and disassemble the system code, which, as explained earlier was not an option during this investigation. Memory LimitationsThe range of devices tested all had different memory capacities, but an area that was investigated was how each keylogger reacted once the memory had been filled. Potential responses may be as follows:
The actual responses of each keylogger when their memory was filled with data are shown in Table 6.
Table 6 - Summary of how keyloggers react once the memory is full The implications of these findings are that if a keylogger can be filled with data then it makes the process of identifying sensitive information such as passwords more difficult. Furthermore, if the device can be filled with meaningless data, generated by software, then an active keylogger mitigation process could be employed whereby every time a user logs off from their machine a process could be activated to fill any keylogger that was present with data that overwrites any sensitive information that may have been captured. The only way that a keylogger could be automatic al ly filled with data is if they stored control commands (which could easily be generated using software). Therefore each device was tested to discover if control information (such as changing the state of the scroll lock LED) was recorded. The results are shown in Table 7.
Table 7 - Summary of keyloggers control command recoding capabilities The results show that an active technique that overwrites memory with control commands could therefore be used to mitigate the presence of an Amecisco keylogger. Keylogger Detection using Voltage or Current MeasurementKeylogger devices are small electronic circuits, which need to draw power from the PC that they are connected to. Therefore, it should be possible to detect an increase in the current drawn from the PC power supply. Keyboard current MeasurementAn ammeter (a device that measures current) was placed inline between the keyboard and PC and measurements were taken with and without keyloggers. Although there is quite a large variation in the amount of current drawn by different brands of keyboard, by introducing the keyloggers the current drawn typically increased by approximately 10mA, which could easily be detected by the ammeter. Therefore, as keylogging hardware will always need to draw current to power the onboard circuitry, one solution could be a hardware device built into the PC motherboard. However, there would need to be a degree of intelligence in this device, as extra current is also drawn when users press the keys that result in LEDs being activated e.g. caps lock. PC Voltage MeasurementMany modern motherboards provide the facility to measure the voltage available to different elements of the system. Theoretically, any increase in current drawn may result in a drop in voltage, which could be measured and therefore indicate the introduction of a keylogger. The tool 'Motherboard Monitor 5' 10 was used to display the voltage measurements for the different elements of the test system, which used a Gigabyte GA-7N400L motherboard, as shown in Figure 3.
Figure 3 - A screenshot of Motherboard Monitor 5 Over a period of an hour the PC was used to perform a range of normal tasks that may or may not have affected the voltages. These tasks were: • Executing a range of programs (which generated hard disk activity) • Accessing the CDROM drive • Accessing the floppy drive • Using the keyboard and pressing keys such as caps lock During this period the voltages were recorded regularly. Once this 'control' state had been established the same process was repeated with each keylogger connected to the system and the results recorded. When the results were compared to the 'control' it was clear that no obvious voltage changes could be directly attributed to the introduction of a keylogger device. This was most likely due to the voltage changes being so small that they could not be detected by the motherboard sensors. References(1) KeyKatcher keylogger (2) KeyGhost keylogger (3) Amecisco keylogger (4) Intel 8742 Keyboard controller specification sheet http://www.intel.com/design/archives/periphrl/docs/29025601.pdf (5) Wout Mertens Guide to Keyboard Programming V1.1 http://www.osdever.net/documents/pdf/wout_kbd.pdf (6) The AT-PS/2 Keyboard Interface, Adam Chapweske http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html (7) The DIY Hardware Keylogger http://www.keelog.com/diy.html (8) Source code for the DIY Hardware Keylogger http://www.keelog.com/files/diy.asm (9) Retrieval Software for the DIY Hardware Keylogger http://www.keelog.com/files/keygrab.zip (10) Alex van Kaam's Motherboard Monitor 5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||