An Arduino library that allows you to use a cheap Arduino (Leonardo) as a Rubber Ducky
Arduino Leonardo Mini with USB adapter
"The USB Rubber Ducky is a keystroke injection tool disguised as a generic flash drive. Computers recognize it as a regular keyboard and accept pre-programmed keystroke payloads at over 1000 words per minute." Taken from Hak5 Gear.
Rubber Ducky: $44.99
Arduino Leonardo Mini: $4.22 (no it's not a mistake)
Rubber Ducky: ???
Arduino Leonardo Mini: Switches, Memory Card, Wifi, etc...
If you're interested in building one from scratch with switches and such, take a look at Seytonic's youtube channel, or you can simply buy a pre-built one from his store.
Please note that the examples might have previous versions of the library, consider creating an arduino project using the most recent version and copy the "setup" method from the examples.
Opens notepad, maximizes the window, writes down "Hello world!" and increases the font size to 200.
Shuts down the machine within 60 seconds.
Downloads a JPG file, sets it at desktop wallpaper and deletes it.
This library allows you to use an Arduino Leonardo as a Rubber Ducky with pre-built methods to simplify your keyboard script coding.
/**
* Prepares the virtual keyboard.
* This method should be the first instruction on the setup code block.
*/
void init();
/**
* Ends the virtual keyboard.
* This method should be the last instruction on the setup code block.
*/
void finish();
/**
* For the keyboard functions to work they need a small
* delay between them. If you notice there's some bugs
* when running your arduino, try using different delay values
* on this function.
*/
void rdDelay();
/**
* A longer delay (5 times the regular delay).
*/
void rdLongerDelay();
/**
* Used to type non-alphanumeric keys.
*/
void rdTypeKey(uint8_t key);
/**
* Runs a program.
* Example: "notepad" starts notepad, "calc" starts the calculator.
*/
void rdRun(String program);
/**
* Takes a screenshot.
*/
void rdPrintScreen();
/**
* Opens the JavaScript console on a browser.
*/
void rdOpenJavascriptConsole();
/**
* Hides a window:
* Basically it drags a window to the lowest it can be
* and then repositions the cursor.
*/
void rdHideWindow();
/**
* Same as Win + D
*/
void rdShowDesktop();
/**
* Same as Ctrl + V
*/
void rdPaste();
/**
* Same as Ctrl + X
*/
void rdCut();
/**
* Same as Ctrl + C
*/
void rdCopy();
/**
* Same as Gui + (the received key)
*/
void rdGuiCombination(uint8_t c);
/**
* Same as Alt + (the received key)
*/
void rdAltCombination(uint8_t c);
/**
* Same as Ctrl + (the received key)
*/
void rdCtrlCombination(uint8_t c);
/**
* Same as Shift + (the received key).
*/
void rdShiftCombination(uint8_t c);
/**
* Same as (Received hold key) + (target key).
*/
void rdKeyCombination(uint8_t holdKey, uint8_t targetKey);
/**
* Same as (Received hold key 1) + (received hold key 2) + (target key).
*/
void rdKeyCombination(uint8_t holdKey1, uint8_t holdKey2, uint8_t targetKey);
/**
* Same as above but with one more hold key.
*/
void rdKeyCombination(uint8_t holdKey1, uint8_t holdKey2, uint8_t holdKey3, uint8_t targetKey);
/**
* Opens the command prompt without admin rights.
*/
void rdOpenCommandPrompt();
/**
* Opens the command prompt, if the "admin" parameter
* has a "true value", it opens a command prompt
* with admin rights. Or without admin rights otherwise.
*/
void rdOpenCommandPrompt(boolean admin);
/**
* Accepts the windows smart screen to grant admin permissions.
*/
void rdAcceptWindowsSmartScreen();
/**
* It runs one or multiple powershell scripts,
* to run multiple scripts, separate them with a new line "\n" char.
*/
void rdPowershellRun(String scripts);
/**
* Changes the keyboard layout, if the computer only
* has 1 keyboard layout this key combination won't
* do anything.
*/
void rdChangeKeyboardLayout();
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
It's highly recommended that you edit this project using Arduino IDE that can be downloaded here since it was developed using that same tool. After installing, run the IDE and go to Tools > Board and select "Arduino Leonardo" or other compatible board (read the notes for further information).
The Arduino website suggests that only three boards are supported for the Mouse and Keyboard library:
-
Leonardo (CPU: ATmega32u4)
-
Micro (CPU: ATmega32u4)
-
Due (CPU: Atmel SAM3X8E ARM Cortex-M3)
- Luís Bragança Silva - Initial work
- Pedro Fernandes Costa - Initial work
- João Marques Capinha - Initial work