freemyipod r793 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r792‎ | r793 | r794 >
Date:00:36, 19 November 2011
Author:theseven
Status:new
Tags:
Comment:
(lib)ipodcrypto.py: Add s5l8702-genpwnage800 command
Modified paths:
  • /emcore/trunk/tools/ipodcrypt.py (modified) (history)
  • /emcore/trunk/tools/libipodcrypto.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/ipodcrypt.py
@@ -27,18 +27,19 @@
2828
2929
3030 def usage():
31 - print("")
32 - print("Please provide a command and (if needed) parameters as command line arguments")
33 - print("")
34 - print("Available commands:")
35 - print(" s5l8701-cryptdfu <infile> <outfile>")
36 - print(" s5l8701-decryptdfu <infile> <outfile>")
37 - print(" s5l8701-cryptfirmware <infile> <outfile>")
38 - print(" s5l8701-decryptfirmware <infile> <outfile>")
39 - print(" s5l8702-cryptnor <infile> <outfile>")
40 - print(" s5l8702-decryptnor <infile> <outfile>")
41 - print(" s5l8702-genpwnage <infile> <outfile>")
42 - print(" s5l8720-genpwnage <infile> <outfile>")
 31+ print ""
 32+ print "Please provide a command and (if needed) parameters as command line arguments"
 33+ print ""
 34+ print "Available commands:"
 35+ print " s5l8701-cryptdfu <infile> <outfile>"
 36+ print " s5l8701-decryptdfu <infile> <outfile>"
 37+ print " s5l8701-cryptfirmware <infile> <outfile>"
 38+ print " s5l8701-decryptfirmware <infile> <outfile>"
 39+ print " s5l8702-cryptnor <infile> <outfile>"
 40+ print " s5l8702-decryptnor <infile> <outfile>"
 41+ print " s5l8702-genpwnage <infile> <outfile>"
 42+ print " s5l8702-genpwnage800 <infile> <outfile>"
 43+ print " s5l8720-genpwnage <infile> <outfile>"
4344 exit(2)
4445
4546
@@ -66,6 +67,9 @@
6768 elif argv[1] == "s5l8702-genpwnage":
6869 libipodcrypto.s5l8702genpwnagefile(argv[2], argv[3])
6970
 71+ elif argv[1] == "s5l8702-genpwnage800":
 72+ libipodcrypto.s5l8702genpwnagefile800(argv[2], argv[3])
 73+
7074 elif argv[1] == "s5l8720-genpwnage":
7175 libipodcrypto.s5l8720genpwnagefile(argv[2], argv[3])
7276
Index: emcore/trunk/tools/libipodcrypto.py
@@ -119,6 +119,19 @@
120120 return data
121121
122122
 123+def s5l8702genpwnage800(data):
 124+ cert = open(os.path.dirname(__file__) + "/libipodcrypto/s5l8702pwnage.cer", "rb").read()
 125+ data = data.ljust(max(0x90, (len(data) + 0xf) & ~0xf), b"\0")
 126+ header = (b"87021.0\x03\0\0\0\0" + struct.pack("<IIII", len(data) - 0x80, len(data) + 0x2ba, len(data), 0x2ba)).ljust(0x40, b"\0")
 127+ emcore = libemcore.Emcore()
 128+ addr = emcore.memalign(0x10, len(data))
 129+ emcore.write(addr, header + hashlib.sha1(header).digest()[:0x10])
 130+ emcore.aesencrypt(addr + 0x40, 0x10, 1)
 131+ data = emcore.read(addr, 0x50).ljust(0x800, b"\0") + data + cert.ljust((len(cert) + 0xf) & ~0xf, b"\0")
 132+ emcore.free(addr)
 133+ return data
 134+
 135+
123136 def s5l8720genpwnage(data):
124137 cert = open(os.path.dirname(__file__) + "/libipodcrypto/s5l8720pwnage.cer", "rb").read()
125138 data = data.ljust(max(0x640, (len(data) + 0xf) & ~0xf), b"\0")
@@ -188,6 +201,14 @@
189202 outfile.close()
190203
191204
 205+def s5l8702genpwnagefile800(infile, outfile):
 206+ infile = open(infile, "rb")
 207+ outfile = open(outfile, "wb")
 208+ outfile.write(s5l8702genpwnage800(infile.read()))
 209+ infile.close()
 210+ outfile.close()
 211+
 212+
192213 def s5l8720genpwnagefile(infile, outfile):
193214 infile = open(infile, "rb")
194215 outfile = open(outfile, "wb")