facedancer.devices.keyboard module
- class facedancer.devices.keyboard.USBKeyboardDevice(*, name: str = 'USB keyboard device', device_class: int = 0, device_subclass: int = 0, protocol_revision_number: int = 0, max_packet_size_ep0: int = 64, vendor_id: int = 24843, product_id: int = 18003, manufacturer_string: StringRef = <factory>, product_string: str = 'Non-suspicious Keyboard', serial_number_string: StringRef = <factory>, supported_languages: tuple = (LanguageIDs.ENGLISH_US,), device_revision: int = 0, usb_spec_version: int = 512, device_speed: DeviceSpeed = None, requestable_descriptors: Dict[tuple[int, int], Union[bytes, callable]] = <factory>, configurations: Dict[int, USBConfiguration] = <factory>, backend: FacedancerUSBApp = None)[source]
Bases:
USBDeviceSimple USB keyboard device.
- KeyboardConfiguration = <facedancer.magic.AutoInstantiator object>
- all_keys_up(*, include_modifiers: bool = True)[source]
Releases all keys currently pressed.
- Parameters:
include_modifiers – If set to false, modifiers will be left at their current states.
- handle_data_requested(endpoint: USBEndpoint)[source]
Provide data once per host request.
- key_down(code: KeyboardKeys)[source]
Marks a given key as pressed; should be a scancode from KeyboardKeys.
- key_up(code: KeyboardKeys)[source]
Marks a given key as released; should be a scancode from KeyboardKeys.
- modifier_down(code: KeyboardModifiers)[source]
Marks a given modifier as pressed; should be a flag from KeyboardModifiers.
- modifier_up(code: KeyboardModifiers)[source]
Marks a given modifier as released; should be a flag from KeyboardModifiers.
- name: str = 'USB keyboard device'
- product_string: str = 'Non-suspicious Keyboard'
- async type_letter(letter: str, duration: float = 0.1, modifiers: KeyboardModifiers = None)[source]
Attempts to type a single letter, based on its ASCII string representation.
- Parameters:
letter – A single-character string literal, to be typed.
duration – How long each key should be pressed, in seconds.
modifiers – Any modifier keys that should be held while typing.
- async type_letters(*letters: Iterable[str], duration: float = 0.1)[source]
Attempts to type a string of letters, based on ASCII string representations.
- Parameters:
*letters – A collection of single-character string literal, to be typed in order.
duration – How long each key should be pressed, in seconds.
- async type_scancode(code: KeyboardKeys, duration: float = 0.1, modifiers: KeyboardModifiers = None)[source]
Presses, and then releases, a single key.
- Parameters:
code – The keyboard key to be pressed’s scancode.
duration – How long the given key should be pressed, in seconds.
modifiers – Any modifier keys that should be held while typing.
- async type_scancodes(*codes: Iterable[KeyboardKeys], duration: float = 0.1)[source]
Presses, and then releases, a collection of keys, in order.
- Parameters:
*code – The keyboard keys to be pressed’s scancodes.
duration – How long each key should be pressed, in seconds.
- async type_string(to_type: str, *, duration: float = 0.1, modifiers: KeyboardModifiers = None)[source]
Attempts to type a python string into the remote host.
- Parameters:
letter – A collection of single-character string literal, to be typed in order.
duration – How long each key should be pressed, in seconds.
modifiers – Any modifier keys that should be held while typing.