Code Monkey home page Code Monkey logo

duck2spark's Introduction

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)

Project files

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

Requirements

  • 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

Usage

  1. Generate a DuckyScript test.duck you want to use as output:

    echo "STRING Hello World" > test.duck
  2. Compile the script using DuckEncoder with your keyboard layout (de in example) or use my python port:

    java -jar encoder.jar -i test.duck -o raw.bin -l de
  3. Use duck2spark.py to convert into Arduino Sketch (options for single run, 2 seconds startup delay):

    duck2spark.py -i raw.bin -l 1 -f 2000 -o sketch.ino
  4. 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 duck2spark.py run duck2spark.py -h

Getting started with DuckyScript

Here's an introduction to DuckyScript

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 Encoder.java 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 duck2spark.py -l 500 to achieve a 500 times repetition without further memory consumption.

duck2spark's People

Contributors

mame82 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.