-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameexeUnpacker.py
42 lines (34 loc) · 981 Bytes
/
GameexeUnpacker.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
40
41
42
# -*- coding: utf-8 -*-
# For Windows OS Only....
import sys
import os
import struct
from Decryption import Decrypt1,Decrypt4,Decompress
def main(argv,key):
if len(argv)<2 or argv[1]=='':
print ("Usage: "+argv[0][argv[0].rfind("\\")+1:]+" <Gameexe.dat> [Gameexe.ini]")
return False
if len(argv)<3 or argv[2]=='':
outFN="Gameexe.ini"
else:
outFN=argv[2]
try:
f=open(argv[1],'rb')
f.read()
f.close()
except:
return False
gameexe=open(argv[1],'rb')
header=gameexe.read(4)
needKey=gameexe.read(4)
data=Decrypt4(gameexe.read())
if needKey==b'\x01\x00\x00\x00':
data=Decrypt1(data,key)
compSize,decompSize=struct.unpack('2I',data[:8])
data=Decompress(data[8:],decompSize)
output=open(outFN,'wb')
output.write(b'\xff\xfe'+data)
output.close()
return True
if __name__=="__main__":
main(sys.argv,[])