Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # cpkunf.py - PES2018 CPK unfucker by f4r - 17/9/17 - v0.1
- # Some CPKs in PES2018 have the header about halfway though the file, like they have been cut in half and swapped.
- # I call thses "fucked" cpks. This is a quick-and-dirty un-fucker so you can browse and edit them again.
- # Unfucked CPKs are written as .unf.cpk.
- # Thanks to Tomato and Shakes.
- # This has only been tested on python2.
- import mmap
- import sys
- infile = sys.argv[1]
- outfilen = infile[:-4] + ".unf.cpk"
- with open(infile, "r+b") as f:
- mm = mmap.mmap(f.fileno(), 0)
- loc = mm.find('\x43\x50\x4b\x20\x00\x00\x00\x00')
- if loc == 0:
- print "CPK header found at offset 0, this isn't a fucked CPK. Exiting..."
- sys.exit(0)
- elif loc == -1:
- print "No valid CPK header found. Exiting..."
- sys.exit(0)
- print "CPK header found at offset", format(loc, '#04x') + ", unfucking.",
- outfile = open(outfilen, "wb")
- f.seek(loc)
- outfile.write(f.read())
- print ".",
- f.seek(0)
- outfile.write(f.read(loc))
- print ".",
- outfile.close()
- print " done."
- sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement