Detecting Hardware Keyloggers. Fabian Mihailowitsch November 26, 2010



Similar documents
Hardware Keylogger Detection. Andy Davis. Research and Development Manager

USB 4 MB / 2 GB PS/2 4 MB / 2 GB

IRON-HID: Create your own bad USB. Seunghun Han

Learning USB by Doing.

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

GEIGER COUNTER "Gamma Check Pro"

Appendix C: Keyboard Scan Codes

Project 4: Pseudo USB Simulation Introduction to UNIVERSAL SERIAL BUS (USB) STANDARD

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

UMBC. ISA is the oldest of all these and today s computers still have a ISA bus interface. in form of an ISA slot (connection) on the main board.

F2103 GPRS DTU USER MANUAL

An Analysis of Wireless Device Implementations on Universal Serial Bus

USB2.0 <=> I2C V4.4. Konverter Kabel und Box mit Galvanischetrennung

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

Network Threats and Vulnerabilities. Ed Crowley

PC Notebook Diagnostic Card

MCB3101 (Class I) WiRobot Serial Bluetooth Wireless Module User Manual

USER GUIDE EDBG. Description

Welcome to the Introduction to Controller Area Network web seminar My name is William Stuart, and I am a Applications Engineer for the Automotive

Computer Systems Structure Input/Output

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

CENTRONICS interface and Parallel Printer Port LPT

EZ-View Network Communications Guide

1. Computer System Structure and Components

Mastertech Diagnostic Software Frequently Asked Questions

VASCO Data Security International, Inc. DIGIPASS GO-7. FIPS Non-Proprietary Cryptographic Module Security Policy

TOE2-IP FTP Server Demo Reference Design Manual Rev1.0 9-Jan-15

SNMP-1 Configuration Guide

MACHINE ARCHITECTURE & LANGUAGE

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Designing VM2 Application Boards

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

RS-485 Protocol Manual

A DIY Hardware Packet Sniffer

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

User Manual. AS-Interface Programmer

The irnetbox Manager User Guide

Performance monitoring with Intel Architecture

Advantech WebAccess Device Driver Guide. BwSNMP Advantech WebAccess to SNMP Agent (Simple Network Management Protocol) Device Driver Guide

INPUT/OUTPUT ORGANIZATION

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

Old Company Name in Catalogs and Other Documents

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

Smart Cards a(s) Safety Critical Systems

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

BLUETOOTH SERIAL PORT PROFILE. iwrap APPLICATION NOTE

Designing a USB Keyboard and PS/2 Mouse Combination Device Using the Cypress Semiconductor CY7C63413 USB Microcontroller

Computer Setup (F10) Utility Guide HP Compaq dx2200 Microtower Business PC

E21 Mobile Users Guide

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

UMI (Universal Metering Interface)

Axia IP-Audio Driver Update v June, 2013

TCP/IP MODULE CA-ETHR-A INSTALLATION MANUAL

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Chapter 13. PIC Family Microcontroller

Chapter 11: Input/Output Organisation. Lesson 06: Programmed IO

User s Guide. KeyLlama PS/2 KeyLlama PS/2 Forensic. with USB Download Accelerator. Page. Introduction. Recording

User Manual Software for DSL Digital Speed Switch

Nemo 96HD/HD+ MODBUS

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

AliOffice 2.0 Installation Guide

IX Support Tool Setting Manual

OpenBSD s New Suspend and Resume Framework

Linux Driver Devices. Why, When, Which, How?

MONITORING PERFORMANCE IN WINDOWS 7

ENTTEC Pixie Driver API Specification

Firmware version: 1.10 Issue: 7 AUTODIALER GD30.2. Instruction Manual

PNOZmulti Configurator V8.1.1

Network Traffic Analysis

INTRODUCTION FEATURES OF THE ICM

Application Note AN_209. AN_209 PDIUSBD12 to FT120 Migration Guide

The Lagopus SDN Software Switch. 3.1 SDN and OpenFlow. 3. Cloud Computing Technology

COS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware

Using the JNIOR with the GDC Digital Cinema Server. Last Updated November 30, 2012

User Guide for Windows 10

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Installation Guide for LynxClient

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

PRT3 Printer Module: ASCII Protocol Programming Instructions

Track 2 Workshop PacNOG 7 American Samoa. Firewalling and NAT

4 Character 5x7 LED Matrix Display

How to design and implement firmware for embedded systems

ENTBUS PLUS SOFTWARE FOR ENERGY MONITORING AND RECORDING INSTALLATION AND OPERATING MANUAL

Type Message Description Probable Cause Suggested Action. Fan in the system is not functioning or room temperature

Timeout The Crosspoint Status Request message has a timeout, which means that you need to wait 1 second in between request messages.

Next Generation ETS Software A preview of the upcoming new ETS5 system & user enhancements. KNX Association, Brussels André Hänel

How To Set Up An Ip Firewall On Linux With Iptables (For Ubuntu) And Iptable (For Windows)

BIOS Update Release Notes

SX-3000EDM Integration Guide

Pen Drive to Pen Drive and Mobile Data Transfer Using ARM

Network Licensing. White Paper 0-15Apr014ks(WP02_Network) Network Licensing with the CRYPTO-BOX. White Paper

Avalanche Site Edition

Getting Started with the Xilinx Zynq All Programmable SoC Mini-ITX Development Kit

ValveLink Mobile Software

Transcription:

Detecting Hardware Keyloggers Fabian Mihailowitsch November 26, 2010

Who? Fabian Mihailowitsch Former Software Developer German energy combine IT-Security Consultant cirosec GmbH Penetration Tests Source Code Reviews Contact Email: fm@cirosec.de www.cirosec.de 2 of 49

What? Hardware Keylogger PS/2 USB Hardware Keyloggers are undetectable by Software Visual inspection is the primary means of detecting hardware keyloggers, since there are no known methods of detecting them through software., en.wikipedia.org, 05.11.10 Talk: Detection of Hardware Keyloggers with Software ;) 3 of 49

Why? Less research on this topic Few information No practical way to detect HKL Because HKL are a threat 2005 (GB): Sumitomo Bank Attackers tried to steal 423 million USD Multiple HKL were installed How about your company? Solution to identify HKL in large enterprises Visual inspection is impractical Only possible via software 4 of 49

Hardware Keylogger Hardware Keylogger USB PS/2 Keyboard Module Mini- / PCI card Installed between PC and Keyboard Records key strokes Captured data are retrieved Software Keyboard Ghost typing Flash drive Wi-Fi-Access Email TCP connect Bluetooth 5 of 49

Hardware Keylogger Features Up to 2 GB flash memory Encryption Password protection Timestamping Time use charts Search functions Upgradeable firmware Pricing PS/2: 32.00 USD USB: 58.00 USD 6 of 49

Hardware Keylogger The companies Big ones KeyDemon, KeeLog, (PL) KeyCarbon (US) Most companies rebrand KeyDemon KeyCobra KeyLlama (once own products) Also famous (older products) KEYKatcher (US) KeyGhost (NZ) KeyShark (DE) The others WirelessKeylogger (UK) Exotic Stuff (mostly CN) Some Open Source Keylogger 7 of 49

PS/2 How does it work Keyboard Wire matrix Microcontroller Sends scancode (make/break) PC Keyboard Controller (KBC) 0x60: I/O-Buffer 0x64: Status 8 of 49

PS/2 How does it work Communication KBC <-> Keyboard Obvious Scancodes Not that obvious ;) Set LEDs Choose scancode Set repeate rate Keyboard self-test / reset Ping Example (Ping) KBC sends "ping" (0xEE) via 0x60 KB sends "pong" (0xEE) to 0x60 9 of 49

PS/2 How does it work PS/2 is a serial interface Communication DATA CLK Bidirectional Keyboard defines clock (30 50 ns) 1. DATA 2. - 3. GND 4. VCC 5. CLCK 6. - Data frames KB (11 bit): startbit, D0-D7 [data], odd parity, stopbit KBC (12 bit): startbit, D0-D7 [data], odd parity, stopbit, ACK (KB) 10 of 49

PS/2 How does it work PS/2 is a serial interface Communication DATA CLK Bidirectional Keyboard defines clock (30 50 ns) 1. DATA 2. - 3. GND 4. VCC 5. CLCK 6. - 11 of 49

Detecting PS/2 Hardware Keylogger Current measurement Additional electronic components = Additional power consumption ;) KeyDemon = 65 ma KeyKatcher = 54 ma More current is drawn Cannot be measured by software 12 of 49

Detecting PS/2 Hardware Keylogger Keylogger are password protected Entered via Keyboard Ghost typing Shipped with default password Password restore is complex Brute Force password Via software Check ghost typing 13 of 49

Detecting PS/2 Hardware Keylogger Problem Tested HKL don t tap the data line HKL are placed inline HKL Keyboard Data Data PC Clock Microprocessor Clock HKL knows the data flow KBC can t send fake keystrokes 14 of 49

Detecting PS/2 Hardware Keylogger However Some KB commands (0x60) lead to fake key presses Maybe keyboard response is interpreted Brute Force password Translation Table (KB command -> key press) Brute Force attack via Software Practical? Limited amount of chars (~10) Not all passwords can be Brute Forced Works for: KeyGhost, KEYKatcher (some) 15 of 49

Detecting PS/2 Hardware Keylogger Demo 16 of 49

Detecting PS/2 Hardware Keylogger Changes on the line HKL are placed inline HKL might change signals on the line Different signals (data) Own clock (30-50 ns) Slight dislocation of data/clock signal Maybe more ;) 17 of 49

Detecting PS/2 Hardware Keylogger Analyze the data flow Tap signal at the keyboard Tap signal after the keylogger 18 of 49

Detecting PS/2 Hardware Keylogger Result: Keylogger Keyboard 19 of 49

Detecting PS/2 Hardware Keylogger Clock is set to low Delay of the HKL Keylogger Delay Keyboard 20 of 49

Detecting PS/2 Hardware Keylogger Clock is set to high Same timing 21 of 49

Detecting PS/2 Hardware Keylogger Clock cycles are shorter for HKL Probably HKL generates own clock signal Can be detected on the wire No possibility to detect via software Exact clock state cannot be retrieved by KBC But the clock signal starts later Remember when clock was pulled low HKL might cause a delay on the wire 22 of 49

Detecting PS/2 Hardware Keylogger Time Measurement Tested HKL were placed inline Microprocessor has to analyze the signal and pass it on This additional logic increase signal propagation time Data signal (begin) Data signal (end) 23 of 49

Detecting PS/2 Hardware Keylogger Time Measurement Tested HKL were placed inline Microprocessor has to analyze the signal and pass it on This additional logic increase signal propagation time Delay 24 of 49

Detecting PS/2 Hardware Keylogger Basic idea Send command to KB, wait for response and measure run time Like a ping _start: _wait1: _wait2: xor %ecx, %ecx mov $0x9999, %cx in $0x60, %al xor %eax, %eax in $0x64, %al test $0x2, %al jne _wait1 mov $0xF2, %al out %al, $0x60 xor %eax, %eax in $0x60, %al cmp $0xFA, %al jne _wait2 loop _wait1 ret Repeat 9999x: Send Identify Keyboard (0xF2) Wait until Keyboard responds with MF-II (0xFA) 25 of 49

Detecting PS/2 Hardware Keylogger Delay introduced by the HKL is very (!) small Previous code can t be used in normal OS state scheduler, interrupts, Measurement isn t exact enough Code must run exclusively Get the most accurate measurement 26 of 49

Detecting PS/2 Hardware Keylogger Solution Loadable Kernel Module Get CPU exclusively Deactivate interrupts for processor Disable kernel preemption SMP locking Run ASM code ( ping ) Measure runtime of the code Interrupts are disabled Read processors time stamp counter (rdtsc) Counter is increased every clock cycle Use the number of clock cycles Restore everything and write result to kernel message buffer 27 of 49

Detecting PS/2 Hardware Keylogger Time Measurement Results Setup Clock cycles Keyboard 338 1 03523280 KeyGhost 338 5 62656160 KeyKatcher Mini 338 6 25304965 KeyKatcher Magnum 338 4 21058298 Inline HKL can be detected using Time Measurement Measure without HKL Define Baseline (e.g 338200000000) Measure again Win ;) 28 of 49

Defeat PS/2 Hardware Keylogger Fill Keylogger memory via software Some stop logging Some overwrite memory at the beginning Keystrokes are overwritten / not recorded Keyboard commands Some commands lead to fake keypress (see Brute Force) Send those repeatedly ~100 logged keys in 10s 109 minutes to fill 64kB Keyboard command 0xFE Resend Keyboard responds by resending the last-sent byte ~ 4 logged keys in 10 s Practical? Most PS/2 HKL have a few KBytes memory Nevertheless takes too much time Works for: KeyGhost, KEYKatcher (some) 29 of 49

Defeat PS/2 Hardware Keylogger Stop HKL from sniffing keystrokes Keyboard sends scancodes Make / Break codes Defined in scan code set Scan codes set can be choosen via KB command 0xF0 3 scancode sets 1: XT keyboards 2: MF2 keyboard 3: AT keyboads Tested Keyloggers support scancode set 2 and 3 Choose scancode set 1 Keylogger doesn t log correctly Logs can t be used New mapping scancode <-> keycode is necessary for OS hdev HAL setkeycode 30 of 49

USB How does it work Host controller + Hubs + devices build tree structure Device has various endpoints Buffer in / out Configuration via endpoint 0 Low Speed devices (Keyboard): endpoint 0 + 2 endpoints with 8 Bytes Only host controller manages communication with devices Polls buffer (device configuration) Writes buffer Data are transferred as packets Data transfer types Isochronous transfer (guaranteed data rate, no error correction) Interrupt transfer (small amount of data, retransmission) Bulk transfer (big amount of data, retransmission) Control transfer (device configuration, ACKed in both directions) 31 of 49

USB How does it work Different device classes Plug and Play Relevant: HID class Defines communication KB sends 8 Byte input report Interrupt Transfer Periodically polled by host Contains pressed keys No make / break codes Packet: Modifier keys OEM use Keycode Keycode Keycode Keycode Keycode Keycode Byte 0 Byte 7 32 of 49

USB How does it work PC sends 1 Byte output report USB Control Transfer Control LEDs Packet: NUM Lock Caps Lock Scroll Lock Compose KANA Constant Constant Constant Bit 0 Bit 7 No addtional KB commands Transfer handeld via USB Typematic rate, etc. configured on PC 33 of 49

Detecting USB Hardware Keylogger Current Measurement Like PS/2 More current is drawn Cannot be measured by software Device configuration contains current However no accurate information available 34 of 49

Detecting USB Hardware Keylogger Brute Force KL password KeyCarbon: software to retrieve keystrokes 35 of 49

Detecting USB Hardware Keylogger Brute Force KL password KeyCarbon: software to retrieve keystrokes Software needs to communicate with KL USB sniffer: 36 of 49

Detecting USB Hardware Keylogger Software needs to communicate with KL 1 Byte output reports (set LEDs) Fixed header + HKL password + footer Password char is encoded with 4 Bytes Brute Force (default) passwords Create Lookup Table for PW chars Perform attack via software Works for: KeyCarbon models 37 of 49

Detecting USB Hardware Keylogger Changes to USB Properties / Topology Keyboard only: 38 of 49

Detecting USB Hardware Keylogger Changes to USB Properties / Topology Keyboard + KeyCarbon: 39 of 49

Detecting USB Hardware Keylogger Changes to USB Properties / Topology Addtional USB HUB if KeyCarbon is present Why is the device undetectable, in practice, by software? The device shows up in Windows Device Manager as a generic USB hub. This generic USB hub has no ID strings, and is indistinguishable from the generic USB hub found in 90% of all USB hubs. Well USB HUB Controller used: Texas Instruments (TUSB2046B) 40 of 49

Detecting USB Hardware Keylogger Changes to USB Properties / Topology KeyGhost changes device properties USB Speed Keyboard: KeyGhost: Device Status Keyboard : KeyGhost : More details later bmaxpacketsize0 08 / Speed: Low bmaxpacketsize0 64 / Speed: Full Bus Powered (0x0000) Self Powered (0x0001) 41 of 49

Detecting USB Hardware Keylogger Time Measurement Like PS/2 HKL are placed inline -> introduces a delay Keylogger Delay Keyboard 42 of 49

Detecting USB Hardware Keylogger Time Measurement Basically the same idea like for PS/2 Has to be adjusted for USB PC can send 1 Byte output report to KB (LED) sent as Control-Transfer Control-Transfer are ACKed Like PS/2 ping Can be used for runtime measurement ;) Implementation Send output report to KB Wait until ACKed Do it various times (10.000) Measure runtime Measurement can be performed from userland e.g. libusb 43 of 49

Detecting USB Hardware Keylogger Time Measurement Results Setup Milliseconds Keyboard 40034 KeyGhost 56331 KeyCarbon 43137 USB HKL can be detected using Time Measurement Create baseline for default setup (HUBs, etc.) Measure again Win ;) 44 of 49

Detecting USB Hardware Keylogger Different keyboard behaviour Normal behaviour: Interrupt read (8 Byte): \x81\x06\x00\x22\x00\x00\x00\x04 Send USB Reset Interrupt read (8 Byte): \x00\x00\x00\x00\x00\x00\x00\x00 KeyGhost behaviour: Interrupt read (8 Byte): \x81\x06\x00\x22\x00\x00\x00\x04 Send USB Reset Interrupt read (8 Byte): \x81\x06\x00\x22\x00\x00\x00\x04 45 of 49

Detecting USB Hardware Keylogger Different keyboard behaviour Analysis on the wire Reason: keyboard never receives USB Reset Before Keylogger After Keylogger USB Reset (D-/D+ pulled low) 46 of 49

Detecting USB Hardware Keylogger Keyboard never receives USB Reset USB single-chip host and device controller (ISP1161A1BD) Acts as Device for PC (causes changes to device properties) Acts as Host Controller for KB Behaviour can be tested via software e.g. libusb Note: Time Measurement for this design bug is possible too 47 of 49

Conclusion PS/2 USB All tested models were placed inline Time Measurement as general technique to detect them Scancode 1 as general technique to defeat them Detection via USB behaviour (USB speed, etc.) Individual bugs More research to come All tested HKL contained bugs that can be used to detect them Generic and individual bugs Each HKL has to be analyzed seperately Bugs can be combined (Pattern) PoC code Soon: https://code.google.com/p/hkd/ 48 of 49

Thank you for your interest! Questions and Feedback 49 of 49