Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ tags
# IntelliJ Project
.idea/

# vim
*.swp

# Release files
VERSION
release-files
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export BACKEND=greatfet
* All GoodFET-based Facedancers, including the common Facedancer21 (```BACKEND=goodfet```)
* RPi + Max3241 Raspdancer boards (```BACKEND=raspdancer```)
* HydraDancer and HydraUSB3 boards (```BACKEND=hydradancer```)
* Any Linux board with [Raw Gadget](https://github.com/xairy/raw-gadget) support (```BACKEND=rawgadget```)

Note that hardware restrictions prevent the MAX3420/MAX3421 boards from emulating
more complex devices -- there's limitation on the number/type of endpoints that can be
Expand All @@ -114,7 +115,6 @@ Note actual FaceDancer 3.0 does not work on Windows(some issues in pyusb...) and

## What boards could be supported soon?

* Any Linux computer with gadgetfs support (e.g. the Pi Zero or Beaglebone Black)
* Anything supporting USB-over-IP.

## What features do you plan on adding?
Expand Down
2 changes: 1 addition & 1 deletion examples/hackrf-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def handle_control_request_14(self, request):

# Theoretically, this is the point where you'd experiment
# with providing one-byte responses and see what `hackrf_info` does.
request.reply([2])
request.reply(bytes([2]))


#
Expand Down
3 changes: 2 additions & 1 deletion facedancer/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"greathost",
"libusbhost",
"moondancer",
"hydradancer"
"hydradancer",
"rawgadget",
]
16 changes: 12 additions & 4 deletions facedancer/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@


class FacedancerBackend:
def __init__(self, device: USBDevice=None, verbose: int=0, quirks: List[str]=[]):
def __init__(self, device=None, verbose: int=0, quirks: List[str]=[]):
"""
Initializes the backend.

Args:
device : The device that will act as our Facedancer. (Optional)
device : The device that will act as our Facedancer. (Optional)
verbose : The verbosity level of the given application. (Optional)
quirks : List of USB platform quirks. (Optional)
quirks : List of USB platform quirks. (Optional)
"""
raise NotImplementedError


@classmethod
def appropriate_for_environment(cls, backend_name: str) -> bool:
def appropriate_for_environment(cls, backend_name: str | None) -> bool:
"""
Determines if the current environment seems appropriate
for using this backend.
Expand All @@ -34,6 +34,14 @@ def get_version(self):
raise NotImplementedError


def requires_packetizing(self):
"""
Tells whether the backend requires the data to be split into chunks
of max packet size when sending this data on an endpoint.
"""
return True


def connect(self, usb_device: USBDevice, max_packet_size_ep0: int=64, device_speed: DeviceSpeed=DeviceSpeed.FULL):
"""
Prepares backend to connect to the target host and emulate
Expand Down
9 changes: 4 additions & 5 deletions facedancer/backends/hydradancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class HydradancerHostApp(FacedancerApp, FacedancerBackend):

current_setup_req = None

def __init__(self, device: USBDevice=None, verbose: int=0, quirks: List[str]=[]):
def __init__(self, device=None, verbose: int=0, quirks: List[str]=[]):
"""
Initializes the backend.

Args:
device : The device that will act as our Facedancer. (Optional)
device : The device that will act as our Facedancer. (Optional)
verbose : The verbosity level of the given application. (Optional)
quirks : List of USB platform quirks. (Optional)
quirks : List of USB platform quirks. (Optional)
"""
super().__init__(self)

Expand All @@ -83,7 +83,7 @@ def __init__(self, device: USBDevice=None, verbose: int=0, quirks: List[str]=[])
self.api.wait_board_ready()

@classmethod
def appropriate_for_environment(cls, backend_name: str) -> bool:
def appropriate_for_environment(cls, backend_name: str | None) -> bool:
"""
Determines if the current environment seems appropriate
for using this backend.
Expand All @@ -92,7 +92,6 @@ def appropriate_for_environment(cls, backend_name: str) -> bool:
backend_name : Backend name being requested. (Optional)
"""

logging.info("this is hydradancer hi")
# Open a connection to the target device...
device = usb.core.find(idVendor=0x16c0, idProduct=0x27d8)

Expand Down
4 changes: 2 additions & 2 deletions facedancer/backends/moondancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class MoondancerApp(FacedancerApp, FacedancerBackend):
# Number of supported USB endpoints.
SUPPORTED_ENDPOINTS = 16

def __init__(self, device: USBDevice=None, verbose: int=0, quirks: List[str]=[]):
def __init__(self, device=None, verbose: int=0, quirks: List[str]=[]):
"""
Sets up a new Cynthion-backed Facedancer (Moondancer) application.

Expand Down Expand Up @@ -144,7 +144,7 @@ def __init__(self, device: USBDevice=None, verbose: int=0, quirks: List[str]=[])
# - Facedancer backend methods --------------------------------------------

@classmethod
def appropriate_for_environment(cls, backend_name: str) -> bool:
def appropriate_for_environment(cls, backend_name: str | None) -> bool:
"""
Determines if the current environment seems appropriate
for using the Moondancer backend.
Expand Down
Loading