This repository contains my final project for the COMP2215 module for University of Southmapton.
Creates a rubber ducky using an Atmel microcontroller, parses a DuckyScript file and creates a hex file to flash on the microcontroller.
That is a hacky implementation of the DuckyScript language that works for the Atmel AT90USB1286 microcontroller. You can find the schematics of the LaFortuna board here and the datasheet for the microcontroller here or on Atmel's website.
The LaFortuna board has a USB controller which is used in Device Controller mode (aka client mode) (p. 246 in the datasheet), simulates a USB keyboard and simulates key presses that are based on the ducky script code.
The C code is based on the keyboard demo provided on Atmel's website. I highly recommend understanding the code before trying to tweak it.
The main change is in keyboard_task.c
where I've added some custom logic for parsing key presses.
The keys that are going to be pressed are stored in an array called usb_keys
.
The HID values of each key can be found in usb_commun_hid.h
(a neat table with the values can be found here).
The main logic is written in Python. It is split in 2 sections - one parsing (simplifying) the DuckyScript language into something easier to convert to HID values.
The second part is a converter that converts characters to their respective HID values.
Both are written utilizing the chain of responsibility pattern to allow easier addition of new logic/tokens to parse.
The script:
DELAY 3000
WINDOWS r
DELAY 500
STRING notepad
DELAY 500
ENTER
DELAY 2750
STRING Hello World!
ENTER
produces the expected hello world example once the board is plugged in:
- Python 3.7+ to parse DuckyScript and adjust the C file
- Gnu make to make the project
- dfu-programmer to flash the .hex file on the microcontroller
- Run
python rubber_ducky_to_hex.py
This will read the contents ofduckyScript.txt
, parse it and make thepayload.hex
file that you should afterwards flash to your microcontroller. - Run
sudo dfu-programmer at90usb1286 erase && sudo dfu-programmer at90usb1286 flash payload.hex
to erase and reflash it.
- Control combos don't work at the moment
If you'd like to contribute, I'll be happy to accept pull requests. The files you should change are:
- keyboard_task.c - if you want to edit low-level key press logic
- python files - to edit the DuckyScript parsing/converting logic
- usb_commun_hid.h - to add new HID values for keys