-
Notifications
You must be signed in to change notification settings - Fork 1
/
pk2unpack
executable file
·50 lines (40 loc) · 918 Bytes
/
pk2unpack
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
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
from struct import *
import os
import sys
f=open(sys.argv[1])
d=f.read(4)
print "Magic:",d.encode('hex')
d=f.read(8)
print "Unk:",d.encode('hex'),unpack("II",d)
d=f.read(12)
print "Zeros:",d.encode('hex')
d=f.read(4)
print "FileCount?:",unpack("I",d)
for i in range(unpack("I",d)[0]):
d=f.read(4)
print "FILE:",d
if d == "FILE":
d=f.read(20)
print "Unk:",d.encode('hex'),unpack("5I",d)
d=f.read(4)
print "nameLen:",unpack("I",d)
len=unpack("I",d)[0]
name=f.read(len)
print "Name: ",name
d=f.read(4)
print "fileLen:",unpack("I",d)
len=unpack("I",d)[0]
d=f.read(len)
open(os.path.basename(name[:-1]),"w").write(d)
continue
if d == "CMD\000":
d=f.read(16)
print "Unk:",d.encode('hex'),unpack("4I",d)
d=f.read(4)
print "cmdLen:",unpack("I",d)
len=unpack("I",d)[0]
d=f.read(len)
open(os.path.basename("CMD"+str(len)),"w").write(d)
continue
break