Subversion Repositories freemyipod

Rev

Rev 279 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 279 Rev 359
Line 21... Line 21...
21
#
21
#
22
#
22
#
23
 
23
 
24
 
24
 
25
import sys
25
import sys
-
 
26
import os
26
import struct
27
import struct
27
import time
28
import time
28
import hashlib
29
import hashlib
29
import libembios
30
import libembios
30
from libembios import Error
31
from libembios import Error
Line 90... Line 91...
90
    embios.lib.dev.timeout = 20000
91
    embios.lib.dev.timeout = 20000
91
    embios.aesdecrypt(0x08000000, len(data) - 0x800, 1)
92
    embios.aesdecrypt(0x08000000, len(data) - 0x800, 1)
92
    return embios.read(0x08000000, len(data) - 0x800)
93
    return embios.read(0x08000000, len(data) - 0x800)
93
 
94
 
94
 
95
 
-
 
96
def s5l8702genpwnage(data):
-
 
97
    cert = open(os.path.dirname(__file__) + "/libipodcrypto/s5l8702pwnage.cer", "rb").read()
-
 
98
    data = data.ljust(max(0x840, (len(data) + 0xf) & ~0xf), "\0")
-
 
99
    header = ("87021.0\x03\0\0\0\0" + struct.pack("<IIII", len(data) - 0x830, len(data) - 0x4f6, len(data) - 0x7b0, 0x2ba)).ljust(0x40, "\0")
-
 
100
    embios = libembios.Embios()
-
 
101
    embios.write(0x08000000, header + hashlib.sha1(header).digest()[:0x10])
-
 
102
    embios.lib.dev.timeout = 5000
-
 
103
    embios.aesencrypt(0x08000040, 0x10, 1)
-
 
104
    return embios.read(0x08000000, 0x50) + data + cert.ljust((len(cert) + 0xf) & ~0xf, "\0")
-
 
105
 
-
 
106
 
95
def s5l8701cryptdfufile(infile, outfile):
107
def s5l8701cryptdfufile(infile, outfile):
96
    infile = open(infile, "rb")
108
    infile = open(infile, "rb")
97
    outfile = open(outfile, "wb")
109
    outfile = open(outfile, "wb")
98
    outfile.write(s5l8701cryptdfu(infile.read()))
110
    outfile.write(s5l8701cryptdfu(infile.read()))
99
    infile.close()
111
    infile.close()
Line 136... Line 148...
136
    infile = open(infile, "rb")
148
    infile = open(infile, "rb")
137
    outfile = open(outfile, "wb")
149
    outfile = open(outfile, "wb")
138
    outfile.write(s5l8702decryptnor(infile.read()))
150
    outfile.write(s5l8702decryptnor(infile.read()))
139
    infile.close()
151
    infile.close()
140
    outfile.close()
152
    outfile.close()
-
 
153
 
-
 
154
 
-
 
155
def s5l8702genpwnagefile(infile, outfile):
-
 
156
    infile = open(infile, "rb")
-
 
157
    outfile = open(outfile, "wb")
-
 
158
    outfile.write(s5l8702genpwnage(infile.read()))
-
 
159
    infile.close()
-
 
160
    outfile.close()