| Index: emcore/trunk/tools/ipodcrypt.py |
| — | — | @@ -27,18 +27,19 @@ |
| 28 | 28 |
|
| 29 | 29 |
|
| 30 | 30 | 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>"
|
| 43 | 44 | exit(2)
|
| 44 | 45 |
|
| 45 | 46 |
|
| — | — | @@ -66,6 +67,9 @@ |
| 67 | 68 | elif argv[1] == "s5l8702-genpwnage":
|
| 68 | 69 | libipodcrypto.s5l8702genpwnagefile(argv[2], argv[3])
|
| 69 | 70 |
|
| | 71 | + elif argv[1] == "s5l8702-genpwnage800":
|
| | 72 | + libipodcrypto.s5l8702genpwnagefile800(argv[2], argv[3])
|
| | 73 | +
|
| 70 | 74 | elif argv[1] == "s5l8720-genpwnage":
|
| 71 | 75 | libipodcrypto.s5l8720genpwnagefile(argv[2], argv[3])
|
| 72 | 76 |
|
| Index: emcore/trunk/tools/libipodcrypto.py |
| — | — | @@ -119,6 +119,19 @@ |
| 120 | 120 | return data
|
| 121 | 121 |
|
| 122 | 122 |
|
| | 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 | +
|
| 123 | 136 | def s5l8720genpwnage(data):
|
| 124 | 137 | cert = open(os.path.dirname(__file__) + "/libipodcrypto/s5l8720pwnage.cer", "rb").read()
|
| 125 | 138 | data = data.ljust(max(0x640, (len(data) + 0xf) & ~0xf), b"\0")
|
| — | — | @@ -188,6 +201,14 @@ |
| 189 | 202 | outfile.close()
|
| 190 | 203 |
|
| 191 | 204 |
|
| | 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 | +
|
| 192 | 213 | def s5l8720genpwnagefile(infile, outfile):
|
| 193 | 214 | infile = open(infile, "rb")
|
| 194 | 215 | outfile = open(outfile, "wb")
|