1

Can anyone please tell me how to change a key in a Mifare 4K classic card.

What I tried was

<newKeyA> + access bits + <KeyB>
0xAA 0xAA 0xAA 0xAA 0xAA 0xAA 0X78 0x77 0x88 0x69 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

But the key refuses to change. The default configuration is 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
vikky
  • 11
  • 2

1 Answers1

1

In order to change the access keys of a sector on a MIFARE Classic card, you simply have to update that sector's trailer block.

So, for instance, if your current key B is FFFFFFFFFFFF (and the current access conditions permit writing of the sector trailer with key B), you would first authenticate for that sector with that current key B.

Then, you would create your new sector trailer:

<new key A> | access bits | general purpose byte | <new key B>

For instance:

AAAAAAAAAAAA 787788 69 BBBBBBBBBBBB

to have key A set to AAAAAAAAAAAA and key B set to BBBBBBBBBBBB with these access conditions:

  • Trailer block: C1=0,C2=1,C3=1 &rightarrow; Sector trailer is writable using key B only; access bits/GPB can be read with key A or B.
  • Data blocks: C1=1, C2=0, C3=0 &rightarrow; Write is possible using key B only; read is permitted with key A or B.

Finally, you can write the new sector trailer to the trailer block, which is the last block (i.e. block 3) of each sector.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206