Duck2spark Save

Converter for raw RubberDucky payloads to Digispark Arduino IDE Sketch source.

Project README

====================================== duck2spark by MaMe82 (Marcus Mengs)

This project provides a python script capable of converting payloads generated by DuckEncoder_ to an Arduino Sketch source targeting DigiSpark. The script solves two problems:

  • Available solutions and tutorials emulating a RuberDucky on a DigiSpark suffer from poor keyboard layout support for non-US languages. This is solved by "outsourcing" the problem to DuckEncoder_ which supports multiple keyboard layouts.
  • Solutions using DigiKeyboard.print() and DigiKeyboard.println() suffer from string size restrictions, due to DigiSparks RAM limitations (less than 512 Bytes available). This is solved by storing the payload in FLASH memory

Additional features

  • Support for DuckyScript "DELAY" and "REPEAT" command
  • Option for initial delay, to cope with missing key presses, due to insufficient time for driver initialization on target.
  • Option to repeat payload execution (counted loop, single run, endless run)
  • Option to blink status LED when payload execution is finished (on by default, except endless loop)

.. _DuckEncoder:

Project files

  • - Main script
  • README.rst - this file
  • - Example script building a payload by running DuckEncoder followed by (encoder.jar has to be present)
  • - RubberDucky script with test cases used by


  • Arduino IDE_ to compile and upload the generated Sketch to DigiSpark
  • Arduino IDE has to be configured to program a DigiSpark, following this guide_
  • One, two or many DigiSparks ;-)
  • DuckEncoder_ to generate a raw payload from DuckyScript, if you want to stay away from Java use my python port of DuckEncoder <>_
  • Python 2 installation

.. _Arduino IDE: .. _guide: .. _DuckEncoder:


#. Generate a DuckyScript you want to use as output::

echo "STRING Hello World" >

#. Compile the script using DuckEncoder with your keyboard layout (de in example) or use my python port <>_::

java -jar encoder.jar -i -o raw.bin -l de

#. Use to convert into Arduino Sketch (options for single run, 2 seconds startup delay):: -i raw.bin -l 1 -f 2000 -o sketch.ino

#. After setting up the Arduino IDE load the example "DigisparkKeyboard" and replace the Sketch source by the one saved to sketch.ino .

To get help on run -h

Getting started with DuckyScript

Here's an introduction_ to DuckyScript

.. _introduction:!

Additional Hints on using DuckEncoder in conjunction with duck2spark

  • DuckEncoder has an issue encoding "GUI" or "WINDOWS" key without an additional key. The common scenario on Windows is a key combination like "GUI r", but using "GUI" alone would produce the incorrect character e as output. The issue is adressed here <>. As there hopefully will be a patch duck2spark doesn't handle this issue. In fact it isn't possible to distinguish between "GUI" key and "e" key in an already encoded script. A patched version of could be found here <>.

  • Using long delays in a DuckyScript results in big payloads, as delays longer than 250 milliseconds are split up into multiple delays, with a maximum of 250 milliseconds each. Each of these delays consumes 2 bytes in the final payload. As the memory of digispark is far more limited, it is suggested to use duck2spark's delay options instead. Duck2spark relies on DigiKeyboard.delay() and is more friendly in terms of memory consumption.

  • Using the "PREPEAT <N>" instruction in DuckyScript results in repeating the whole key sequence of the former command and thus consumes <N> times as much memory in the final payload. Again, as Digispark is short on memory, it is suggested to use duck2spark's loop option whenever possible. Printing out a 10 character string 500 times by using "REPEAT 500" results in a payload 10000 bytes in size, which is to large for Digispark. Encoding a DuckyScript with a single 10 character string consumes only 20 bytes and could be combined with -l 500 to achieve a 500 times repetition without further memory consumption.

Open Source Agenda is not affiliated with "Duck2spark" Project. README Source: mame82/duck2spark
Open Issues
Last Commit
5 years ago

Open Source Agenda Badge

Open Source Agenda Rating