From edc9c04b9a3d32ed50d1ce810afd5fc526099893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Fri, 24 Jan 2020 20:06:37 +0000 Subject: extract_freestyle: add an option to not print keepalive messages. These messages are not encrypted, but they can also be safely ignored. --- reversing_tools/abbott/extract_freestyle.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'reversing_tools') diff --git a/reversing_tools/abbott/extract_freestyle.py b/reversing_tools/abbott/extract_freestyle.py index 39c52ad..69f0d02 100755 --- a/reversing_tools/abbott/extract_freestyle.py +++ b/reversing_tools/abbott/extract_freestyle.py @@ -25,8 +25,15 @@ import usbmon import usbmon.chatter import usbmon.pcapng +_KEEPALIVE_TYPE = 0x22 + _UNENCRYPTED_TYPES = ( - 0x01, 0x04, 0x05, 0x06, 0x0c, 0x0d, 0x14, 0x15, 0x33, 0x34, 0x35, 0x71,) + 0x01, 0x04, 0x05, 0x06, 0x0c, 0x0d, + 0x14, 0x15, + 0x33, 0x34, 0x35, + 0x71, + _KEEPALIVE_TYPE, +) def main(): if sys.version_info < (3, 7): @@ -52,6 +59,11 @@ def main(): 'Libre 2 devices encrypt some of the messages, and as such they ' 'will be dumped with the undecoded length as well.')) + parser.add_argument( + '--print_keepalive', action='store_true', + help=('Whether to print the keepalive messages sent by the device. ' + 'Keepalive messages are usually safely ignored.')) + parser.add_argument( 'pcap_file', action='store', type=str, help='Path to the pcapng file with the USB capture.') @@ -91,6 +103,9 @@ def main(): message_type = packet.payload[0] + if message_type == _KEEPALIVE_TYPE and not args.print_keepalive: + continue + if args.libre2 and message_type not in _UNENCRYPTED_TYPES: # On Libre 2 (expected encrypted communication), we ignore the # message_length and we keep it with the whole message. -- cgit v1.2.3