Skip to content

Conversation

@akvadrako
Copy link
Contributor

While working on the raw_gadget backend I was mostly using the proxy device. However there were several issues with it that prevented it from working. This fixes those.

It also fixes a few things that were not correct according to the libusb docs, like forwarding SET_INTERFACE to the real device - it should be handled specially.

There are also some suggestions for logging to make it more clear and have a level where it's less verbose.

@akvadrako akvadrako mentioned this pull request Jun 11, 2025
@xairy
Copy link
Contributor

xairy commented Jun 11, 2025

It would be great to split these changes into separate commits with separate descriptions of what each change does.

But I'll leave reviewing this to the Facedancer developers.

@antoinevg antoinevg self-requested a review June 24, 2025 14:07
Copy link
Member

@antoinevg antoinevg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great submission, I have a few questions in my review comments but mostly it's just nit-picks. Thank you!

from .logging import log
from .request import USBControlRequest
from .types import USB

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove any code format changes that are not directly related to behavioral changes. e.g. whitespace, new-lines, small-fixes, spelling etc.

They make it harder to see what's going on and can open up discussions best had in another context. 🥹

One way to strip them all out can be found here: https://gist.github.com/hello-josh/dbabb56e1a01ac293b83154a6f4a208e

class USBProxyDevice(USBBaseDevice):
""" USB Proxy Device """
"""USB Proxy Device"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

if len(usb_devices) <= index:
raise DeviceNotFoundError(f"Could not find device to proxy.")
raise DeviceNotFoundError("Could not find device to proxy.")
device = usb_devices[index]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

interface.number: interface
for interface in configuration.get_interfaces()
if interface.alternate == 0
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

endpoint = self.configuration.get_endpoint(ep_num, USBDirection.IN)
if endpoint is None:
return
Typically, this method will delegate the request to the appropriate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you removed this method?

"""libusb1 recommends always using this instead of sending control packets."""
log.info(f"LibUSB1Device setInterface {interface} alt {alt}")
cls._handle().setInterfaceAltSetting(interface, alt)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

cls._claim()

cls._handle().setAutoDetachKernelDriver(1)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

from .filters.logging import USBProxyPrettyPrintFilter
from .filters.standard import USBProxySetupFilters
from .filters.logging import USBProxyPrettyPrintFilter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

async def configure_logging():
import logging

logging.getLogger("facedancer").setLevel(logging.INFO)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

logging.getLogger("facedancer").setLevel(logging.INFO)

from facedancer import main

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants