#!/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()
#!/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, " ")
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, "rb").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)