RP2040 USB Host Keylogger
A USB keyboard keylogger implementation for the Adafruit Feather RP2040 USB Host. The device acts as a man-in-the-middle (MitM) between a USB keyboard and a host computer, capturing keystrokes and storing them locally using LittleFS.
For educational, research, and authorized security testing purposes only.
Features
- USB keyboard interception using USB Host functionality
- Local keystroke storage via LittleFS
- Serial interface for log management
- Simple commands to dump or clear recorded data
- Automated Python log reader with raw/cleaned views
- Runs on Adafruit Feather RP2040 USB Host hardware
Hardware Requirements
- Adafruit Feather RP2040 USB Host
- USB keyboard
- USB connection to target system
- Arduino IDE v2.x
Software Requirements
Board Package
Install:
- Raspberry Pi Pico/RP2040/RP2350 by Earle F. Philhower, III
- Version: 5.6.0
Required Libraries
| Library | Version |
|---|---|
| Adafruit NeoPixel | 1.15.5 |
| Adafruit SPI Flash | 5.1.1 |
| Adafruit TinyUSB Library | 3.7.7 |
| MIDI Library | 3.7.7 |
| PICO PIO USB | 0.7.2 |
| SdFat (Adafruit Fork) | 2.3.103 |
Project Dependencies
usbh_helper.hLittleFS.hstring.h
Python Dependencies (for Log Reader)
pip install pyserial
Arduino IDE Configuration
Use the following settings:
| Setting | Value |
|---|---|
| Board | Adafruit Feather RP2040 USB Host |
| USB Stack | Adafruit TinyUSB |
| CPU Speed | 120 MHz, 240 MHz, or another frequency divisible by 12 |
| Flash Size | Allocate sufficient LittleFS space (recommended: 3 MB) |
| Port | Select the correct serial port |
Installation
- Clone or download the project.
- Open
keylogger.inoin Arduino IDE. - Install all required board packages and libraries.
- Configure the Arduino IDE according to the settings above.
- Compile and upload the firmware to the RP2040 device.
- (Optional) Install Python dependencies for the log reader:
pip install pyserial
Usage
Hardware Setup
Connect the device between a USB keyboard and the target system:
Keyboard
│
▼
RP2040 USB Host Keylogger
│
▼
Target Computer
Once powered, the device begins recording keyboard input.
Serial Commands (via Arduino Serial Monitor)
Open the Serial Monitor and use the following commands:
| Command | Description |
|---|---|
DUMP |
Display the contents of the keystroke log |
CLEAR |
Erase the stored log file |
Automated Log Reader (Python Script)
The included reader.py script provides an interactive menu for managing logs:
python3 reader.py
Features:
- Auto-detects RP2040 device (looks for "rp2040", "pico", "feather", or "tinyusb" in port description)
- Read Log (RAW): Displays the raw log output from the device
- Read Log (Cleaned): Processes the log to convert special key representations:
[BACKSPACE]→ removes previous character[SPACE]→ converts to actual space[TAB]and[ENTER]→ skipped
- Clear Log: Erases the stored log (with confirmation)
- Exit: Closes the connection
Storage
Captured keystrokes are stored locally using LittleFS.
The storage partition size depends on the flash configuration selected in the Arduino IDE. A dedicated LittleFS allocation of approximately 3 MB is recommended.
Log output uses markers for easy parsing:
Disclaimer
This software is intended solely for:
- Educational purposes
- Security research
- Authorized penetration testing
- Hardware experimentation
Users are responsible for complying with all applicable laws and regulations. Unauthorized monitoring, interception, or collection of keyboard input may be illegal in your jurisdiction.