def __init__(self, char_dict, key_directory="Brain_Transplant_Assets"):
     """
     This class manages bin files, does transplants and serial editing
     :param char_dict:
     """
     self.characters = char_dict
     self.key_directory = key_directory
     with open(r'\\'.join([self.key_directory, 'unfixed-info.bin']), 'rb') as fp_d, \
             open(r'\\'.join([self.key_directory, 'locked-secret.bin']), 'rb') as fp_t:
         self.master_keys = AmiiboMasterKey.from_separate_bin(
             fp_d.read(), fp_t.read())
示例#2
0
def make_new_amiibo(unfixed_info, locked_key, amiibo_data, uid):
    try:
        master_keys = AmiiboMasterKey.from_separate_bin(
            unfixed_info.read(), locked_key.read())
    except ValueError as e:
        print_error("Invalid keys: " + str(e))
        sys.exit(EXIT_FAILURE)
    try:
        amiibo = AmiiboDump(master_keys, amiibo_data)
        amiibo.unlock()
    except (AmiiboHMACError, AmiiboHMACTagError, AmiiboDumpSizeError):
        print_error("This amiibo is invalid or corrupt")
        sys.exit(EXIT_FAILURE)
    amiibo.uid_hex = uid_to_hex_format(uid)
    amiibo.lock()
    amiibo.unset_lock_bytes()
    return amiibo
示例#3
0
chk_state_learn.set(False)

window.title("SSBU Amiibo editor")
window.geometry('1040x280')

menu = Menu(window)

new_item = Menu(menu, tearoff=0)

new_item.add_command(label='Open', command=OpenCmd)

sv_cmd = new_item.add_command(label='Save', command=SaveCmd, state='disabled')

if (key_file):
    with open('./retail.key', 'rb') as fp_d:
        master_keys = AmiiboMasterKey.from_combined_bin(fp_d.read())

if (key_file):
    new_item.add_separator()
    enc_cmd = new_item.add_command(label='Encrypt Amiibo',
                                   command=Encrypt,
                                   state='disabled')
    drc_cmd = new_item.add_command(label='Decrypt amiibo', command=Decrypt)
    block_item = Menu(menu, tearoff=0)
    block_item.add_command(label='Export DataBlock', command=ExportDB)
    block_item.add_command(label='Import DataBlock', command=InportDB)

new_item.add_separator()
new_item.add_command(label='Exit', command=QuitCmd)

menu.add_cascade(label='File', menu=new_item)
示例#4
0
文件: ui.py 项目: tlamvip/SSBU_Amiibo
def maine():
    global master_keys, window, txt_CL, new_item, sv_cmd, sva_cmd, menu, chk_state_learn, chk_learn, Moves, txt_XP, txt_ATC, txt_HP, txt_Gift, key_file, background_label, menu
    window = Tk()

    key_file = Path("./key_retail.bin").is_file()

    chk_state_learn = BooleanVar()
    chk_state_learn.set(False)

    window.title("SSBU Amiibo editor")
    window.geometry('1080x400')

    menu = Menu(window)

    new_item = Menu(menu, tearoff=0)

    new_item.add_command(label='Open', command=OpenCmd)

    sv_cmd = new_item.add_command(label='Save',
                                  command=SaveCmd,
                                  state='disabled')
    sva_cmd = new_item.add_command(label='Save As...',
                                   command=SaveASCmd,
                                   state='disabled')

    if (key_file):
        with open('./key_retail.bin', 'rb') as fp_d:
            master_keys = AmiiboMasterKey.from_combined_bin(fp_d.read())

    if (key_file):
        new_item.add_separator()
        enc_cmd = new_item.add_command(label='Encrypt Amiibo',
                                       command=Encrypt,
                                       state='disabled')
        drc_cmd = new_item.add_command(label='Decrypt amiibo', command=Decrypt)

    new_item.add_separator()
    new_item.add_command(label='Exit', command=QuitCmd)
    menu.add_cascade(label='File', menu=new_item)

    unMenuCount = 6
    block_item = Menu(menu, tearoff=0)
    sub_item = Menu(block_item, tearoff=0)

    sub_item.add_command(label='Export Full DataBlock', command=ExportDB)
    sub_item.add_command(label='Export Traning DataBlock',
                         command=lambda: Export('train'))
    sub_item.add_command(label='Export Color DataBlock',
                         command=lambda: Export('color'))

    for un in range(0, unMenuCount):
        sub_item.add_command(label='Export Un' + str(un) + '_Block',
                             command=(lambda un: lambda: Export('un' + un))(
                                 str(un)))
    block_item.add_cascade(label='Export', menu=sub_item)

    sub_item = Menu(block_item, tearoff=0)
    sub_item.add_command(label='Import Full DataBlock', command=InportDB)
    sub_item.add_command(label='Import Traning DataBlock',
                         command=lambda: Inport('train'))
    sub_item.add_command(label='Import Color DataBlock',
                         command=lambda: Inport('color'))

    for un in range(0, unMenuCount):
        sub_item.add_command(label='Import Un' + str(un) + '_Block',
                             command=(lambda un: lambda: Inport('un' + un))(
                                 str(un)))
    block_item.add_cascade(label='Import', menu=sub_item)

    sub_item = Menu(block_item, tearoff=0)
    sub_item.add_command(label='Edit Full DataBlock',
                         command=(lambda: Edit('train')))
    sub_item.add_command(label='Edit Traning DataBlock',
                         command=lambda: Edit('train'))
    sub_item.add_command(label='Edit Color DataBlock',
                         command=lambda: Edit('color'))

    for un in range(0, unMenuCount):
        sub_item.add_command(label='Edit Un' + str(un) + '_Block',
                             command=(lambda un: lambda: Edit('un' + un))(
                                 str(un)))
    block_item.add_cascade(label='Edit', menu=sub_item)

    menu.add_cascade(label='Data', menu=block_item, state='disabled')

    window.config(menu=menu)
    window.bind("<Key>", key)

    background_label = Label(window)
    background_label.grid(column=0, row=5, columnspan=4)

    chk_learn = Checkbutton(window,
                            text='Learning On/Off',
                            var=chk_state_learn)
    chk_learn.grid(column=0, row=0)

    moveFrame = mv.buildTrees(window)
    moveFrame.grid(column=4, row=1, rowspan=5)

    for tree in mv.TreeList:
        mv.addSkilsToTree(tree)

    lbl_XP = Label(window, text="XP: ")
    lbl_XP.grid(column=0, row=1)
    txt_XP = Entry(window)
    txt_XP.grid(column=1, row=1)

    lbl_ATC = Label(window, text="Attack: ")
    lbl_ATC.grid(column=2, row=1)
    txt_ATC = Entry(window)
    txt_ATC.grid(column=3, row=1)

    lbl_HP = Label(window, text="Defense: ")
    lbl_HP.grid(column=0, row=2)
    txt_HP = Entry(window)
    txt_HP.grid(column=1, row=2)

    lbl_Gift = Label(window, text="Gift: ")
    lbl_Gift.grid(column=2, row=2)
    txt_Gift = Entry(window)
    txt_Gift.grid(column=3, row=2)

    lbl_CL = Label(window, text="Color: ")
    lbl_CL.grid(column=0, row=3)
    txt_CL = Entry(window)
    txt_CL.grid(column=1, row=3)

    window.mainloop()
示例#5
0
__status__ = "Development"

import nfc
from easy_nfc import nfc_parser
from amiibo import AmiiboDump, AmiiboMasterKey, crypto

lock_data = [  #page, #byteoffset, #bytedata
    ('82h', 3, [0x01, 0x00, 0x0F, 0xBD]),  #dynamic lockpages
    ('02h', 2, [0x0F, 0x48, 0x0F, 0xE0]),  #static lockpages
]

ni = nfc_parser()

with open('unfixed-info.bin', 'rb') as fp_d, open('locked-secret.bin',
                                                  'rb') as fp_t:
    master_keys = AmiiboMasterKey.from_separate_bin(fp_d.read(), fp_t.read())

with open('orig.bin', 'rb') as fp:
    dump = AmiiboDump(master_keys, fp.read())

try:
    dump.unlock()
except amiibo.crypto.AmiiboHMACDataError:
    print('AmiiboHMACDataError error thrown (corrupt bin?)')
    quit(1)
else:
    print(ni)
    dump.uid_hex = ni.spaced_hex(ni.uid)
    dump.lock()
    dump.unset_lock_bytes()