Keyboard connector

This module provides the whad.unifying.keyboard.Keyboard class that behaves like a Logitech Unifying keyboard. This connector is able to synchronize with an existing keyboard dongle and send spoofed events.

class whad.unifying.connector.keyboard.Keyboard(device: WhadDevice)[source]

Logitech Unifying Keyboard interface for compatible WHAD device.

property address: str

Current device address

Returns:

current device address

Return type:

str

property aes_counter: int

Current AES counter value

Returns:

AES counter value

Return type:

int

property channel: int

Current channel in use

Returns:

current channel in use

Return type:

int

property key: bytes

Current encryption key

Returns:

encryption key

Return type:

bytes

lock()[source]

Lock keyboard on current channel.

on_pdu(packet)[source]

Unifying packet handler, feeds the underlying stack.

send_key(key, ctrl: bool = False, alt: bool = False, shift: bool = False, gui: bool = False) bool[source]

Send a keypress with modifiers.

Parameters:
  • key (bytes) – Key to send

  • ctrl (bool) – CONTROL key modifier enabled if set to True

  • alt (bool) – ALT key modifier enabled if set to True

  • shift (bool) – SHIFT key modifier enabled if set to True

  • gui (bool) – GUI key modifier enabled if set to True

Returns:

True if key has been successfully injected, False otherwise.

Return type:

bool

send_text(text: str)[source]

Send a series of keystrokes.

Parameters:

text (str) – text to send

property stack: ESBStack

Current ESB stack in use

Returns:

ESB stack instance

Return type:

whad.esb.stack.ESBStack

start()[source]

Start keyboard mode

stop()[source]

Stop keyboard mode

synchronize(timeout: float = 10.0) bool[source]

Synchronize with target device.

Parameters:

timeout (float) – timeout in seconds

Returns:

True if synchronization succeeded, False otherwise.

Return type:

bool

unlock()[source]

Unlock keyboard from current channel.

volume_down() bool[source]

Send a volume down keypress.

volume_toggle() bool[source]

Send a volume toggle keypress.

volume_up() bool[source]

Send a volume up keypress.