How to Build a Raspberry Pi USB Data Grabber with Python and WeChat Alerts
This guide walks you through creating a Raspberry Pi‑based Python tool that automatically detects inserted USB drives, logs their file names and paths to a text file, and sends the information to a designated WeChat account, while explaining the required hardware, Linux setup, and code details.
Reading font
Recently I have been learning Python web crawling and became curious about obtaining data from others' devices; using a Raspberry Pi I created a simple hacking tool called “U‑disk‑thief”.
The tool detects when a USB drive is plugged into the Pi’s USB port, records the file names and paths into a TXT file, and sends the file to a specified WeChat account; the speed depends on the number of files on the USB.
Materials needed
Raspberry Pi
Two smartphones logged into WeChat (as friends)
A USB flash drive
To enable automatic USB detection on the Pi’s Linux system, create a udev rule: sudo nano /etc/udev/rules.d/10-usbstorage.rules Paste the provided script into the editor and save. After inserting the USB, it will be auto‑mounted under /media/Untitled-sda1; remember this path for later use.
Python code
The script checks for the presence of the USB mount point /media/Untitled-sda1. If not found, it retries every 10 seconds. When the drive is detected, usbWalker() creates u-copy.txt in /home/pi/usbdisk-copy/ and sends it via WeChat (implementation similar to the author’s previous WeChat robot articles).
To avoid repeatedly generating the file while the USB remains connected, the script calls getusb() to detect duplicates before invoking usbWalker().
Possible extensions
The program can be adapted for Windows, adding file‑copy functionality to retrieve actual file contents or filter by type (e.g., .doc, .xls, .ppt, .txt). The Windows version can be packaged with PyInstaller into an executable and run as a background service.
Note: This tool is intended for learning and legitimate security research only; misuse is the user’s responsibility.
For questions about attribution, corrections or content rights, please contactand we will review it promptly.