#!/usr/bin/env python3 import argparse from psptool.pack import pack_prx from psptool.prx import encrypt parser = argparse.ArgumentParser( description="Infinity User Firmware Module Packer") parser.add_argument('input', type=argparse.FileType('rb'), help='The raw user PRX to pack') parser.add_argument('--id', type=str, help='The btcnf id to set') parser.add_argument('output', type=str, help='The output to write the packed PRX') args = parser.parse_args() executable = args.input.read() executable = encrypt(pack_prx(executable, is_pbp=False, psptag=lambda x: 0x457B8AF0), id=bytes.fromhex(args.id)) with open(args.output, 'wb') as f: f.write(executable)
#!/usr/bin/env python3 import argparse from psptool.pack import pack_prx from psptool.prx import encrypt parser = argparse.ArgumentParser(description="Infinity Kernel Module Packer") parser.add_argument('input', type=argparse.FileType('rb'), help='The raw kernel PRX to pack') parser.add_argument('--tag', type=str, help='tag in the executable header') parser.add_argument('output', type=str, help='The output to write the packed PRX') args = parser.parse_args() id = bytearray.fromhex('AA'*16) tag = 0x00000000 if args.tag: tag = int(args.tag, 16) executable = args.input.read() executable = encrypt(pack_prx(executable, is_pbp=False, fix_relocs=False, psptag=lambda x: tag), id=id) with open(args.output, 'wb') as f: f.write(executable)
#!/usr/bin/env python3 import argparse from psptool.pack import pack_prx from psptool.prx import encrypt parser = argparse.ArgumentParser(description="Infinity Kernel Module Packer") parser.add_argument('input', type=argparse.FileType('rb'), help='The raw kernel PRX to pack') parser.add_argument('--vanity', type=str, help='Some vanity text in the executable header') parser.add_argument('output', type=str, help='The output to write the packed PRX') args = parser.parse_args() executable = args.input.read() executable = encrypt(pack_prx(executable, is_pbp=False, psptag=lambda x: 0x00000000), vanity=args.vanity) with open(args.output, 'wb') as f: f.write(executable)
#!/usr/bin/env python3 import argparse from psptool.pbp import is_pbp, PBP from psptool.pack import pack_prx from psptool.prx import encrypt parser = argparse.ArgumentParser(description="Infinity Updater Packer") parser.add_argument('input', type=argparse.FileType('rb'), help='The raw PBP to pack') parser.add_argument('--vanity', type=str, help='Some vanity text in the executable header') parser.add_argument('output', type=str, help='The output to write the packed PBP') args = parser.parse_args() executable = args.input.read() if not is_pbp(executable): raise ValueError("not a PBP") pbp = PBP(executable) pbp.prx = encrypt(pack_prx(pbp.prx, is_pbp=True, psptag=lambda x: 0x0B000000), vanity=args.vanity) with open(args.output, 'wb') as f: f.write(pbp.pack())
self.reserved2 = [0] * 2 self.key_data1 = [0xDA] * 0x10 self.signcheck = [0] * 0x58 self.key_data2 = 0 self.key_data3 = [0xDA] * 0x1C def pack(self): return struct.pack( '<IHHBB28sBBIIIII4H4I4I5IIBxH48BII2I16BI88BII28B', PSP_HEADER_MAGIC, self.attribute, self.comp_attribute, self.module_ver_lo, self.module_ver_hi, self.modname.encode('ascii'), self.version, self.nsegments, self.elf_size, self.psp_size, self.entry, self.modinfo_offset, self.bss_size, *self.seg_align, *self.seg_address, *self.seg_size, *self.reserved, self.devkitversion, self.decrypt_mode, 0, *self.key_data0, self.comp_size, 0x80, *self.reserved2, *self.key_data1, self.psptag, *self.signcheck, self.key_data2, self.oetag, *self.key_data3) id = bytearray.fromhex('AA' * 16) data = args.input.read() psp_header = PSPHeader(data) data = encrypt(psp_header.pack() + data, id=id) with open(args.output, 'wb') as f: f.write(data)