Skip to content

Commit

Permalink
v5
Browse files Browse the repository at this point in the history
  • Loading branch information
therealdreg committed Jan 5, 2025
1 parent 1e70ed6 commit 99cf5f8
Show file tree
Hide file tree
Showing 7 changed files with 3,319 additions and 3,277 deletions.
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# USB sniffer for RASPBERRY PI PICO RP2040

This is a simple USB sniffer based on a Raspberry Pi PICO RP2040. It supports Low Speed and Full Speed modes.
This is a simple USB sniffer based on a Raspberry Pi PICO RP2040 (pico-sdk). It supports Low Speed and Full Speed modes.

![](stuff/keylogsetp.jpg)

The firmware presents itself as a virtual COM-port (VCP), so no additional software is necessary and it is compatible with all operating systems.

This is the Dreg's fork of the original project by Alex Taradov, which can be found:
https://github.com/therealdreg/pico-usb-sniffer-lite
This is the Dreg's fork of the original baremetal project by Alex Taradov, which can be found:
https://github.com/ataradov/usb-sniffer-lite

I have ported everything (PIO+SRC) to pico-sdk and made some changes. It won't be exactly the same as the bare-metal version.

I created this project to ensure that all the effort I put into my okhi project (Open Keylogger Hardware Implant - USB & PS2 Keyboards) can benefit more people: https://github.com/therealdreg/okhi

Expand All @@ -19,6 +21,10 @@ Download the latest firmware from the releases section:

https://github.com/therealdreg/pico-usb-sniffer-lite/releases/latest

# Flashing the firmware

To flash the firmware, you need to put the Raspberry Pi Pico in bootloader mode. To do this, press and hold the button while connecting the USB cable to the PC. The Pico will appear as a USB mass storage device. Drag and drop the "pico_usb_sniffer_lite.uf2" firmware file to the Pico.

# Physical USB keylogger using a Raspberry Pi Pico

As an example, let's see how to make a physical USB keylogger without soldering anything. You only need a RASPBERRY PI PICO and some materials.
Expand Down Expand Up @@ -77,11 +83,13 @@ Connect to the USB board:

Finally, connect everything to the PC, and you're done!

WARNING: some USB Hubs can cause problems with this setup. If you have problems, try connecting ALL directly to the PC.
**WARNING**: some USB Hubs can cause problems with this setup. If you have problems, try connecting ALL directly to the PC.

**WARNING**: Use short cables to avoid signal degradation (USB & Dupont). Avoid stack adapters, etc.

## Inspecting USB low speed traffic

Connect to serial PORT (COM PORT) with a terminal program (like Putty, Tera Term, etc.), por conf:
Connect to serial PORT (COM PORT) with a terminal program (like Putty, Tera Term, etc.), port conf:
- 9600 bauds
- data 8 bits
- parity none
Expand Down Expand Up @@ -200,6 +208,8 @@ enabled in the settings, the capture would pause until the trigger pin is pulled
Given the limited size of the capture buffer, trigger mechanism provides a way for
the debugged target to mark the part of interest.

**WARNING**: This project uses different GPIOs than the original project by Alex Taradov because okhi uses these GPIOs.

# Examples

Here are a couple of example capture logs for the [enumeration](stuff/usb_fs_enumeration.txt) and a regular [data transfer](stuff/usb_fs_data.txt).
Expand Down Expand Up @@ -242,6 +252,19 @@ number of packets. After the capture is done, the buffer is displayed using curr
The display settings may be adjusted without a new capture. Once the buffer is captured,
it is stored in the memory and can be displayed again using a `b` command.

# Learn resources

- https://www.usbmadesimple.co.uk/
- https://www.beyondlogic.org/usbnutshell/usb1.shtml
- https://forums.raspberrypi.com/
- https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
- https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf
- https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
- https://github.com/therealdreg/okhi/blob/main/stuff/USB_doc.pdf
- https://www.eevblog.com/forum/projects/usb-sniffer-using-rp2040/
- https://www.eevblog.com/forum/projects/pico-usb-sniffer-lite/
- https://forums.raspberrypi.com/viewtopic.php?p=2283134#p2283134

# Developers

Instructions for building & debugging the firmware step-by-step can be found in the okhi repository:
Expand All @@ -251,6 +274,14 @@ https://github.com/therealdreg/okhi?tab=readme-ov-file#developers-setup

# CHANGELOG

## v5 2025-01-05

- print BUILD DATE
- more DOC
- TIME implemented
- CDC reset connection on main for SWD programming
- minor & cosmetic changes

## v3 2025-01-05

Ported & adapted, but not strictly 100% equal to the original
Expand Down
10 changes: 0 additions & 10 deletions firmware/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@
},
"cmake.generator": "Ninja",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"files.associations": {
"pll.h": "c",
"clocks.h": "c",
"uart.h": "c",
"string.h": "c",
"cstdlib": "c",
"bootrom.h": "c",
"pico_usb_sniffer_lite.pio.h": "c",
"timer.h": "c",
},
"files.trimTrailingWhitespace": true,
"editor.insertSpaces": true,
"editor.tabSize": 4,
Expand Down
13 changes: 4 additions & 9 deletions firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ add_executable(pico_usb_sniffer_lite
)

# pull in common dependencies
target_link_libraries(pico_usb_sniffer_lite
pico_stdlib
pico_multicore
target_link_libraries(pico_usb_sniffer_lite
pico_stdlib
pico_multicore
hardware_pio)

pico_generate_pio_header(pico_usb_sniffer_lite ${CMAKE_CURRENT_LIST_DIR}/pico_usb_sniffer_lite.pio)
Expand All @@ -56,10 +56,5 @@ example_auto_set_url(pico_usb_sniffer_lite)
string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--print-memory-usage")

target_compile_definitions(pico_usb_sniffer_lite PRIVATE
PICO_DEFAULT_UART=1
PICO_DEFAULT_UART_TX_PIN=4
PICO_DEFAULT_UART_RX_PIN=5
PICO_DEFAULT_UART_BAUD_RATE=921600
PICO_FLASH_SIZE_BYTES=16777216
)

)
Binary file modified firmware/build/pico_usb_sniffer_lite.elf
Binary file not shown.
Loading

0 comments on commit 99cf5f8

Please sign in to comment.