fix missing gitignore
[RRG-proxmark3.git] / client / pyscripts / amiibo_change_uid.py
blob4c7b2354aba85d486ac6fc59a41c9d771777a8c3
1 # Requirements:
2 # python3 -m pip install pyamiibo
4 import sys
5 from amiibo import AmiiboDump, AmiiboMasterKey
7 def main():
8 if(len(sys.argv) != 5):
9 print("""
10 \t{0} - helper script for integrating with PyAmiibo
12 Usage: {0} <uid> <infile> <outfile> <keyfile>
14 Example:
16 \t{0} 04123456789ABC my_amiibo_original.bin my_amiibo_with_new_uid.bin keyfile.bin
18 \n""".format(sys.argv[0]))
19 return 1
21 uid = sys.argv[1]
22 infile = sys.argv[2]
23 outfile = sys.argv[3]
24 keyfile = sys.argv[4]
26 if len(uid) != 14:
27 print('expecting 7 byte UID')
28 return 1
30 with open(keyfile, 'rb') as keybin:
31 master_key = AmiiboMasterKey.from_combined_bin(keybin.read())
33 with open(infile, 'rb') as fin, open(outfile, 'wb') as fout:
34 dump = AmiiboDump(master_key, fin.read(), is_locked=True)
35 dump.unlock()
36 dump.uid_hex = uid
37 dump.lock()
38 fout.write(dump.data)
40 return 0
42 if __name__ == "__main__":
43 sys.exit(main())