18 lines
538 B
Python
18 lines
538 B
Python
#!/usr/bin/env python3
|
|
import struct, sys
|
|
|
|
d = open(sys.argv[1], 'rb').read()
|
|
print('size', len(d), 'head', d[:16])
|
|
pos = 12
|
|
while pos + 8 <= len(d) and pos < 200000:
|
|
name = d[pos:pos+4]
|
|
if not all(65 <= c <= 90 for c in name):
|
|
print(' stop at', pos, name)
|
|
break
|
|
ln_be = struct.unpack('>I', d[pos+4:pos+8])[0]
|
|
ln_le = struct.unpack('<I', d[pos+4:pos+8])[0]
|
|
print(' %s at %d len_be=%d len_le=%d' % (name.decode('latin1'), pos, ln_be, ln_le))
|
|
pos += 8 + ln_be
|
|
if ln_be > len(d):
|
|
break
|