May 21st, 2022
775
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from pprint import pprint
2. import struct
3.
4. # H - uint16    2
5. # h - int16     2
6. # I - uint32    4
7. # i - int32     4
8. # b - int8      1
9. # B - uint8     1
10. # q - int64     8
11. # Q - uint64    8
12. # f - float     4
13. # c - char      1
14. # d - double    8
15.
16. pointer = 4
17.
18.
19. def structA(data):
20.     A = {}
21.     global pointer
22.     A['A1'] = struct.unpack('>H', data[pointer:pointer + 2])[0]
23.     pointer += 2
24.     # print(A['A1'])
25.     A['A2'] = []
26.     size = struct.unpack('>H', data[pointer:pointer + 2])[0]
27.     pointer += 2
28.     address = struct.unpack('>H', data[pointer:pointer + 2])[0]
29.     pointer += 2
30.     for i in range(size):
31.         b = struct.unpack('>I', data[address + i * 4:address + 4 + i * 4])[0]
32.         A['A2'].append(b)
33.     for i in range(size):
34.         A['A2'][i] = structB(data, A['A2'][i])
35.     address = struct.unpack('>H', data[pointer:pointer + 2])[0]
36.     pointer += 2
38.     A['A4'] = struct.unpack('>i', data[pointer:pointer + 4])[0]
39.     pointer += 4
40.     return A
41.
42.
44.     B = {}
49.     return B
50.
51.
53.     C = {}
54.     C['C1'] = []
55.     for i in range(4):
69.     return C
70.
71.
73.     D = {}
78.     return D
79.
80.
82.     E = {}
87.     E['E1'] = []
88.     for i in range(size):
89.         b = struct.unpack('>i', data[address_2 + i * 4:address_2 + i * 4 + 4])
90.         E['E1'].append(b[0])
91.     address_2 += 4 * size
96.     E['E2'] = []
97.     for i in range(size):
99.         E['E2'].append(b[0])
104.     return E
105.
106.
108.     F = {}
115.     F['F4'] = []
116.     for i in range(5):
119.     return F
120.
121.
122. # d = (b'YXXBI\xfa\x00\x02\x00\x16\x00]S#\xa0\xf1\xab/;\xbc\xaf\xe2\x00\x00'
123. #      b'\x00\x10\x00\x00\x00\x13\x03\x89\x92\xa0\xec\xb6\x86\x8aS\xba\xc2\xc4\xe35'
124. #      b'\xf9\x88\xbd\x9c\x07\xcd\xfeX\x1c1\xe1\xe1\x00\x00\x00\x06\x00\x00\x00\x1e'
125. #      b'\x00\x00\x00\x02\x006\xf1\x08?\x10s\xaa\x85W\xbe\xbe\xc4\xc4?3\xfb.\xac\x91'
126. #      b'\x93k)/\xcc\xfe?\xda5\xd1\x80\xc5\xc60\x8b?\xe9T\x1c\x11Xu\x04!\xbf\xcazw'
127. #      b'6\xe7\xb4\xf0H\xbf\xe6\xa0\xd5\xe6\xacRl\x19\x008\xbf\xe8\xd2\xa0\xf2n\xe5Z'
128. #      b'\x00N')
129.
130.
131. def main(d):
132.     return structA(d)
133.