This Answer is aiming on how to stop the rubber ducky:
If you use Ubuntu, the approach presented in this video steming from this guide should work for you:
- open a terminal
- run the following command in the terminal:
sudo echo 'blacklist usbhid' > /etc/modprobe.d/usbhid.conf
- run the following command in the terminal:
sudo update-initramfs -u -k $(uname -r)
- reboot the computer
Sadly this method has the side effect that USB mouses and keyboards wont work anymore, as explained in both the video and the guide, because it works by configuring the OS to not accept mouse/keyboard input from devices connected via USB.
However, this way of treating the issue also has its pros, because since the OS then discards USB mouse/keyboard input, there is no way any rubber ducky may get around it, its 100% sure that this method will stop this specific type (rubber ducky emulating keystrokes and/or mouse interaction to run commands) of attack
(you dont have to worry about some shady protective program acting quick enough) and since no extra programs are required, you dont risk to infect your OS by installing poisoned ones.
If you use other Linux operating systems, you may be able to use similar blacklisting mechanisms in a similar fashion.
If you use Windows, I dont know, but I think youre screwed. I hardly doubt that windows provides similar mechanisms, afaik you can't even disable atomatic USB mounting on windows. But I would not do things where security is paramount on a windows machine anyways, since these are in general far more vulnerable (if the gossip got it right).
Disclaimer: as I am absolutely new to this topic (hardening devices) and do not fully understand the solution presented in the video and the guide, I cannot guarantee for anything, I just present that solution here, along with some assumptions of mine. However, since everything seems perfectly sound to me, I hardly doubt I got something wrong, please correct me tho if I did.