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.
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
