Edit: Stray let me know in the comments that this will only work on the computer you install the Digistump Drivers on, unfortunately. Still looking for a workaround!
A Rubber Ducky is an awesome USB keystroke injector. Basically, you can write whatever scripts you want containing clicks/keystrokes, and they are run immediately when plugged into Linux/Windows/Mac machines. This is super useful for many pentesting activities, and even pranks!
However, not many of us want to pay $49.99 for the tool, so some smart folks out there (not me) have devised a way to make one using a $3 Digispark microcontroller. Here's how to make your own.
Digispark ATTINY85 microcontroller (the only purchase)
Arduino IDE software
The Arduino IDE will allow us to write, compile, and upload code to our Digispark
- You can download the Arduino IDE for Windows, Linux, or Mac for free from their software page
- Once opened, go to File -> Preferences, and in the Additional Boards Manager URLs input, enter http://digistump.com/package_digistump_index.json
- Go to Tools -> Board -> Boards Manager and search for Digistump AVR Boards (you'll want the one authored by Digistump) and click install
- If any other installations are prompted (like drivers) accept them
- Finally, go to Tools -> Board and select Digispark (Default - 16.5mhz)
- Download the driver zip file and unzip it
- Enter the directory and run the Install Drivers file, then go through the installation wizard and accept
The Duckyspark Python script lets us translate Ducky code to Digispark code. There are a lot of scripts people have made that we want to use!
- Clone the Duckyspark repository from their GitHub page to wherever you want it
Now that we have everything we need, it's time to try it out.
- Find a ducky script you want to use, for a harmless one that's good for testing I recommend the Notepad Demo by Cloudcompany.at
- Open the demo and either click Encode Payload and download it as duckycode.txt, or copy and paste the code into a txt file
- Move your newly made txt file into the Duckyspark repo we cloned. Open a terminal and cd to the repo then run
py Duckyspark_translator.py nameofyourfile.txt
- You should get a 'Success!' message and a new file called digipayload.ino in the repo
- Double-click the ino file, or open it in the Arduino IDE, then go to Sketch -> Verify/Compile
- Finally, go to Sketch -> Upload and plug in your Digikey when prompted.
- Once it is successfully uploaded, remove the Digikey and re-insert it. Your script should run!
- If you get this error at compile: "DigiKeyboard.h: No such file or directory", your board was likely changed when the Arduino IDE was reopened. Go back to Tools -> Board and select Digispark (Default - 16.5mhz)
- If you have any other errors and/or their fixes, please leave them in the comments :)
Now that you have everything installed, you can either write your own scripts in the DigiKeyboard language, or in Ducky and translate it with Duckyspark. Also as you've seen, there are tons of scripts out there for Ducky that you can translate. But be careful, many of them are for pentesting and other security applications, so don't make yourself vulnerable.
Thanks for reading!