Beispiel #1
0
def _disable_pin(args):
    reader = args.reader
    puk = change_pin(reader, args.pin, 'dummy')
    unlock_pin(reader, args.puk)

    if args.machine_readable:
        json.dump({'status': 'success'}, fp=sys.stdout)
    else:
        print('OK - unlocked')
Beispiel #2
0
def _change_pin(args):
	reader = args.reader
	puk = change_pin(reader, args.current_pin, args.new_pin)

	if args.machine_readable:
		json.dump({
			'status': 'success',
			'puk': puk.hex()}, fp=sys.stdout)
	else:
		print('New PUK to unlock card (hex): ' + puk.hex())
if ('__main__' == __name__):
    reader = get_reader()
    activate_card(reader)
    mode = input(
        'What would you like to do? ("Set pin", "Change pin", "Unlock pin" or "Verify pin")\n'
    )
    try:
        if ('Set pin' == mode):
            pin = input('Please enter a new PIN: ')
            puk = blocksec2go.set_pin(reader, pin)
            print('PUK to unlock card (hex): ' + puk.hex())
        elif ('Change pin' == mode):
            old_pin = input('Please enter PIN: ')
            new_pin = input('Please enter a new PIN: ')
            puk = blocksec2go.change_pin(reader, old_pin, new_pin)
            print('New PUK to unlock card (hex): ' + puk.hex())
        elif ('Unlock pin' == mode):
            puk = input('Please enter PUK: ')
            status = blocksec2go.unlock_pin(reader, bytes.fromhex(puk))
            if ((True == status) and (isinstance(status, bool))):
                print('OK - Unlocked!')
            elif (0 != status):
                print('ERROR - ' + str(status) + ' tries left')
            else:
                print('ERROR - Card locked!')
        elif ('Verify pin' == mode):
            pin = input('Please enter PIN: ')
            status = blocksec2go.verify_pin(reader, pin)
            if ((True == status) and (isinstance(status, bool))):
                print('OK - Verified!')