class documentation

Read and execute DuckyScript commands.

Method __init__ Create an interpreter for a USB device and optional peripherals.
Method exec Read a DuckyScript file from SD storage and execute it.
Method run Execute DuckyScript source code synchronously.
Instance Variable button_reader Undocumented
Instance Variable default_delay Undocumented
Instance Variable default_string_delay Undocumented
Instance Variable device_id Undocumented
Instance Variable media_device Undocumented
Instance Variable mouse_device Undocumented
Instance Variable storage Undocumented
Instance Variable usb_device Undocumented
Method _alt_char Type one character using the ALT+numpad method.
Method _alt_string Type a string using ALT+numpad character codes.
Method _delay_before_command Apply the configured delay before a command.
Method _execute_command Execute one parsed command.
Method _globe Send a Globe/Fn key through an optional device hook.
Method _hold Press a key without releasing it.
Method _key_spec Resolve a DuckyScript key expression.
Method _key_tokens Split modifier-key syntax using spaces or hyphens.
Method _media Send a consumer-control media key.
Method _mouse_click Send a mouse click through an optional mouse device.
Method _mouse_move Move the mouse by an x and y offset.
Method _mouse_scroll Scroll the mouse by a signed distance.
Method _number Parse an integer command argument.
Method _parse_line Parse one source line into a command and argument.
Method _press_key Press and release a key or key combination.
Method _release Release all keys or the requested held key.
Method _release_all Release all keys through the USB device.
Method _repeat Repeat the previously executed command.
Method _reset_run_state Reset per-script parser and key state.
Method _restore_holds Restore held keys after a press that released the report.
Method _send_alt_code Send a decimal code while holding the ALT modifier.
Method _send_held_keys Send the current held-key report.
Method _send_key Send a key-down report through the USB device.
Method _set_device_id Validate and apply a custom USB device ID when supported.
Method _sleep Sleep for a number of milliseconds.
Method _string Type a string using the configured string delay.
Method _sysrq Send an ALT+PRINTSCREEN SysRq sequence.
Method _wait_for_button Wait until the configured button source reports a press.
Constant _ALIASES Undocumented
Constant _KEYPAD_KEYS Undocumented
Constant _MEDIA_KEYS Undocumented
Constant _MODIFIERS Undocumented
Constant _SPECIAL_KEYS Undocumented
Instance Variable _held_keycodes Undocumented
Instance Variable _held_modifiers Undocumented
Instance Variable _last_command Undocumented
Instance Variable _string_delay Undocumented
def __init__(self, usb_device, storage=None, media_device=None, mouse_device=None, button_reader=None):

Create an interpreter for a USB device and optional peripherals.

Parameters
usb_deviceUSB keyboard-compatible device.
storageOptional storage instance used by exec.
media_deviceOptional USB media-key device.
mouse_deviceOptional USB mouse device.
button_readerOptional callable returning whether a button was pressed.
def exec(self, file_path):

Read a DuckyScript file from SD storage and execute it.

Parameters
file_path:strPath to the script on the SD card.
Returns
NoneThe script is executed synchronously.
def run(self, code):

Execute DuckyScript source code synchronously.

Parameters
code:str or bytesDuckyScript source to execute.
Returns
NoneThe script is executed synchronously.
button_reader =

Undocumented

default_delay: int =

Undocumented

default_string_delay: int =

Undocumented

device_id =

Undocumented

media_device =

Undocumented

mouse_device =

Undocumented

storage =

Undocumented

usb_device =

Undocumented

def _alt_char(self, argument):

Type one character using the ALT+numpad method.

def _alt_string(self, text):

Type a string using ALT+numpad character codes.

def _delay_before_command(self):

Apply the configured delay before a command.

def _execute_command(self, command, argument, line_number):

Execute one parsed command.

def _globe(self, argument):

Send a Globe/Fn key through an optional device hook.

def _hold(self, argument):

Press a key without releasing it.

def _key_spec(self, argument, include_held=True):

Resolve a DuckyScript key expression.

def _key_tokens(self, argument):

Split modifier-key syntax using spaces or hyphens.

def _media(self, argument):

Send a consumer-control media key.

def _mouse_click(self, button):

Send a mouse click through an optional mouse device.

def _mouse_move(self, argument, command):

Move the mouse by an x and y offset.

def _mouse_scroll(self, argument, command):

Scroll the mouse by a signed distance.

def _number(self, value, command, allow_negative=False):

Parse an integer command argument.

def _parse_line(self, line):

Parse one source line into a command and argument.

def _press_key(self, argument):

Press and release a key or key combination.

def _release(self, argument):

Release all keys or the requested held key.

def _release_all(self):

Release all keys through the USB device.

def _repeat(self, argument, line_number):

Repeat the previously executed command.

def _reset_run_state(self):

Reset per-script parser and key state.

def _restore_holds(self):

Restore held keys after a press that released the report.

def _send_alt_code(self, code):

Send a decimal code while holding the ALT modifier.

def _send_held_keys(self):

Send the current held-key report.

def _send_key(self, modifier, keycode):

Send a key-down report through the USB device.

def _set_device_id(self, argument):

Validate and apply a custom USB device ID when supported.

def _sleep(self, milliseconds):

Sleep for a number of milliseconds.

def _string(self, text):

Type a string using the configured string delay.

def _sysrq(self, argument):

Send an ALT+PRINTSCREEN SysRq sequence.

def _wait_for_button(self):

Wait until the configured button source reports a press.

_ALIASES: dict[str, str] =

Undocumented

Value
{'DEFAULTDELAY': 'DEFAULT_DELAY',
 'STRINGDELAY': 'STRING_DELAY',
 'DEFAULTSTRINGDELAY': 'DEFAULT_STRING_DELAY',
 'ALTCODE': 'ALTSTRING',
 'LEFT_CLICK': 'LEFTCLICK',
 'RIGHT_CLICK': 'RIGHTCLICK',
 'MOUSE_MOVE': 'MOUSEMOVE',
...
_KEYPAD_KEYS: dict[str, int] =

Undocumented

Value
{'0': 98,
 '1': 89,
 '2': 90,
 '3': 91,
 '4': 92,
 '5': 93,
 '6': 94,
...
_MEDIA_KEYS =

Undocumented

Value
{'POWER': 48,
 'REBOOT': 48,
 'SLEEP': 50,
 'LOGOFF': 410,
 'EXIT': 41,
 'HOME': 547,
 'BACK': 548,
...
_MODIFIERS =

Undocumented

Value
{'CTRL': USBKeyboard.MOD_LCTRL,
 'CONTROL': USBKeyboard.MOD_LCTRL,
 'SHIFT': USBKeyboard.MOD_LSHIFT,
 'ALT': USBKeyboard.MOD_LALT,
 'GUI': USBKeyboard.MOD_LGUI,
 'WINDOWS': USBKeyboard.MOD_LGUI}
_SPECIAL_KEYS =

Undocumented

Value
{'DOWNARROW': USBKeyboard.KEY_DOWN,
 'DOWN': USBKeyboard.KEY_DOWN,
 'LEFTARROW': USBKeyboard.KEY_LEFT,
 'LEFT': USBKeyboard.KEY_LEFT,
 'RIGHTARROW': USBKeyboard.KEY_RIGHT,
 'RIGHT': USBKeyboard.KEY_RIGHT,
 'UPARROW': USBKeyboard.KEY_UP,
...
_held_keycodes: list =

Undocumented

_held_modifiers: int =

Undocumented

_last_command =

Undocumented

_string_delay =

Undocumented