Skip to content

Instantly share code, notes, and snippets.

@SocraticBliss
Last active May 10, 2018 01:09
Show Gist options
  • Save SocraticBliss/d383ff1cd2a4705b76ddeb5c5970834d to your computer and use it in GitHub Desktop.
Save SocraticBliss/d383ff1cd2a4705b76ddeb5c5970834d to your computer and use it in GitHub Desktop.
unpack_PRODINFO.py
# Unpacking PRODINFO.bin [Certs and Keys]
# SocraticBliss (R)
import os, sys
Sections = [['device_cert_ecc_b233', 0x0480, 0x180, 'der'],
['ssl_cert', 0x0AE0, 0x800, 'der'],
['gamecard_cert', 0x2440, 0x400, 'der'],
['eticket_cert_rsa', 0x2A90, 0x240, 'der'],
['amiibo_key', 0x3520, 0x050, 'pem'],
['amiibo_cert_ecqv', 0x3580, 0x014, 'der'],
['amiibo_cert_ecdsa', 0x35A0, 0x070, 'der'],
['amiibo_key_ecqv_bls', 0x3620, 0x040, 'pem'],
['amiibo_cert_ecqv_bls', 0x3670, 0x020, 'der'],
['amiibo_root_cert_ecqv_bls', 0x36A0, 0x090, 'der'],
['device_ext_key_ecc_b233', 0x3770, 0x050, 'pem'],
['eticket_ext_key_rsa', 0x3890, 0x240, 'pem'],
['ssl_ext_key', 0x3AE0, 0x130, 'pem'],
['gamecard_ext_key', 0x3C20, 0x130, 'pem']]
def read_at(fp, off, len):
fp.seek(off)
return fp.read(len)
def main(argc, argv):
if argc != 2:
print('Usage: %s PRODINFO.bin' % argv[0])
sys.exit(1)
try:
with open(sys.argv[1], 'rb') as PRODINFO:
for section in Sections:
try:
os.remove('%s.%s' % (section[0], section[3]))
except OSError:
pass
sec_block = read_at(PRODINFO, section[1], section[2])
with open('%s.%s' % (section[0], section[3]), 'wb') as out:
out.write(sec_block)
print('Saved %s.%s' % (section[0], section[3]))
except:
print('Failed to open %s!' % argv[1])
sys.exit(1)
print('Done!')
sys.exit(0)
if __name__=='__main__':
main(len(sys.argv), sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment