The Rubber Ducky attack is simply opening up a command line and spewing an attack from an emulated USB HID keyboard. If the attacker can’t open up cmd or PowerShell, the attack breaks.
If you don’t wish to use any USB devices or USB storage devices, you can block the USB ports on your computer. In Windows 11, ...