Make a Rubber Ducky for $3 with Digispark 
Tags: pentesting, arduino, security, digispark
Published: 2019-12-04 06:46:52

---
title: Make a Rubber Ducky for $3 with Digispark 
published: true
description: A guide for making a Rubber Ducky from Digispark ATTINY85
tags: pentesting, arduino, security, digispark
cover_image: https://thehacktoday.com/wp-content/uploads/2017/03/ducky-1.jpg
---

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!

## Wait, what *is* a Rubber Ducky?

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.

## What do I need?

Digispark ATTINY85 microcontroller (the only purchase)
Arduino IDE software
Digistump Drivers
Duckyspark software

## Arduino IDE

The Arduino IDE will allow us to write, compile, and upload code to our Digispark

<ul>

<li>You can download the Arduino IDE for Windows, Linux, or Mac for free from <a href="https://www.arduino.cc/en/Main/Software">their software page</a></li>

<li>Once opened, go to File -> Preferences, and in the Additional Boards Manager URLs input, enter http://digistump.com/package_digistump_index.json
<img src="https://thepracticaldev.s3.amazonaws.com/i/qrlmyxkqd2l1keitvmls.PNG"></img></li>

<li>Go to Tools -> Board -> Boards Manager and search for Digistump AVR Boards (you'll want the one authored by Digistump) and click install <img src="https://thepracticaldev.s3.amazonaws.com/i/nn2wtzxw0rjr6wmqsxfx.PNG"></img></li>

<li>If any other installations are prompted (like drivers) accept them</li>

<li>Finally, go to Tools -> Board and select Digispark (Default - 16.5mhz) <img src="https://thepracticaldev.s3.amazonaws.com/i/x4t8i4t6l5r29tztp2lv.png"></img></li>

</ul>

## Digistump Drivers
<ul>

<li>Download the <a href="https://github.com/toxydose/Duckyspark">driver zip file</a> and unzip it</li>

<li>Enter the directory and run the Install Drivers file, then go through the installation wizard and accept</li>

</ul>


## Duckyspark

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!

<ul>

<li>Clone the Duckyspark repository from <a href="https://github.com/toxydose/Duckyspark">their GitHub page</a> to wherever you want it</li>

</ul>

## Putting it All Together

Now that we have everything we need, it's time to try it out.

<ul>

<li>Find a ducky script you want to use, for a harmless one that's good for testing I recommend the <a href="https://ducktoolkit.com/userscripts">Notepad Demo by Cloudcompany.at</a> <img src="https://thepracticaldev.s3.amazonaws.com/i/th3g0hq5q59na0q7k2kq.PNG"></img></li>

<li>Open the demo and either click Encode Payload and download it as duckycode.txt, or copy and paste the code into a txt file</li>

<li>Move your newly made txt file into the Duckyspark repo we cloned. Open a terminal and cd to the repo then run 
<code>py Duckyspark_translator.py nameofyourfile.txt</code></li>

<li>You should get a 'Success!' message and a new file called digipayload.ino in the repo <img src="https://thepracticaldev.s3.amazonaws.com/i/vhrp4srggxgeeotmdz5w.PNG"></img></li>

<li>Double-click the ino file, or open it in the Arduino IDE, then go to Sketch -> Verify/Compile <img src="https://thepracticaldev.s3.amazonaws.com/i/slmgtlaj0yvo1dy3i71p.png"></img>
<img src="https://thepracticaldev.s3.amazonaws.com/i/t7m7pf9gllhm7q8av6f2.PNG"></img></li>

<li>Finally, go to Sketch -> Upload and plug in your Digikey when prompted. <img src="https://thepracticaldev.s3.amazonaws.com/i/m7cxjp0exmotk4enqsik.png"></img><img src="https://thepracticaldev.s3.amazonaws.com/i/e2vyqpht2e0bbe0495xg.PNG"></img></li>

<li>Once it is successfully uploaded, remove the Digikey and re-insert it. Your script should run! <img src="https://thepracticaldev.s3.amazonaws.com/i/25j84w87rhn236nxq2gg.PNG"></img></li>

</ul>

## Common Errors

<ul>

<li>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)</li>

<li>If you have any other errors and/or their fixes, please leave them in the comments :)</li>

</ul>

## What now?

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!