Harald Welte | 04fe6b5 | 2020-06-20 21:05:31 +0200 | [diff] [blame] | 1 | #!/usr/bin/python3 |
2 | |||||
3 | # parses the output of strace and stroes the binary writes to a file | ||||
4 | |||||
5 | import re, binascii | ||||
6 | from struct import * | ||||
7 | |||||
8 | |||||
9 | p = re.compile('read\(\d+, "(.*)", \d+\) = \d+') | ||||
10 | |||||
11 | fi = open("e1_ts2_short.log", "r") | ||||
12 | fo = open("e1_ts2_short.bin", "wb") | ||||
13 | |||||
14 | for line in fi: | ||||
15 | m = p.match(line) | ||||
16 | data = m.group(1) | ||||
17 | snippets = [data[2+i:4+i] for i in range(0, len(data), 4)] | ||||
18 | for s in snippets: | ||||
19 | b = binascii.unhexlify(s) | ||||
20 | fo.write(b) |