I recall seeing a video of a presentation about trashing a device that's plugged in via exploits (I think?) in the USB protocol, but I imagine that the "do things when something is detected" part would be comparatively easy to reproduce.
Unfortunately, I can't recall where it was, nor can I seem to find it. Sorry.
Unfortunately, I can't recall where it was, nor can I seem to find it. Sorry.