adafruit_ducky

CircuitPython library for running DuckyScript

  • Author(s): Eva Herrada

Implementation Notes

Software and Dependencies:

class adafruit_ducky.Ducky(filename: str, keyboard: Keyboard, layout: KeyboardLayoutBase)

Class that runs a DuckyScript file.

Quickstart: Importing and using the library

Here is an example of using the Ducky class. First you will need to import the libraries

import time
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
import ducky

Once this is done, define the keyboard layout and initialize the Ducky class.

time.sleep(1)  # Sleep for a bit to avoid a race condition on some systems
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

duck = ducky.Ducky('duckyscript.txt', keyboard, keyboard_layout)

Now, set up a loop which will run a line of the script every time loop is called.

result = True
while result is not False:
    result = duck.loop()
loop() bool

Function that sends a line of the DuckyScript file over hid every time it is called

write_key(start: str) None

Writes the keys over HID. Used to help with more complicated commands