Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os,sys,struct,zlib
- def get_data(filename):
- totalbytes = os.path.getsize(filename)
- infile = open(filename, 'rb')
- totalfiledata = infile.read(totalbytes)
- return totalfiledata
- if __name__ == '__main__':
- filedata = get_data(sys.argv[1])
- if filedata[:4] != 'KTZ0':
- print '%s is not compressed' % sys.argv[1]
- sys.exit()
- uncomplen = struct.unpack('>I',filedata[0x4:0x8])[0]
- pos = 0x8
- newfiledata = ''
- while pos < len(filedata) and len(newfiledata) < uncomplen:
- sectioncomplen = struct.unpack('>I',filedata[pos:pos+0x4])[0]
- newfiledata += zlib.decompress(filedata[pos+0x4:pos+0x4+sectioncomplen])
- pos += 0x4+sectioncomplen
- outfile = open(sys.argv[1].rsplit('.',1)[0] + '_new.' + sys.argv[1].rsplit('.',1)[1],'wb')
- outfile.write(newfiledata)
- outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement