Skip to content

Instantly share code, notes, and snippets.

@ezterry
Created January 5, 2012 15:09
Show Gist options
  • Save ezterry/1565640 to your computer and use it in GitHub Desktop.
Save ezterry/1565640 to your computer and use it in GitHub Desktop.
Python Script to decode ACER update zips (With auto 16bit key detection)
#!/usr/bin/python
#Acer update zip decoder
#Based on information in this post/thread:
#http://forum.xda-developers.com/showpost.php?p=14201285&postcount=161
#As well as "new key" information in
#http://forum.xda-developers.com/showpost.php?p=14505451&postcount=31
import sys
import os
import struct
ZIPHEADER = "PK"
def main():
if(len(sys.argv) != 3):
print("Usage:")
print(sys.argv[0] + " <input encoded zip> <output decoded zip>")
return
infile=open(sys.argv[1],"rb")
outfile=open(sys.argv[2],"wb")
(key,) = struct.unpack("=H",infile.read(2))
(seed,) = struct.unpack("=H",ZIPHEADER)
key = key ^ seed
print("key= " + hex(key))
infile.seek(0)
sys.stdout.write("\n\rReading: " + str(0) )
buf=infile.read(512)
pos=512
while(buf != ""):
droplast = len(buf) % 2
if(droplast):
buf=buf + " "
block=""
for x in xrange(0,len(buf),2) :
(val,)=struct.unpack("=H",buf[x:x+2])
block=block+struct.pack("=H",(key ^ val) & 0x0000FFFF)
if(droplast):
block=block[:-1]
outfile.write(block)
sys.stdout.write("\rReading: " + str(pos) )
pos+=512
buf=infile.read(512)
infile.close()
outfile.close()
print("\nDone :)")
if(__name__=="__main__"):
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment