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.

29 thoughts on “USB-Rubber Ducky scripts on Arduino/Leostick

  1. that is some good stuff i am using the teensy still but am wanting to get one of those leosticks i have seen them around

  2. Whenever I attempt to verify a compiled script i come up with

    screen_rotate.ino: In function ‘void setup()’:
    screen_rotate:174: error: ‘KEY_MODIFIER_LEFT_CTRL’ was not declared in this scope

    What do?

  3. Hi! I tried the lock prank, but i got this error message when trying to compile it:
    lock_prank.cpp: In function ‘void sendKey(byte, byte, byte)’:
    lock_prank.cpp:155:3: error: ‘KeyReport’ was not declared in this scope
    lock_prank.cpp:155:13: error: expected ‘;’ before ‘report’
    lock_prank.cpp:158:3: error: ‘report’ was not declared in this scope
    lock_prank.cpp:162:3: error: ‘Keyboard’ was not declared in this scope
    lock_prank.cpp: In function ‘void setup()’:
    lock_prank.cpp:298:26: error: ‘KEY_MODIFIER_LEFT_ALT’ was not declared in this scope
    lock_prank.cpp:300:3: error: ‘Keyboard’ was not declared in this scope

    i am using an arduino UNO and ubuntu 12.04

  4. Hey,
    Just wondering how you’d be able to update/modify the code on the leo after the initial payload has been installed without running the (old) payload on the machine?

Comments are closed.