Skip to content

Commit

Permalink
Merge pull request #32 from HclX/master
Browse files Browse the repository at this point in the history
Support descriptors with non-standard length.
  • Loading branch information
ktemkin authored Feb 9, 2020
2 parents c23fa47 + 734ca98 commit 2281b57
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion facedancer/USBConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def from_binary_descriptor(cls, data):

# Unpack the main colleciton of data into the descriptor itself.
descriptor_type, total_length, num_interfaces, index, string_index, \
attributes, max_power = struct.unpack('<xBHBBBBB', data[0:length])
attributes, max_power = struct.unpack_from('<xBHBBBBB', data[0:length])

# Extract the subordinate descriptors, and parse them.
interfaces = cls._parse_subordinate_descriptors(data[length:total_length])
Expand Down
2 changes: 1 addition & 1 deletion facedancer/USBDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def from_binary_descriptor(cls, data):
spec_version_msb, spec_version_lsb, device_class, device_subclass, device_protocol, \
max_packet_size_ep0, vendor_id, product_id, device_rev_msb, device_rev_lsb, \
manufacturer_string_index, product_string_index, \
serial_number_string_index, num_configurations = struct.unpack("<xxBBBBBBHHBBBBBB", data)
serial_number_string_index, num_configurations = struct.unpack_from("<xxBBBBBBHHBBBBBB", data)

# FIXME: generate better placeholder configurations
configurations = [USBConfiguration()] * num_configurations
Expand Down
2 changes: 1 addition & 1 deletion facedancer/USBEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def from_binary_descriptor(cls, data):
"""

# Parse the core descriptor into its components...
address, attributes, max_packet_size, interval = struct.unpack("xxBBHB", data)
address, attributes, max_packet_size, interval = struct.unpack_from("xxBBHB", data)

# ... and break down the packed fields.
number = address & 0x7F
Expand Down
2 changes: 1 addition & 1 deletion facedancer/USBInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def from_binary_descriptor(cls, data):
"""
interface_number, alternate_setting, num_endpoints, interface_class, \
interface_subclass, interface_protocol, interface_string_index \
= struct.unpack("xxBBBBBBB", data)
= struct.unpack_from("xxBBBBBBB", data)
return cls(interface_number, alternate_setting, interface_class,
interface_subclass, interface_protocol, interface_string_index)

Expand Down

0 comments on commit 2281b57

Please sign in to comment.