facedancer.proxy module

USB Proxy implementation.

class facedancer.proxy.LibUSB1Device[source]

Bases: object

A wrapper around the proxied device based on libusb1.

classmethod clear_halt(endpoint_number, direction)[source]
context = None

Class variable that stores our device handle.

classmethod controlRead(request_type, request, value, index, length, timeout=1000)[source]
classmethod controlWrite(request_type, request, value, index, data, timeout=1000)[source]
device_handle = None
classmethod device_speed()[source]
classmethod find(idVendor, idProduct, find_all=True)[source]

Finds a USB device by its identifiers.

classmethod open(device, detach=True)[source]
classmethod read(endpoint_number, length, timeout=1000)[source]
classmethod write(endpoint_number, data, timeout=1000)[source]
class facedancer.proxy.USBProxyDevice(index=0, quirks=[], scheduler=None, **kwargs)[source]

Bases: USBBaseDevice

USB Proxy Device

__init__(index=0, quirks=[], scheduler=None, **kwargs)[source]

Sets up a new USBProxy instance.

add_filter(filter_object, head=False)[source]

Adds a filter to the USBProxy filter stack.

configured(configuration: USBConfiguration)[source]

Callback that handles when the target device becomes configured. If you’re using the standard filters, this will be called automatically; if not, you’ll have to call it once you know the device has been configured.

Parameters:

configuration – The configuration to be applied.

connect()[source]

Initialize this device. We perform a reduced initialization, as we really only want to proxy data.

filter_list = []
handle_bus_reset()[source]

Event handler for a bus reset.

handle_data_available(ep_num, data)[source]

Handles the case where data is ready from the Facedancer device that needs to be proxied to the target device.

handle_get_configuration_request(request)[source]
handle_get_descriptor_request(request)[source]
handle_nak(ep_num)[source]

Handles a NAK, which means that the target asked the proxied device to participate in a transfer. We use this as our cue to participate in communications.

handle_request(request: USBControlRequest)[source]

Proxies EP0 requests between the victim and the target.

interface_changed(interface_number: int, alternate: int)[source]

Callback that handles when a SET_INTERFACE request is made to the target. If you’re using the standard filters, this will be called automatically; if not, you’ll have to call it once you know an alternate setting has been applied.

Parameters:
  • interface_number – The interface number.

  • alternate – The alternate setting to be applied.

name: str = 'USB Proxy Device'