Created
May 29, 2020 12:21
-
-
Save darthcloud/1316ba802d33dab32f90a29ab915e440 to your computer and use it in GitHub Desktop.
Bluetooth H4 raw binary trace to Wireshark's text2pcap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
with open(sys.argv[1], "rb") as f: | |
byte = f.read(1) | |
while byte: | |
if int(byte[0]) == 0x01: | |
byte += f.read(3) | |
byte += f.read(int(byte[3])) | |
print('O 00000 ' + ''.join('{:02x} '.format(x) for x in byte)) | |
elif int(byte[0]) == 0x02: | |
byte += f.read(4) | |
byte += f.read(int(byte[3]) | (int(byte[4]) << 4)) | |
print('00000 ' + ''.join('{:02x} '.format(x) for x in byte)) | |
elif int(byte[0]) == 0x04: | |
byte += f.read(2) | |
byte += f.read(int(byte[2])) | |
print('I 00000 ' + ''.join('{:02x} '.format(x) for x in byte)) | |
byte = f.read(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment