Subversion Repositories freemyipod

Rev

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

Rev 794 Rev 860
Line 142... Line 142...
142
    emcore.aesencrypt(addr + 0x40, 0x10, 1)
142
    emcore.aesencrypt(addr + 0x40, 0x10, 1)
143
    data = emcore.read(addr, 0x50) + data + cert.ljust((len(cert) + 0xf) & ~0xf, b"\0")
143
    data = emcore.read(addr, 0x50) + data + cert.ljust((len(cert) + 0xf) & ~0xf, b"\0")
144
    emcore.free(addr)
144
    emcore.free(addr)
145
    return data
145
    return data
146
 
146
 
-
 
147
def fileoperation(infilepath, outfilepath, function):
-
 
148
    with open(infilepath, "rb") as infile:
-
 
149
        infiledata = infile.read()
-
 
150
    
-
 
151
    try:
-
 
152
        outfiledata = function(infiledata)
-
 
153
    except:
-
 
154
        os.remove(outfilepath)
-
 
155
        raise
-
 
156
    
-
 
157
    with open(outfilepath, "wb") as outfile:
-
 
158
        outfile.write(outfiledata)
147
 
159
 
148
def s5l8701cryptdfufile(infile, outfile):
160
def s5l8701cryptdfufile(infile, outfile):
149
    infile = open(infile, "rb")
-
 
150
    outfile = open(outfile, "wb")
-
 
151
    outfile.write(s5l8701cryptdfu(infile.read()))
161
    fileoperation(infile, outfile, s5l8701cryptdfu)
152
    infile.close()
-
 
153
    outfile.close()
-
 
154
 
-
 
155
 
162
 
156
def s5l8701decryptdfufile(infile, outfile):
163
def s5l8701decryptdfufile(infile, outfile):
157
    infile = open(infile, "rb")
-
 
158
    outfile = open(outfile, "wb")
-
 
159
    outfile.write(s5l8701decryptdfu(infile.read()))
164
    fileoperation(infile, outfile, s5l8701decryptdfu)
160
    infile.close()
-
 
161
    outfile.close()
-
 
162
 
-
 
163
 
165
 
164
def s5l8701cryptfirmwarefile(infile, outfile):
166
def s5l8701cryptfirmwarefile(infile, outfile):
165
    infile = open(infile, "rb")
-
 
166
    outfile = open(outfile, "wb")
-
 
167
    outfile.write(s5l8701cryptfirmware(infile.read()))
167
    fileoperation(infile, outfile, s5l8701cryptfirmware)
168
    infile.close()
-
 
169
    outfile.close()
-
 
170
 
-
 
171
 
168
 
172
def s5l8701decryptfirmwarefile(infile, outfile):
169
def s5l8701decryptfirmwarefile(infile, outfile):
173
    infile = open(infile, "rb")
-
 
174
    outfile = open(outfile, "wb")
-
 
175
    outfile.write(s5l8701decryptfirmware(infile.read()))
170
    fileoperation(infile, outfile, s5l8701decryptfirmware)
176
    infile.close()
-
 
177
    outfile.close()
-
 
178
 
-
 
179
 
171
 
180
def s5l8702cryptnorfile(infile, outfile):
172
def s5l8702cryptnorfile(infile, outfile):
181
    infile = open(infile, "rb")
-
 
182
    outfile = open(outfile, "wb")
-
 
183
    outfile.write(s5l8702cryptnor(infile.read()))
173
    fileoperation(infile, outfile, s5l8702cryptnor)
184
    infile.close()
-
 
185
    outfile.close()
-
 
186
 
-
 
187
 
174
 
188
def s5l8702decryptnorfile(infile, outfile):
175
def s5l8702decryptnorfile(infile, outfile):
189
    infile = open(infile, "rb")
-
 
190
    outfile = open(outfile, "wb")
-
 
191
    outfile.write(s5l8702decryptnor(infile.read()))
176
    fileoperation(infile, outfile, s5l8702decryptnor)
192
    infile.close()
-
 
193
    outfile.close()
-
 
194
 
-
 
195
 
177
 
196
def s5l8702genpwnagefile(infile, outfile):
178
def s5l8702genpwnagefile(infile, outfile):
197
    infile = open(infile, "rb")
-
 
198
    outfile = open(outfile, "wb")
-
 
199
    outfile.write(s5l8702genpwnage(infile.read()))
179
    fileoperation(infile, outfile, s5l8702genpwnage)
200
    infile.close()
-
 
201
    outfile.close()
-
 
202
 
-
 
203
 
180
 
204
def s5l8702genpwnagefile800(infile, outfile):
181
def s5l8702genpwnagefile800(infile, outfile):
205
    infile = open(infile, "rb")
-
 
206
    outfile = open(outfile, "wb")
-
 
207
    outfile.write(s5l8702genpwnage800(infile.read()))
182
    fileoperation(infile, outfile, s5l8702genpwnage800)
208
    infile.close()
-
 
209
    outfile.close()
-
 
210
 
-
 
211
 
183
 
212
def s5l8720genpwnagefile(infile, outfile):
184
def s5l8720genpwnagefile(infile, outfile):
213
    infile = open(infile, "rb")
-
 
214
    outfile = open(outfile, "wb")
-
 
215
    outfile.write(s5l8720genpwnage(infile.read()))
185
    fileoperation(infile, outfile, s5l8720genpwnage)
216
    infile.close()
-
 
217
    outfile.close()
-