USB-Rubber Ducky scripts on Arduino/Leostick
The other day I was at Jaycar and saw that they are now selling small USB sticks that are arduino compatible. It is called the LeoStick and is made by Freetronics down in Melbourne. Seeing that it could pretend to be a USB HID device (ie keyboard/mouse) I wondered if I could do the sort of thing that the USB Rubber Ducky from Hak5 can do As it turns out the answer is YES :)
Since it was possible I spent an hour or two writing a quick shell script which can convert ducky script payloads into a sketch suitable for uploading to the LeoStick (or any arduino that has USB-HID capability) The end result is a small bash script which can be downloaded from compile_payload.sh
Usage is fairly simple - you run the script with two options - the first being the payload file, and the second being the arduino script output.
ie: compile_payload lock_prank.txt lock_prank.ino
Various payloads can be found linked from the USB-Rubber-Ducky wiki
As a bit of fun I changed the lock_prank payload to work on Gnome/Linux and it also plays the mission impossible theme once done ;) Grab it from lock_prank.ino
Also note that to get this working you need to edit the arduino libraries so that the sendReport function is marked as public.
To to this edit the USBAPI.h file which can be found in ${ARDUINO_DIR}/hardware/arduino/cores/arduino directory. This may be /usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h or similar If you installed the LeoStick board stuff from their website then it will be under your sketches directory as hardware/LeoStick/cores/arduino/USBAPI.h
Open that file and find
private:
KeyMap* _keyMap;
void sendReport(KeyReport* keys);
void setKeyMap(KeyMap* keyMap);
public:
Keyboard_();
virtual size_t write(uint8_t);
Then change that to
private:
KeyMap* _keyMap;
void setKeyMap(KeyMap* keyMap);
public:
void sendReport(KeyReport* keys);
Keyboard_();
virtual size_t write(uint8_t);
Then everything should work fine.