Skip to main content
BlackUSB is an experimental script that prevents theft of personal data, malware, forensic tools, and BadUSB attacks (USB Rubber Ducky). It generates a whitelist of USB/HID devices and blocks any unauthorized insertion of unknown devices.
Experimental Status: BlackUSB is marked as frozen. Use at your own risk and test thoroughly before deploying in production environments.

Platform Support

BlackUSB is available for both Linux and Windows operating systems with different implementations:

Linux Version

A bash script that generates a whitelist of USB/HID devices and blocks unauthorized devices using udev rules.

Installation

sudo wget -q -N https://raw.githubusercontent.com/maravento/vault/master/blackusb/linux/blackusb.sh -O /path_to/blackusb.sh
sudo chmod +x /path_to/blackusb.sh

Command Reference

CommandShortDescription
showsShow currently connected USB devices
onoTurn on BlackUSB and generate whitelist of connected USB devices
ejectjChoose a device from the list to eject or add entry
offxTemporarily deactivate BlackUSB
gengGenerate or refresh whitelist udev rules file
deldDelete udev rules file containing whitelist
editeEdit udev rules file manually

Usage Examples

1

Show connected devices

Display all currently connected USB devices:
sudo /path_to/blackusb.sh s
Example output:
0 Name=xHCI Host Controller, Vendor=1d6b, Product=0003, Serial=0022:00:14.0
1 Vendor=8087, Product=07dc
2 Name=USB2.0-CRW, Vendor=0bda, Product=0129, Serial=20100001396000000
3 Name=Integrated_Webcam_HD, Vendor=0c45, Product=6710
4 Name=HID-compliant mouse, Vendor=046d, Product=c530
5 Name=xHCI Host Controller, Vendor=1d6b, Product=0002, Serial=0022:00:14.0
2

Enable protection

Activate BlackUSB and create a whitelist of currently connected devices:
sudo /path_to/blackusb.sh on
3

Manage devices

Eject a device or add to whitelist:
sudo /path_to/blackusb.sh eject

Paranoic Mode

By default, BlackUSB locks the terminal when an unauthorized device is detected. Paranoic mode powers off the system instead.To enable, edit the script and uncomment:
'poweroff'
Paranoic Mode: Enabling this will immediately shut down your system when an unauthorized USB device is inserted. Use with extreme caution.

Logs

All BlackUSB events are logged to:
/var/log/blackusb.log
Example log entry:
2017-07-06 12:34:10 Blackusb triggered!
Unknown Device Blocked: SUBSYSTEM=="usb", ATTR{idVendor}=="0781", ATTR{idProduct}=="5567", ATTR{serial}=="4C530799910104103543"
Cruzer Blade

Dependencies

  • bash
  • udev

Credits

BlackUSB is forked from:

Use Cases

  • Data Theft Prevention: Block unauthorized USB drives from being used to steal sensitive data
  • BadUSB Protection: Prevent USB Rubber Ducky and similar HID attack devices
  • Malware Prevention: Stop malware propagation through infected USB devices
  • Forensic Tool Defense: Block unauthorized forensic tools from accessing the system
  • Compliance: Enforce USB device policies in regulated environments

License

BlackUSB is licensed under:
  • GPL-3.0
  • CC BY-SA 4.0

Disclaimer

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

Build docs developers (and LLMs) love