summaryrefslogtreecommitdiffstats
path: root/freestyle_hid
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2021-05-16 18:59:43 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2021-05-16 18:59:43 +0200
commitf6855ef1afdbe572a1acd81c9d624d74d2ccb280 (patch)
tree321b824c5eb9df319fc362c29dc6496b540d792b /freestyle_hid
parentFix tests: DeviceAddress objects cannot be joined. (diff)
downloadfreestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.tar
freestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.tar.gz
freestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.tar.bz2
freestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.tar.lz
freestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.tar.xz
freestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.tar.zst
freestyle-hid-f6855ef1afdbe572a1acd81c9d624d74d2ccb280.zip
Diffstat (limited to 'freestyle_hid')
-rw-r--r--freestyle_hid/tools/encrypted_setup_extractor.py14
-rwxr-xr-xfreestyle_hid/tools/extract_chatter.py6
2 files changed, 15 insertions, 5 deletions
diff --git a/freestyle_hid/tools/encrypted_setup_extractor.py b/freestyle_hid/tools/encrypted_setup_extractor.py
index dfe8229..cb9c416 100644
--- a/freestyle_hid/tools/encrypted_setup_extractor.py
+++ b/freestyle_hid/tools/encrypted_setup_extractor.py
@@ -7,13 +7,14 @@
import logging
import sys
-from typing import BinaryIO, Sequence
+from typing import BinaryIO, Optional, Sequence
import click
import click_log
import construct
import usbmon
import usbmon.pcapng
+from usbmon.tools import _utils
logger = logging.getLogger()
click_log.basic_config(logger)
@@ -65,13 +66,18 @@ _CHALLENGE_RESPONSE = construct.Struct(
"Device address (busnum.devnum) of the device to extract capture"
" of. If none provided, device descriptors will be relied on."
),
+ type=_utils.DeviceAddressType(),
)
@click.argument(
"pcap-files",
type=click.File(mode="rb"),
nargs=None,
)
-def main(*, device_address: str, pcap_files: Sequence[BinaryIO]):
+def main(
+ *,
+ device_address: Optional[usbmon.addresses.DeviceAddress],
+ pcap_files: Sequence[BinaryIO],
+):
if sys.version_info < (3, 7):
raise Exception("Unsupported Python version, please use at least Python 3.7.")
@@ -93,6 +99,8 @@ def main(*, device_address: str, pcap_files: Sequence[BinaryIO]):
else:
device_address = descriptor.address
+ assert device_address is not None
+
if device_address in session.device_descriptors:
descriptor = session.device_descriptors[device_address]
assert descriptor.vendor_id == _ABBOTT_VENDOR_ID
@@ -109,7 +117,7 @@ def main(*, device_address: str, pcap_files: Sequence[BinaryIO]):
if not first.type == usbmon.constants.PacketType.SUBMISSION:
continue
- if not first.address.startswith(f"{device_address}."):
+ if not first.address.device_address == device_address:
# No need to check second, they will be linked.
continue
diff --git a/freestyle_hid/tools/extract_chatter.py b/freestyle_hid/tools/extract_chatter.py
index 80e9629..5b9818d 100755
--- a/freestyle_hid/tools/extract_chatter.py
+++ b/freestyle_hid/tools/extract_chatter.py
@@ -8,7 +8,7 @@
import logging
import sys
import textwrap
-from typing import BinaryIO
+from typing import BinaryIO, Optional
import click
import click_log
@@ -17,6 +17,7 @@ import usbmon
import usbmon.chatter
import usbmon.pcapng
import usbmon.support.hid
+from usbmon.tools import _utils
logger = logging.getLogger()
click_log.basic_config(logger)
@@ -64,6 +65,7 @@ _ENCRYPTED_MESSAGE = construct.Struct(
"Device address (busnum.devnum) of the device to extract capture"
" of. If none provided, device descriptors will be relied on."
),
+ type=_utils.DeviceAddressType(),
)
@click.option(
"--encrypted-protocol / --no-encrypted-protocol",
@@ -95,7 +97,7 @@ _ENCRYPTED_MESSAGE = construct.Struct(
)
def main(
*,
- device_address: str,
+ device_address: Optional[usbmon.addresses.DeviceAddress],
encrypted_protocol: bool,
verbose_encryption_setup: bool,
print_keepalive: bool,