People keep saying never put a random USB in your device because it could ruin it with a virus. Hackers are able to program USBs to automatically run a virus when it is put in a device. So I decided to search how to program a USB to auto run a file. It said to use autorun.inf so I tested out autorun.inf and found out that it no longer works because laptops are no longer always checking for batch files. So it seemed like the only method to do this was patched, yet we are still warned about using random USBs. So how do hackers program USBs to auto run a file.

  • @ThoriumBR No, I am asking how they program it to autorun. Apr 30, 2020 at 19:46
  • Actually it does. It's the firmware. The answers walk you through this. You will want to look at BadUSB for one specific implementation.
    – schroeder
    Apr 30, 2020 at 19:58
  • 1. User plugs in unknown, mysterious USB stick. 2. User sees an attracting file on it. What fraction of users do you think will double click on it? There is your autorun scheme.
    – Tony
    Apr 30, 2020 at 20:12

1 Answer 1


A USB "thumb drive" could be a keyboard interface in disguise. A popular tool called Rubber Ducky works like this:

"While it appears to be an innocuous USB thumb drive, when it is plugged into a computer, it instead registers itself as a USB keyboard on the system and fires off a keystroke payload at lightning speed." (Tutorial)

Most commonly an encoded PowerShell script is typed in and run, creating an implant on the system which will then call out to the attacker over the network.

Not the answer you're looking for? Browse other questions tagged .