Computer security researchers wrote the code following the discovery of the USB flaw earlier this year.
The pair made the code public in an attempt to force electronics firms to improve defences against attack by USB.
One of the experts who found the flaw said the release was a “stark reminder” of its seriousness.
Details of the BadUSB flaw were released at the Black Hat computer security conference in August by Karsten Nohl and Jakob Lell.
Their work revealed how to exploit flaws in the software that helps devices connect to computers via USB. The biggest problem they discovered lurks in the onboard software, known as firmware, found on these devices.