One Python script that knows the difference between a flash drive and a flash drive that types, plus the USBGuard rule that slams the door on it.
Somebody leaves a USB stick on your desk with a sticky note that says "Q3 photos," and in the half second before your file manager opens, that stick can introduce itself to your laptop as a keyboard and start typing. By the end of this post that half second becomes a red line in your terminal, a push notification on your phone, and a USBGuard policy that refuses the device before it gets a single keystroke in.
Everything here runs on your own machine against your own hardware. The "attacker" we build to test it carries no payload at all, which turns out to be the most interesting part.
The Lie Lives in the Descriptor
A USB device tells your computer what it is. Your computer believes it.
That handshake happens through interface descriptors, small blocks of bytes that carry a class code. Class 03 is HID, which covers keyboards and mice.…