Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instruction authentication failed after writing to another block inside my MIFARE CLASSIC 1K #3

Closed
caf-3 opened this issue Jun 14, 2022 · 1 comment

Comments

@caf-3
Copy link

caf-3 commented Jun 14, 2022

I'm facing a problem after writing to another block different than 0x01.
After writing to another block, i can't authenticate to previous the blocks that i have wrote data.
My code

from nfc import nfc as nfcReader

reader = nfcReader.Reader()
block_number = 0x01
custom_number = 0x20
key_location = 0x01
reader.load_authentication_data(key_location, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
reader.authentication(block_number, 0x61, key_location)

def write(position=block_number, number=custom_number, data=[0x00 for i in range(16)]):
    """ Write data to mifare tag
    Example:
        write(reader, 0x01, 0x20, [0x00 for i in range(16)])
    """

    while number >= 16:
        write_16(reader, position, 16, data)
        number -= 16
        position += 1


def write_16(r, position, number, data):
    
    r.update_binary_blocks(position, number, data)


def read(position=block_number, number=custom_number):
    """ Read data from mifare tag
    >>> read(reader, 0x01, 0x20)
    """
    print(f'block {block_number}')
    result = []
    while number >= 16:
        result.append(read_16(position, 16, reader))
        number -= 16
        position += 1
    return result


def read_16(position, number, r):
    return r.read_binary_blocks(position, number)
@Flowtter
Copy link
Owner

Unfortunately I don't have the NFC reader anymore so I won't be able to provide much help.

I used the acs' API to write it.

There might be a bug, if you find it you're welcome to do a pull request.

If I recall correctly, you can't access every blocks as well. Everything is in the API's documentation.

Sorry I can't help more unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants