-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpvr-extractor.py
executable file
·39 lines (32 loc) · 1.09 KB
/
pvr-extractor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import sys, bitstring
import struct
print("Handline "+sys.argv[1])
infile = open(sys.argv[1],'rb')
data = infile.read()
datad = bitstring.BitArray(data)
slices = datad.split('0x47424958')
i = 0
next(slices)
for slic in slices:
gbix_header_size=4
gbix_header_loc=0
gbix_header = slic[gbix_header_loc*8:(gbix_header_loc+gbix_header_size)*8]
gbix_len_loc = gbix_header_loc + gbix_header_size
gbix_len_size = 4
gbix_len = slic[gbix_len_loc*8:(gbix_len_loc+gbix_len_size)*8]
gbix_len_int = gbix_len.uintle
pvrt_header_loc = gbix_header_loc + gbix_header_size + gbix_len_size + gbix_len_int
pvrt_header_size = 4
pvrt_header = slic[(pvrt_header_loc)*8:(pvrt_header_loc+pvrt_header_size)*8]
pvrt_len_loc = pvrt_header_loc + pvrt_header_size
pvrt_len_size = 4
pvrt_len = slic[(pvrt_len_loc)*8:(pvrt_len_loc+pvrt_len_size)*8]
pvrt_len_int = pvrt_len.uintle
data = slic[0:(gbix_header_size+gbix_len_size+gbix_len_int +
pvrt_header_size+pvrt_len_size+pvrt_len_int)*8]
f = open(sys.argv[1]+'_text'+str(i).zfill(7)+'.pvr', 'wb')
data.tofile(f)
f.close()
i += 1
infile.close()