DEV Community

Monazir Muhammad Doha
Monazir Muhammad Doha

Posted on

Build a $10 DIY Wi-Fi USB Keylogger with ESP32-S3 and MicroPython (DuckLogger)

Have you ever wanted to build your own hardware keylogger but were deterred by the high cost or the need to design custom PCBs? Meet DuckLogger, an open-source, ESP32-S3–based USB Key Logger that you can build yourself for under $10 using off-the-shelf parts.

DuckLogger DIY Wi-Fi USB Keylogger Setup

In this guide, we'll cover what DuckLogger is, the hardware you need, and how you can assemble and program it yourself in a few simple steps.

What is DuckLogger?

DuckLogger is a MicroPython-powered DIY hardware hacking project. It silently intercepts and logs USB keystrokes into a text file and hosts a built-in Wi-Fi access point, allowing you to easily and wirelessly download your logs through a sleek web UI.

DuckLogger Hardware and Components Overview

Key Features

  • Internal Storage Logging: Records keystrokes and safely saves them to the ESP32's internal flash storage.
  • Wireless Access: Automatically spins up a Wi-Fi Access Point when plugged in.
  • Web UI: Download your log files directly from your browser by navigating to http://192.168.4.1/.
  • Zero Custom PCBs Required: Built entirely with widely available breakout boards.

(Upcoming features include sending Ducky scripts directly from the web UI and remote keyboard control via your browser!)


Hardware Requirements

To build this DIY keylogger, you only need three easily obtainable components (which can be easily found on AliExpress or Amazon):

  1. ESP32-S3 SuperMini: A tiny but powerful microcontroller that handles the Wi-Fi, storage, and logic.
  2. CH9350 HID Module: A specialized module that converts USB keyboard inputs into serial data.
  3. 4 Female Jumper Wires: For connecting the modules together.

Total cost? Less than $10.


How to Build Your DuckLogger

Ready to build your own? Let's walk through the setup process.

Step 1: Wiring and Schematics

Connecting the ESP32-S3 to the CH9350 module is incredibly straightforward. You only need to make four connections using your jumper wires.

DuckLogger ESP32-S3 and CH9350 Wiring Schematic

ESP32-S3 Pin CH9350 Pin Description
5V 5V Power
GND GND Ground
GP1 TX Receive Keystrokes
GP2 RX Send Commands

Step 2: Configure the CH9350 Module

The CH9350 supports multiple operating modes. For our keylogger to intercept USB keystrokes, we need to set it to USB Host Mode.

CH9350 DIP Switch Configuration for USB Host Mode

On the onboard DIP switches:

  • Set S0 to the GND position (0).
  • Keep all other switches in the opposite position (1).

This converts the USB keyboard inputs into serial data sent via UART at a default baud rate of 115200.

Step 3: Flash MicroPython to the ESP32-S3

DuckLogger runs on Python. If your board isn't already running it, you'll need to flash the latest MicroPython firmware.
You can find the official ESP32-S3 Generic flashing instructions on the MicroPython website.

Once flashed, disconnect and reconnect the board via USB.

Step 4: Install Dependencies

On your computer, install mpremote, a handy CLI tool for interacting with MicroPython devices:

pip install mpremote
Enter fullscreen mode Exit fullscreen mode

Verify your board is detected:

mpremote connect list
Enter fullscreen mode Exit fullscreen mode

Next, install the required USB packages directly onto the ESP32-S3:

mpremote mip install usb-device
mpremote mip install usb-device-keyboard
Enter fullscreen mode Exit fullscreen mode

Step 5: Upload the DuckLogger Code

Clone the official DuckLogger repository to your computer:

git clone https://github.com/Itsmmdoha/duckLogger.git
cd duckLogger
Enter fullscreen mode Exit fullscreen mode

With your board connected via USB, copy the project files over to the microcontroller:

1. Copy all library files to the /lib directory on the device:

mpremote cp lib/*.py :/lib/
Enter fullscreen mode Exit fullscreen mode

2. Copy the main execution file to the root of the device:

mpremote cp main.py :
Enter fullscreen mode Exit fullscreen mode

3. Reboot the board to start DuckLogger:

mpremote reset
Enter fullscreen mode Exit fullscreen mode

How to Use Your New Keylogger

  1. Plug the target USB keyboard directly into the CH9350 HID module.
  2. Connect the ESP32-S3 SuperMini to the target computer using a USB-C to USB-A cable.

The device will automatically power on, pass through the keystrokes to the computer (so the computer behaves normally), and simultaneously save those keystrokes to its internal flash memory.

To retrieve your logs:
From your smartphone or laptop, look for the newly created Wi-Fi Access Point.

  • Connect to the Wi-Fi Network (Default Password: duckPass1234)
  • Open your browser and navigate to: http://192.168.4.1/

Boom! You now have a low-cost, stealthy, Wi-Fi enabled hardware keylogger.

Final Thoughts

DuckLogger is an awesome example of how accessible hardware hacking and cybersecurity projects have become. Using MicroPython and cheap microcontrollers, you can build testing tools that previously cost hundreds of dollars.

Check out the full source code, contribute, or drop a star on the DuckLogger GitHub Repository!


Disclaimer: This project is strictly for educational purposes, security research, and personal use on your own devices. Always ensure you have explicit, documented permission before using keystroke logging tools.

Top comments (0)