Idea, development and implementation: @JoelSernaMoreno & @TobozoTagada
The sketch implements a hardware keylogger for the ESP32-S2 modules. ESP32-S2 modules do not support device and host at the same time, but it is possible to use USB Host Soft to implement this.
At this time, our keylogger with ESP32-S2 is limited, it only works with USB Low Speed keyboards.
The tests and PoC have been done with this keyboard: UNYKAch Mini Keyboard KB 302.
Make sure to use a USB-LS keyboard for your tests.
- Install esptool: sudo apt install esptool
- Install pyserial: sudo pip install pyserial
- Download and Install the Arduino IDE: https://www.arduino.cc/en/main/software
- Download ESP32S2-USB_LS-Keylogger repository: git clone https://github.com/joelsernamoreno/ESP32S2-USB_LS-Keylogger.git
- Download the EspTinyUSB library in the Arduino library directory: git clone https://github.com/chegewara/EspTinyUSB.git
- Download the ESPAsyncWebServer library in the Arduino library directory: git clone https://github.com/me-no-dev/ESPAsyncWebServer.git
- Download the AsyncTCP library in the Arduino library directory: git clone https://github.com/me-no-dev/AsyncTCP.git
- Edit AsyncTCP/src/AsyncTCP.h and change the following:
- #define CONFIG_ASYNC_TCP_USE_WDT 1 to #define CONFIG_ASYNC_TCP_USE_WDT 0
- Open Arduino IDE
- Go to File - Preferences. Locate the field "Additional Board Manager URLs:" Add "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" without quotes. Click "Ok"
- Select Tools - Board - Boards Manager. Search for "esp32". Install "esp32 by Espressif system version 2.0.4". Click "Close".
- Open the firmware/firmware.ino sketch
- Select Tools:
- Board - "ESP32S2 Dev Module".
- Upload Speed - "921600".
- USB CDC On Boot - "Disabled".
- USB Firmware MSC On Boot - "Disabled".
- USB DFU On Boot - "Disabled".
- All other options: Default
- Flash the firmware
The PoC is based on MouseLab's Nano ESP32-S2 and a female USB breakout
The ESP32-S2 and USB breakout connections have been made with the ESP32S2 GPIO8 and GPIO9 pins. You can change the pins in the sketch
- Visualize the wifi networks around you and connect to the ESP32-S2 (default SSID: ESP32S2 USB-LS Keylogger).
- Enter the password for the wifi network (default password: 123456789).
- Open a browser and access the web panel (default IP: 192.168.4.1).
NOTE: This is a proof of concept, the logs disappear when the device is disconnected.