Initial commit
This commit is contained in:
11
pywii/pywii-tools/addhash.py
Executable file
11
pywii/pywii-tools/addhash.py
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import re
|
||||
import pywii as wii
|
||||
|
||||
hash = wii.SHA.new(open(sys.argv[2]).read()).digest().encode("hex")
|
||||
f = open(sys.argv[1], "r")
|
||||
data = f.read()
|
||||
f.close()
|
||||
data = re.sub('@SHA1SUM@', hash, data)
|
||||
open(sys.argv[3], "w").write(data)
|
||||
15
pywii/pywii-tools/arclist.py
Executable file
15
pywii/pywii-tools/arclist.py
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path, struct
|
||||
import pywii as wii
|
||||
|
||||
arc = open(sys.argv[1], "rb")
|
||||
|
||||
tag, fstoff, fstsize, dataoff = struct.unpack(">IIII16x",arc.read(0x20))
|
||||
|
||||
arc.seek(fstoff)
|
||||
fst = arc.read(fstsize)
|
||||
|
||||
fst = wii.WiiFST(fst)
|
||||
|
||||
fst.show()
|
||||
26
pywii/pywii-tools/arcpack.py
Executable file
26
pywii/pywii-tools/arcpack.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path, struct
|
||||
import pywii as wii
|
||||
|
||||
fstb = wii.WiiFSTBuilder(0x20)
|
||||
|
||||
fstb.addfrom(sys.argv[2])
|
||||
|
||||
arc = open(sys.argv[1],"wb")
|
||||
# dummy generate to get length
|
||||
fstlen = len(fstb.fst.generate())
|
||||
dataoff = wii.align(0x20+fstlen,0x20)
|
||||
fst = fstb.fst.generate(dataoff)
|
||||
|
||||
hdr = struct.pack(">IIII16x",0x55AA382d,0x20,fstlen,dataoff)
|
||||
arc.write(hdr)
|
||||
|
||||
arc.write(fst)
|
||||
wii.falign(arc,0x20)
|
||||
for f in fstb.files:
|
||||
data = open(f, "rb").read()
|
||||
arc.write(data)
|
||||
wii.falign(arc,0x20)
|
||||
|
||||
arc.close()
|
||||
26
pywii/pywii-tools/certinfo.py
Executable file
26
pywii/pywii-tools/certinfo.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args[0] == "-dpki":
|
||||
wii.loadkeys_dpki()
|
||||
args.pop(0)
|
||||
else:
|
||||
wii.loadkeys()
|
||||
|
||||
certfile = args.pop(0)
|
||||
|
||||
certs, certlist = wii.parse_certs(open(args.pop(0), "rb").read())
|
||||
|
||||
print "Certification file %s: " % certfile
|
||||
cert = wii.WiiCert(open(certfile, "rb").read())
|
||||
cert.showinfo(" ")
|
||||
cert.showsig(certs," ")
|
||||
|
||||
print "Certificates:"
|
||||
for cert in certlist:
|
||||
cert.showinfo(" - ")
|
||||
cert.showsig(certs," ")
|
||||
28
pywii/pywii-tools/discinfo.py
Executable file
28
pywii/pywii-tools/discinfo.py
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
isofile = sys.argv[1]
|
||||
disc = wii.WiiDisc(isofile,readonly=True)
|
||||
disc.showinfo()
|
||||
|
||||
partitions = disc.read_partitions()
|
||||
|
||||
parts = range(len(partitions))
|
||||
|
||||
try:
|
||||
pnum = int(sys.argv[2])
|
||||
partitions[pnum]
|
||||
parts = [pnum]
|
||||
except:
|
||||
pass
|
||||
|
||||
for partno in parts:
|
||||
part = wii.WiiCachedPartition(disc,partno)
|
||||
part.showinfo()
|
||||
pdat = wii.WiiPartitionData(part)
|
||||
pdat.showinfo()
|
||||
|
||||
35
pywii/pywii-tools/dpkisign.py
Executable file
35
pywii/pywii-tools/dpkisign.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii
|
||||
|
||||
pywii.loadkeys_dpki()
|
||||
|
||||
args = sys.argv[1:]
|
||||
mode = args.pop(0)
|
||||
infile = args.pop(0)
|
||||
outfile = args.pop(0)
|
||||
certfile = args.pop(0)
|
||||
issuer = args.pop(0)
|
||||
|
||||
if sys.argv[1] == "-cetk":
|
||||
signed = pywii.WiiTik(open(infile, "rb").read())
|
||||
elif sys.argv[1] == "-tmd":
|
||||
signed = pywii.WiiTmd(open(infile, "rb").read())
|
||||
else:
|
||||
print "EYOUFAILIT"
|
||||
sys.exit(1)
|
||||
|
||||
certs, certlist = pywii.parse_certs(open(certfile).read())
|
||||
|
||||
signed.update_issuer(issuer)
|
||||
|
||||
if not signed.sign(certs):
|
||||
print "dpki signing failed"
|
||||
sys.exit(1)
|
||||
|
||||
open(outfile, "wb").write(signed.data)
|
||||
|
||||
print "successfully signed %s" % outfile
|
||||
sys.exit(0)
|
||||
|
||||
57
pywii/pywii-tools/ecchecksig.py
Executable file
57
pywii/pywii-tools/ecchecksig.py
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import pywii as wii
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print "Usage: %s keyfile.[priv|pub] infile"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1] == "-":
|
||||
k = sys.stdin.read()
|
||||
else:
|
||||
k = open(sys.argv[1],"rb").read()
|
||||
if len(k) not in (30,60):
|
||||
print "Failed to read key"
|
||||
sys.exit(2)
|
||||
|
||||
if len(k) == 30:
|
||||
print "Key is a private key, generating public key..."
|
||||
q = wii.ec.priv_to_pub(k)
|
||||
else:
|
||||
q = k
|
||||
|
||||
print "Public key:"
|
||||
pq = q.encode('hex')
|
||||
print "X =",pq[:30]
|
||||
print " ",pq[30:60]
|
||||
print "Y =",pq[60:90]
|
||||
print " ",pq[90:]
|
||||
print
|
||||
|
||||
indata = open(sys.argv[2],"rb").read()
|
||||
|
||||
if len(indata) < 64 or indata[:4] != "SIG0":
|
||||
print "Invalid header"
|
||||
sys.exit(3)
|
||||
|
||||
r = indata[4:34]
|
||||
s = indata[34:64]
|
||||
|
||||
sha = wii.SHA.new(indata[64:]).digest()
|
||||
print "SHA1: %s"%sha.encode('hex')
|
||||
|
||||
print
|
||||
print "Signature:"
|
||||
print "R =",r[:15].encode('hex')
|
||||
print " ",r[15:].encode('hex')
|
||||
print "S =",s[:15].encode('hex')
|
||||
print " ",s[15:].encode('hex')
|
||||
print
|
||||
|
||||
if wii.ec.check_ecdsa(q,r,s,sha):
|
||||
print "Signature is VALID"
|
||||
else:
|
||||
print "Signature is INVALID"
|
||||
sys.exit(4)
|
||||
|
||||
33
pywii/pywii-tools/ecgenpriv.py
Executable file
33
pywii/pywii-tools/ecgenpriv.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os
|
||||
import pywii as wii
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print "Usage: %s keyfile.priv"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
print "Generating private key..."
|
||||
|
||||
k = wii.ec.gen_priv_key()
|
||||
|
||||
print "Private key:"
|
||||
pk = k.encode('hex')
|
||||
print "K =",pk[:30]
|
||||
print " ",pk[30:]
|
||||
|
||||
print
|
||||
print "Corresponding public key:"
|
||||
q = wii.ec.priv_to_pub(k)
|
||||
pq = q.encode('hex')
|
||||
print "X =",pq[:30]
|
||||
print " ",pq[30:60]
|
||||
print "Y =",pq[60:90]
|
||||
print " ",pq[90:]
|
||||
|
||||
fd = open(sys.argv[1],"wb")
|
||||
os.fchmod(fd.fileno(), 0o600)
|
||||
fd.write(k)
|
||||
fd.close()
|
||||
|
||||
print "Saved private key to %s"%sys.argv[1]
|
||||
30
pywii/pywii-tools/ecpriv2pub.py
Executable file
30
pywii/pywii-tools/ecpriv2pub.py
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import pywii as wii
|
||||
|
||||
if len(sys.argv) not in (2,3):
|
||||
print "Usage: %s keyfile.priv [keyfile.pub]"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1] == "-":
|
||||
k = sys.stdin.read()
|
||||
else:
|
||||
k = open(sys.argv[1],"rb").read()
|
||||
if len(k) != 30:
|
||||
print "Failed to read private key"
|
||||
sys.exit(2)
|
||||
|
||||
print "Public key:"
|
||||
q = wii.ec.priv_to_pub(k)
|
||||
pq = q.encode('hex')
|
||||
print "X =",pq[:30]
|
||||
print " ",pq[30:60]
|
||||
print "Y =",pq[60:90]
|
||||
print " ",pq[90:]
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
fd = open(sys.argv[2],"wb")
|
||||
fd.write(q)
|
||||
fd.close()
|
||||
print "Saved public key to %s"%sys.argv[2]
|
||||
35
pywii/pywii-tools/ecsign.py
Executable file
35
pywii/pywii-tools/ecsign.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import pywii as wii
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print "Usage: %s keyfile.priv infile outfile"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1] == "-":
|
||||
k = sys.stdin.read()
|
||||
else:
|
||||
k = open(sys.argv[1],"rb").read()
|
||||
|
||||
if len(k) != 30:
|
||||
print "Failed to read private key"
|
||||
sys.exit(2)
|
||||
|
||||
indata = open(sys.argv[2],"rb").read()
|
||||
sha = wii.SHA.new(indata).digest()
|
||||
|
||||
print "SHA1: %s"%sha.encode('hex')
|
||||
print
|
||||
print "Signature:"
|
||||
r,s = wii.ec.generate_ecdsa(k,sha)
|
||||
print "R =",r[:15].encode('hex')
|
||||
print " ",r[15:].encode('hex')
|
||||
print "S =",s[:15].encode('hex')
|
||||
print " ",s[15:].encode('hex')
|
||||
|
||||
outdata = "SIG0" + r + s + indata
|
||||
|
||||
fd = open(sys.argv[3],"wb")
|
||||
fd.write(outdata)
|
||||
fd.close()
|
||||
59
pywii/pywii-tools/extract.py
Executable file
59
pywii/pywii-tools/extract.py
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
def parseint(d):
|
||||
if len(d) > 2 and d[0:2].lower()=='0x':
|
||||
return int(d,16)
|
||||
return int(d)
|
||||
|
||||
if len(sys.argv) < 4 or len(sys.argv) > 7:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <file to extract to> [Partition offset] [length]"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, data_name = sys.argv[1:4]
|
||||
partno = int(partno)
|
||||
part_offset = 0
|
||||
data_offset = 0
|
||||
copy_length = None
|
||||
|
||||
if len(sys.argv) >= 5:
|
||||
part_offset = parseint(sys.argv[4])
|
||||
if len(sys.argv) == 6:
|
||||
copy_length = parseint(sys.argv[5])
|
||||
|
||||
if copy_length is not None and copy_length < 0:
|
||||
print "Error: negative copy length"
|
||||
sys.exit(1)
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False, checkhash=False)
|
||||
if part_offset >= part.data_bytes:
|
||||
print "Error: Offset past end of partition"
|
||||
sys.exit(1)
|
||||
if copy_length is None:
|
||||
copy_length = part.data_bytes - part_offset
|
||||
if copy_length > (part.data_bytes - part_offset):
|
||||
print "Error: Length too large"
|
||||
sys.exit(1)
|
||||
|
||||
dataf = open(data_name, "wb")
|
||||
left = copy_length
|
||||
offset = part_offset
|
||||
while left > 0:
|
||||
blocklen = min(left, 4*1024*1024)
|
||||
d = part.read(offset, blocklen)
|
||||
if len(d) != blocklen:
|
||||
print "Part EOF reached!"
|
||||
sys.exit(1)
|
||||
dataf.write(d)
|
||||
offset += blocklen
|
||||
left -= blocklen
|
||||
|
||||
dataf.close()
|
||||
|
||||
26
pywii/pywii-tools/extractdol.py
Executable file
26
pywii/pywii-tools/extractdol.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys, os, os.path
|
||||
sys.path.append(os.path.realpath(os.path.dirname(sys.argv[0]))+"/../Common")
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys(os.environ["HOME"]+os.sep+".wii")
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <dol output>"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, dol_name = sys.argv[1:4]
|
||||
partno = int(partno)
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False)
|
||||
partdata = wii.WiiPartitionData(part)
|
||||
|
||||
dolf = open(dol_name, "wb")
|
||||
dolf.write(partdata.dol)
|
||||
dolf.close()
|
||||
|
||||
|
||||
59
pywii/pywii-tools/extractfiles.py
Normal file
59
pywii/pywii-tools/extractfiles.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
def parseint(d):
|
||||
if len(d) > 2 and d[0:2].lower()=='0x':
|
||||
return int(d,16)
|
||||
return int(d)
|
||||
|
||||
if len(sys.argv) < 4 or len(sys.argv) > 7:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <root path to extract to> "%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, data_name = sys.argv[1:4]
|
||||
partno = int(partno)
|
||||
part_offset = 0
|
||||
data_offset = 0
|
||||
copy_length = None
|
||||
|
||||
if len(sys.argv) >= 5:
|
||||
part_offset = parseint(sys.argv[4])
|
||||
if len(sys.argv) == 6:
|
||||
copy_length = parseint(sys.argv[5])
|
||||
|
||||
if copy_length is not None and copy_length < 0:
|
||||
print "Error: negative copy length"
|
||||
sys.exit(1)
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False, checkhash=False)
|
||||
if part_offset >= part.data_bytes:
|
||||
print "Error: Offset past end of partition"
|
||||
sys.exit(1)
|
||||
if copy_length is None:
|
||||
copy_length = part.data_bytes - part_offset
|
||||
if copy_length > (part.data_bytes - part_offset):
|
||||
print "Error: Length too large"
|
||||
sys.exit(1)
|
||||
|
||||
dataf = open(data_name, "wb")
|
||||
left = copy_length
|
||||
offset = part_offset
|
||||
while left > 0:
|
||||
blocklen = min(left, 4*1024*1024)
|
||||
d = part.read(offset, blocklen)
|
||||
if len(d) != blocklen:
|
||||
print "Part EOF reached!"
|
||||
sys.exit(1)
|
||||
dataf.write(d)
|
||||
offset += blocklen
|
||||
left -= blocklen
|
||||
|
||||
dataf.close()
|
||||
|
||||
24
pywii/pywii-tools/getappldr.py
Executable file
24
pywii/pywii-tools/getappldr.py
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
if len(sys.argv) != 5:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <apploader text> <apploader trailer>"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, app_name, trail_name = sys.argv[1:5]
|
||||
partno = int(partno)
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False)
|
||||
partdata = wii.WiiPartitionData(part)
|
||||
|
||||
apploader = partdata.apploader
|
||||
apploader.showinfo()
|
||||
open(app_name,"wb").write(apploader.text)
|
||||
open(trail_name,"wb").write(apploader.trailer)
|
||||
68
pywii/pywii-tools/inject.py
Executable file
68
pywii/pywii-tools/inject.py
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
def parseint(d):
|
||||
if len(d) > 2 and d[0:2].lower()=='0x':
|
||||
return int(d,16)
|
||||
return int(d)
|
||||
|
||||
if len(sys.argv) < 4 or len(sys.argv) > 7:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <file to inject> [Partition offset] [data offset] [length]"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, data_name = sys.argv[1:4]
|
||||
partno = int(partno)
|
||||
part_offset = 0
|
||||
data_offset = 0
|
||||
copy_length = None
|
||||
|
||||
if len(sys.argv) >= 5:
|
||||
part_offset = parseint(sys.argv[4])
|
||||
if len(sys.argv) >= 6:
|
||||
data_offset = parseint(sys.argv[5])
|
||||
if len(sys.argv) == 7:
|
||||
copy_length = parseint(sys.argv[6])
|
||||
|
||||
data_len = os.stat(data_name).st_size
|
||||
|
||||
if copy_length == None:
|
||||
copy_length = data_len - data_offset
|
||||
copy_end = data_offset + copy_length
|
||||
if copy_length < 0:
|
||||
print "Error: negative copy length"
|
||||
sys.exit(1)
|
||||
if copy_end > data_len:
|
||||
print "Error: data file is too small"
|
||||
sys.exit(1)
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False, checkhash=False)
|
||||
|
||||
dataf = open(data_name, "rb")
|
||||
dataf.seek(data_offset)
|
||||
left = copy_length
|
||||
offset = part_offset
|
||||
while left > 0:
|
||||
blocklen = min(left, 4*1024*1024)
|
||||
d = dataf.read(blocklen)
|
||||
if len(d) != blocklen:
|
||||
print "File EOF reached!"
|
||||
sys.exit(1)
|
||||
part.write(offset, d)
|
||||
offset += blocklen
|
||||
left -= blocklen
|
||||
|
||||
part.flush()
|
||||
part.update()
|
||||
part.tmd.null_signature()
|
||||
part.tmd.brute_sha()
|
||||
part.updatetmd()
|
||||
|
||||
|
||||
|
||||
31
pywii/pywii-tools/injectdol.py
Executable file
31
pywii/pywii-tools/injectdol.py
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <dol to inject>"%sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, dol_name = sys.argv[1:4]
|
||||
partno = int(partno)
|
||||
|
||||
doldata = open(dol_name, "rb").read()
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False)
|
||||
partdata = wii.WiiPartitionData(part)
|
||||
partdata.replacedol(doldata)
|
||||
|
||||
part.flush()
|
||||
part.update()
|
||||
part.tmd.null_signature()
|
||||
part.tmd.brute_sha()
|
||||
part.updatetmd()
|
||||
part.showinfo()
|
||||
|
||||
|
||||
28
pywii/pywii-tools/partsetios.py
Executable file
28
pywii/pywii-tools/partsetios.py
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print "Usage:"
|
||||
print " python %s <encrypted ISO> <partition number> <IOS version>"%sys.argv[0]
|
||||
print " IOS version should be just the minor number (16, 33, etc) in decimal"
|
||||
sys.exit(1)
|
||||
|
||||
iso_name, partno, ios = sys.argv[1:4]
|
||||
partno = int(partno)
|
||||
iosno = int(ios)
|
||||
|
||||
disc = wii.WiiDisc(iso_name)
|
||||
disc.showinfo()
|
||||
part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False)
|
||||
part.tmd.sys_version = 0x100000000 + iosno
|
||||
part.tmd.update()
|
||||
part.tmd.null_signature()
|
||||
part.tmd.brute_sha()
|
||||
part.updatetmd()
|
||||
part.showinfo()
|
||||
|
||||
|
||||
1
pywii/pywii-tools/pywii
Symbolic link
1
pywii/pywii-tools/pywii
Symbolic link
@@ -0,0 +1 @@
|
||||
../Common/pywii
|
||||
20
pywii/pywii-tools/rsapatch.py
Executable file
20
pywii/pywii-tools/rsapatch.py
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
def hexdump(s):
|
||||
return ' '.join(map(lambda x: "%02x"%x,map(ord,s)))
|
||||
|
||||
isofile = sys.argv[1]
|
||||
disc = WiiDisc(isofile)
|
||||
disc.showinfo()
|
||||
part = WiiPartition(disc,int(sys.argv[2]))
|
||||
part.showinfo()
|
||||
|
||||
part.tmd.update_signature(file("signthree.bin").read())
|
||||
part.tmd.brute_sha()
|
||||
part.updatetmd()
|
||||
|
||||
part.showinfo()
|
||||
|
||||
10
pywii/pywii-tools/saveinfo.py
Executable file
10
pywii/pywii-tools/saveinfo.py
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
savefile = sys.argv[1]
|
||||
save = wii.WiiSave(savefile)
|
||||
save.showcerts()
|
||||
17
pywii/pywii-tools/tikfix.py
Executable file
17
pywii/pywii-tools/tikfix.py
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
tikfile = sys.argv[1]
|
||||
print "fixing Tik file %s " % tikfile
|
||||
tik = wii.WiiTik(open(tikfile, "rb").read())
|
||||
tik.null_signature()
|
||||
tik.brute_sha()
|
||||
tik.update()
|
||||
f = open(tikfile,"wb")
|
||||
f.write(tik.data)
|
||||
f.close()
|
||||
|
||||
28
pywii/pywii-tools/tikinfo.py
Executable file
28
pywii/pywii-tools/tikinfo.py
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args[0] == "-dpki":
|
||||
wii.loadkeys_dpki()
|
||||
args.pop(0)
|
||||
else:
|
||||
wii.loadkeys()
|
||||
|
||||
tikfile = args.pop(0)
|
||||
|
||||
certs = None
|
||||
if len(args) > 0:
|
||||
certs, certlist = wii.parse_certs(open(args.pop(0), "rb").read())
|
||||
|
||||
print "ETicket file %s:"%tikfile
|
||||
tik = wii.WiiTik(open(tikfile, "rb").read())
|
||||
tik.showinfo(" ")
|
||||
if certs is not None:
|
||||
tik.showsig(certs," ")
|
||||
print "Certificates:"
|
||||
for cert in certlist:
|
||||
cert.showinfo(" - ")
|
||||
cert.showsig(certs," ")
|
||||
18
pywii/pywii-tools/tmdfix.py
Executable file
18
pywii/pywii-tools/tmdfix.py
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
tmdfile = sys.argv[1]
|
||||
print "TMD file %s:"%tmdfile
|
||||
tmd = wii.WiiTmd(open(tmdfile, "rb").read())
|
||||
tmd.null_signature()
|
||||
tmd.brute_sha()
|
||||
tmd.update()
|
||||
tmd.parse()
|
||||
tmd.showinfo(" ")
|
||||
f = open(tmdfile,"wb")
|
||||
f.write(tmd.data)
|
||||
f.close()
|
||||
28
pywii/pywii-tools/tmdinfo.py
Executable file
28
pywii/pywii-tools/tmdinfo.py
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args[0] == "-dpki":
|
||||
wii.loadkeys_dpki()
|
||||
args.pop(0)
|
||||
else:
|
||||
wii.loadkeys()
|
||||
|
||||
tmdfile = args.pop(0)
|
||||
|
||||
certs = None
|
||||
if len(args) > 0:
|
||||
certs, certlist = wii.parse_certs(open(args.pop(0), "rb").read())
|
||||
|
||||
print "TMD file %s:"%tmdfile
|
||||
tmd = wii.WiiTmd(open(tmdfile, "rb").read())
|
||||
tmd.showinfo(" ")
|
||||
if certs is not None:
|
||||
tmd.showsig(certs," ")
|
||||
print "Certificates:"
|
||||
for cert in certlist:
|
||||
cert.showinfo(" - ")
|
||||
cert.showsig(certs," ")
|
||||
29
pywii/pywii-tools/tmdupdatecr.py
Executable file
29
pywii/pywii-tools/tmdupdatecr.py
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
from Crypto.Hash import SHA
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
tmdfile = args.pop(0)
|
||||
indir = args.pop(0)
|
||||
|
||||
print "updating content records of TMD file %s" % tmdfile
|
||||
tmd = wii.WiiTmd(open(tmdfile, "rb").read())
|
||||
|
||||
for i, cr in enumerate(tmd.get_content_records()):
|
||||
data = open(os.path.join(indir, "%08X" % cr.cid), "rb").read()
|
||||
cr.sha = SHA.new(data).digest()
|
||||
cr.size = len(data)
|
||||
tmd.update_content_record(i, cr)
|
||||
|
||||
tmd.null_signature()
|
||||
tmd.brute_sha()
|
||||
tmd.update()
|
||||
f = open(tmdfile, "wb")
|
||||
f.write(tmd.data)
|
||||
f.close()
|
||||
|
||||
23
pywii/pywii-tools/tmdvers.py
Executable file
23
pywii/pywii-tools/tmdvers.py
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
tmdfile = args.pop(0)
|
||||
|
||||
if len(args) == 2:
|
||||
newvers = int(args.pop(0)) << 8 | int(args.pop(0))
|
||||
else:
|
||||
newvers = int(args.pop(0), 16)
|
||||
|
||||
print "setting version of TMD file %s to 0x%04x" % (tmdfile, newvers)
|
||||
tmd = wii.WiiTmd(open(tmdfile, "rb").read())
|
||||
tmd.title_version = newvers
|
||||
tmd.update()
|
||||
f = open(tmdfile,"wb")
|
||||
f.write(tmd.data)
|
||||
f.close()
|
||||
16
pywii/pywii-tools/wadinfo.py
Executable file
16
pywii/pywii-tools/wadinfo.py
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args[0] == "-dpki":
|
||||
wii.loadkeys_dpki()
|
||||
args.pop(0)
|
||||
else:
|
||||
wii.loadkeys()
|
||||
|
||||
wadfile = args.pop(0)
|
||||
wad = wii.WiiWad(wadfile)
|
||||
wad.showinfo()
|
||||
34
pywii/pywii-tools/wadpack-boot2.py
Executable file
34
pywii/pywii-tools/wadpack-boot2.py
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
wii.loadkeys()
|
||||
|
||||
wadfile = sys.argv[1]
|
||||
indir = sys.argv[2]
|
||||
|
||||
tmd = wii.WiiTmd(open(indir+os.sep+"tmd", "rb").read())
|
||||
tik = wii.WiiTik(open(indir+os.sep+"cetk", "rb").read())
|
||||
|
||||
certs, certlist = wii.parse_certs(open(os.path.join(indir, "certs"), "rb").read())
|
||||
|
||||
footer = open(indir+os.sep+"footer", "rb").read()
|
||||
|
||||
wad = wii.WiiWadMaker(wadfile, tmd, tik, certlist, footer, nandwad=True)
|
||||
|
||||
for i,ct in enumerate(tmd.get_content_records()):
|
||||
data = open(indir+os.sep+"%08X"%ct.cid, "rb").read()
|
||||
wad.adddata(data,ct.cid)
|
||||
|
||||
wad.finish()
|
||||
|
||||
if not wad.tik.signcheck(wad.certs):
|
||||
wad.tik.null_signature()
|
||||
wad.tik.brute_sha()
|
||||
wad.updatetik()
|
||||
|
||||
if not wad.tmd.signcheck(wad.certs):
|
||||
wad.tmd.null_signature()
|
||||
wad.tmd.brute_sha()
|
||||
wad.updatetmd()
|
||||
40
pywii/pywii-tools/wadpack.py
Executable file
40
pywii/pywii-tools/wadpack.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args[0] == "-dpki":
|
||||
wii.loadkeys_dpki()
|
||||
args.pop(0)
|
||||
else:
|
||||
wii.loadkeys()
|
||||
|
||||
wadfile = args.pop(0)
|
||||
indir = args.pop(0)
|
||||
|
||||
tmd = wii.WiiTmd(open(os.path.join(indir, "tmd"), "rb").read())
|
||||
tik = wii.WiiTik(open(os.path.join(indir, "cetk"), "rb").read())
|
||||
|
||||
certs, certlist = wii.parse_certs(open(os.path.join(indir, "certs"), "rb").read())
|
||||
|
||||
footer = open(os.path.join(indir, "footer"), "rb").read()
|
||||
|
||||
wad = wii.WiiWadMaker(wadfile, tmd, tik, certlist, footer)
|
||||
|
||||
for i,ct in enumerate(tmd.get_content_records()):
|
||||
data = open(os.path.join(indir, "%08X" % ct.cid), "rb").read()
|
||||
wad.adddata(data,ct.cid)
|
||||
|
||||
wad.finish()
|
||||
|
||||
if not wad.tik.signcheck(wad.certs):
|
||||
wad.tik.null_signature()
|
||||
wad.tik.brute_sha()
|
||||
wad.updatetik()
|
||||
|
||||
if not wad.tmd.signcheck(wad.certs):
|
||||
wad.tmd.null_signature()
|
||||
wad.tmd.brute_sha()
|
||||
wad.updatetmd()
|
||||
44
pywii/pywii-tools/wadunpack.py
Executable file
44
pywii/pywii-tools/wadunpack.py
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, os.path
|
||||
import pywii as wii
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if args[0] == "-dpki":
|
||||
wii.loadkeys_dpki()
|
||||
args.pop(0)
|
||||
else:
|
||||
wii.loadkeys()
|
||||
|
||||
wadfile = args.pop(0)
|
||||
outdir = args.pop(0)
|
||||
wad = wii.WiiWad(wadfile)
|
||||
wad.showinfo()
|
||||
|
||||
if not os.path.isdir(outdir):
|
||||
os.mkdir(outdir)
|
||||
|
||||
for ct in wad.tmd.get_content_records():
|
||||
data = wad.getcontent(ct.index)
|
||||
f = open(os.path.join(outdir, "%08X" % ct.cid),"wb")
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
f = open(os.path.join(outdir, "cetk"),"wb")
|
||||
f.write(wad.tik.data)
|
||||
f.close()
|
||||
|
||||
f = open(os.path.join(outdir, "tmd"),"wb")
|
||||
f.write(wad.tmd.data)
|
||||
f.close()
|
||||
|
||||
f = open(os.path.join(outdir, "certs"),"wb")
|
||||
for cert in wad.certlist:
|
||||
f.write(cert.data)
|
||||
wii.falign(f,0x40)
|
||||
f.close()
|
||||
|
||||
f = open(os.path.join(outdir, "footer"),"wb")
|
||||
f.write(wad.footer)
|
||||
f.close()
|
||||
Reference in New Issue
Block a user