1 # Notes on Magic Cards, aka UID changeable
2 This document is based mostly on information posted on http://www.proxmark.org/forum/viewtopic.php?pid=35372#p35372
5 * [AN10833 MIFARE Type Identification Procedure](https://www.nxp.com/docs/en/application-note/AN10833.pdf)
7 - [ISO14443A](#iso14443a)
8 * [Identifying broken ISO14443A magic](#identifying-broken-iso14443a-magic)
9 - [MIFARE Classic](#mifare-classic)
10 * [MIFARE Classic block0](#mifare-classic-block0)
11 * [MIFARE Classic Gen1A aka UID](#mifare-classic-gen1a-aka-uid)
12 * [MIFARE Classic Gen1B](#mifare-classic-gen1b)
13 * [MIFARE Classic DirectWrite aka Gen2 aka CUID](#mifare-classic-directwrite-aka-gen2-aka-cuid)
14 * [MIFARE Classic DirectWrite, FUID version aka 1-write](#mifare-classic-directwrite-fuid-version-aka-1-write)
15 * [MIFARE Classic DirectWrite, UFUID version](#mifare-classic-directwrite-ufuid-version)
16 * [MIFARE Classic, other versions](#mifare-classic-other-versions)
17 * [MIFARE Classic APDU aka Gen3](#mifare-classic-apdu-aka-gen3)
18 * [MIFARE Classic Super](#mifare-classic-super)
19 - [MIFARE Ultralight](#mifare-ultralight)
20 * [MIFARE Ultralight blocks 0..2](#mifare-ultralight-blocks-02)
21 * [MIFARE Ultralight Gen1A](#mifare-ultralight-gen1a)
22 * [MIFARE Ultralight DirectWrite](#mifare-ultralight-directwrite)
23 * [MIFARE Ultralight EV1 DirectWrite](#mifare-ultralight-ev1-directwrite)
24 * [MIFARE Ultralight C Gen1A](#mifare-ultralight-c-gen1a)
25 * [MIFARE Ultralight C DirectWrite](#mifare-ultralight-c-directwrite)
27 * [NTAG213 DirectWrite](#ntag213-directwrite)
30 * ["DESFire" APDU, 7b UID](#desfire-apdu-7b-uid)
31 * ["DESFire" APDU, 4b UID](#desfire-apdu-4b-uid)
32 - [ISO14443B](#iso14443b)
33 * [ISO14443B magic](#iso14443b-magic)
34 - [ISO15693](#iso15693)
35 * [ISO15693 magic](#iso15693-magic)
40 ## Identifying broken ISO14443A magic
42 When a magic card configuration is really messed up and the card is not labeled, it may be hard to find out which type of card it is.
44 Here are some tips if the card doesn't react or gives error on a simple `hf 14a reader`:
46 Let's force a 4b UID anticollision and see what happens:
48 hf 14a config --atqa force --bcc ignore --cl2 skip --rats skip
51 It it responds, we know it's a TypeA card. But maybe it's a 7b UID, so let's force a 7b UID anticollision:
53 hf 14a config --atqa force --bcc ignore --cl2 force --cl3 skip --rats skip
56 At this stage, you know if it's a TypeA 4b or 7b card and you can check further on this page how to reconfigure different types of cards.
58 To restore anticollision config of the Proxmark3:
65 Referred as M1, S50 (1k), S70 (4k)
67 ## MIFARE Classic block0
69 UID 4b: (actually NUID as there are no more "unique" IDs on 4b)
72 11223344440804006263646566676869
77 ^^^^^^^^^^^^^^^^ Manufacturer data
78 (*) some cards have a different SAK in their anticollision and in block0: +0x80 in the block0 (e.g. 08->88, 18->98)
82 Computing BCC on UID 11223344: `hf analyse lcr -d 11223344` = `44`
87 04112233445566884400c82000000000
92 ^^^^^^^^^^^^ Manufacturer data
93 (*) all? cards have a different SAK in their anticollision and in block0: +0x80 in the block0 (e.g. 08->88, 18->98)
96 ## MIFARE Classic Gen1A aka UID
103 [+] Magic capabilities : Gen 1a
108 * Wipe: `40(7)`, `41` (use 2000ms timeout)
109 * Read: `40(7)`, `43`, `30xx`+crc
110 * Write: `40(7)`, `43`, `A0xx`+crc, `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`+crc
114 * UID: Only 4b versions
116 * all cards play blindly the block0 ATQA bytes, beware!
118 * some cards play blindly the block0 SAK byte, beware!
119 * some cards use a fix "08" in anticollision, no matter the block0
120 * some cards use a fix "08" in anticollision, unless SAK in block0 has most significant bit "80" set, in which case SAK="88"
122 * all cards play blindly the block0 BCC byte, beware!
126 #### MIFARE Classic Gen1A flavour 1
128 * SAK: play blindly the block0 SAK byte, beware!
129 * PRNG: static 01200145
130 * Wipe: filled with 0xFF
132 #### MIFARE Classic Gen1A flavour 2
134 * SAK: play blindly the block0 SAK byte, beware!
135 * PRNG: static 01200145
136 * Wipe: filled with 0x00
138 #### MIFARE Classic Gen1A flavour 3
141 * PRNG: static 01200145
142 * Wipe: filled with 0xFF
144 #### MIFARE Classic Gen1A flavour 4
148 * Wipe: timeout, no wipe
150 #### MIFARE Classic Gen1A flavour 5
154 * Wipe: reply ok but no wipe performed
156 #### MIFARE Classic Gen1A flavour 6
158 * SAK: 08 or 88 if block0_SAK most significant bit is set
160 * Wipe: timeout, no wipe
162 #### MIFARE Classic Gen1A flavour 7
164 * SAK: 08 or 88 if block0_SAK most significant bit is set
166 * Wipe: filled with 0x00
168 ### Proxmark3 commands
181 When "soft-bricked" (by writing invalid data in block0), these ones may help:
185 hf mf cwipe -u 11223344 -a 0004 -s 08
187 hf mf cwipe -u 11223344 -a 0044 -s 18
189 or just fixing block0:
192 hf mf csetuid -u 11223344 -a 0004 -s 08
194 hf mf csetuid -u 11223344 -a 0044 -s 18
198 script run hf_mf_magicrevive
201 To execute commands manually:
203 hf 14a raw -a -k -b 7 40
205 hf 14a raw -k -c A000
206 hf 14a raw -c -t 1000 11223344440804006263646566676869
210 hf 14a raw -a -k -b 7 40
211 hf 14a raw -t 1000 41
218 nfc-mfclassic R a u mydump
219 nfc-mfclassic W a u mydump
222 ## MIFARE Classic Gen1B
224 Similar to Gen1A, but supports directly read/write after command 40
231 [+] Magic capabilities : Gen 1b
236 * Read: `40(7)`, `30xx`
237 * Write: `40(7)`, `A0xx`+crc, `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`+crc
239 ## MIFARE Classic DirectWrite aka Gen2 aka CUID
241 (also referred as MCT compatible by some sellers)
248 [+] Magic capabilities : Gen 2 / CUID
251 Not all Gen2 cards can be identified with `hf 14a info`, only those replying to RATS.
253 To identify the other ones, you've to try to write to block0 and see if it works...
259 * issue regular write to block0
263 * UID: 4b and 7b versions
265 * some cards play blindly the block0 ATQA bytes, beware!
266 * some cards use a fix ATQA in anticollision, no matter the block0. Including all 7b.
268 * some cards play blindly the block0 SAK byte, beware!
269 * some cards use a fix "08" or "18" in anticollision, no matter the block0. Including all 7b.
271 * some cards play blindly the block0 BCC byte, beware!
272 * some cards compute a proper BCC in anticollision. Including all 7b computing their BCC0 and BCC1.
274 * some cards don't reply to RATS
275 * some reply with an ATS
277 #### MIFARE Classic DirectWrite flavour 1
280 * ATQA: play blindly the block0 ATQA bytes, beware!
281 * SAK: play blindly the block0 SAK byte, beware!
282 * BCC: play blindly the block0 BCC byte, beware!
286 #### MIFARE Classic DirectWrite flavour 2
292 * ATS: 0978009102DABC1910F005
295 #### MIFARE Classic DirectWrite flavour 3
298 * ATQA: play blindly the block0 ATQA bytes, beware!
300 * BCC: play blindly the block0 BCC byte, beware!
304 #### MIFARE Classic DirectWrite flavour 4
310 * ATS: 0978009102DABC1910F005
311 * PRNG: static 00000000
313 #### MIFARE Classic DirectWrite flavour 5
317 * SAK: play blindly the block0 SAK byte, beware!
322 #### MIFARE Classic DirectWrite flavour 6
324 **TODO** need more info
327 * ATS: 0D780071028849A13020150608563D
329 ### Proxmark3 commands
332 hf mf wrbl --blk 0 -k FFFFFFFFFFFF -d 11223344440804006263646566676869
337 When "soft-bricked" (by writing invalid data in block0), these ones may help:
346 hf 14a config --atqa force --bcc ignore --cl2 skip --rats skip
347 hf mf wrbl --blk 0 -k FFFFFFFFFFFF -k 11223344440804006263646566676869 # for 1k
348 hf mf wrbl --blk 0 -k FFFFFFFFFFFF -k 11223344441802006263646566676869 # for 4k
356 hf 14a config --atqa force --bcc ignore --cl2 force --cl3 skip --rats skip
357 hf mf wrbl --blk 0 -k FFFFFFFFFFFF -k 04112233445566084400626364656667 # for 1k
358 hf mf wrbl --blk 0 -k FFFFFFFFFFFF -k 04112233445566184200626364656667 # for 4k
362 ## MIFARE Classic DirectWrite, FUID version aka 1-write
364 Same as MIFARE Classic DirectWrite, but block0 can be written only once.
366 Initial UID is AA55C396
370 Only possible before personalization.
375 [+] Magic capabilities : Write Once / FUID
378 ## MIFARE Classic DirectWrite, UFUID version
380 Same as MIFARE Classic DirectWrite, but block0 can be locked with special command.
386 ### Proxmark3 commands
388 To lock definitively block0:
390 hf 14a raw -a -k -b 7 40
392 hf 14a raw -k -c e000
393 hf 14a raw -c 85000000000000000000000000000008
396 ## MIFARE Classic, other versions
400 * ZXUID, EUID, ICUID ?
401 * Some cards exhibit a specific SAK=28 ??
403 ## MIFARE Classic APDU aka Gen3
410 [+] Magic capabilities : Gen 3 / APDU
417 * issue special APDUs
421 90 F0 CC CC 10 <block0> - write block 0
422 90 FB CC CC 07 <uid> - change uid (independently of block0 data)
423 90 FD 11 11 00 - lock permanently
425 It seems the length byte gets ignored anyway.
427 Note: it seems some cards only accept the "change UID" command.
429 It accepts direct read of block0 (and only block0) without prior auth.
431 Writing to block 0 has some side-effects:
433 * It changes also the UID. Changing the UID *does not* change block 0.
434 * ATQA and SAK bytes are automatically replaced by fixed values.
435 * On 4-byte UID cards, BCC byte is automatically corrected.
439 * UID: 4b and 7b versions
444 ### Proxmark3 commands
451 # lock (uid/block0?) forever:
456 script run hf_mf_gen3_writer -h
462 hf 14a raw -s -c -t 2000 90FBCCCC07 11223344556677
464 hf 14a raw -s -c 3000
466 hf 14a raw -s -c -t 2000 90F0CCCC10 041219c3219316984200e32000000000
467 # lock (uid/block0?) forever:
468 hf 14a raw -s -c 90FD111100
471 ## MIFARE Classic Super
473 It behaves like DirectWrite but records reader auth attempts.
475 To change UID: same commands as for MFC DirectWrite
477 To do reader-only attack: at least two versions exist.
479 * type 1: https://github.com/nfc-tools/nfc-supercard for card with ATS: 0978009102DABC1910F005
480 * type 2: https://github.com/netscylla/super-card/blob/master/libnfc-1.7.1/utils/nfc-super.c for ??
484 Only type 1 at the moment:
489 [+] Magic capabilities : super card
494 ## MIFARE Ultralight blocks 0..2
502 UID is made of SN0..SN6 bytes
504 Computing BCC0 on UID 04112233445566: `analyse lcr -d 88041122` = `bf`
506 Computing BCC1 on UID 04112233445566: `analyse lcr -d 33445566` = `44`
508 Int is internal, typically 0x48
510 Anticol shortcut (CL1/3000) is supported for UL, ULC, NTAG except NTAG I2C
513 ## MIFARE Ultralight Gen1A
529 #### SAK, ATQA, BCC, ATS
531 **TODO** need more tests
533 ### Proxmark3 commands
536 script run hf_mfu_setuid -h
539 When "soft-bricked" (by writing invalid data in block0), these ones may help:
543 script run hf_mf_magicrevive -u
546 ## MIFARE Ultralight DirectWrite
553 [+] Magic capabilities : Gen 2 / CUID
556 It seems so far that all MFUL DW have an ATS.
560 Issue three regular MFU write commands in a row to write first three blocks.
564 * UID: Only 7b versions
566 * all cards play fix ATQA
568 * all cards play fix SAK
570 * some cards play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
571 * some cards compute proper BCC0 and BCC1 in anticollision
573 * all cards reply with an ATS
575 #### MIFARE Ultralight DirectWrite flavour 1
578 * ATS: 0A78008102DBA0C119402AB5
579 * Anticol shortcut (CL1/3000): fails
581 #### MIFARE Ultralight DirectWrite flavour 2
583 * BCC: play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
584 * ATS: 850000A00A000AB00000000000000000184D
585 * Anticol shortcut (CL1/3000): succeeds
587 ### Proxmark3 commands
593 Equivalent: don't use `hf mfu wrbl` as you need to write three blocks in a row, but do, with proper BCCx:
596 hf 14a raw -s -c -k a2 00 041122bf
597 hf 14a raw -c -k a2 01 33445566
598 hf 14a raw -c a2 02 44480000
601 When "soft-bricked" (by writing invalid data in block0), these ones may help:
609 hf 14a config --atqa force --bcc ignore --cl2 force --cl3 skip --rats skip
610 hf mfu setuid --uid 04112233445566
620 See `--uid` and `--full`
624 * MIFARE++ Ultralight
626 ## MIFARE Ultralight EV1 DirectWrite
628 Similar to MFUL DirectWrite
635 [+] Magic capabilities : Gen 2 / CUID
640 * UID: Only 7b versions
642 * all cards play fix ATQA
644 * all cards play fix SAK
646 * cards play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
648 * all cards reply with an ATS
650 #### MIFARE Ultralight EV1 DirectWrite flavour 1
652 * BCC: play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
653 * ATS: 850000A000000AC30004030101000B0341DF
655 #### MIFARE Ultralight EV1 DirectWrite flavour 2
657 * BCC: play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
658 * ATS: 850000A00A000AC30004030101000B0316D7
660 ## MIFARE Ultralight C Gen1A
662 Similar to MFUL Gen1A
664 ## MIFARE Ultralight C DirectWrite
666 Similar to MFUL DirectWrite
673 [+] Magic capabilities : Gen 2 / CUID
678 * UID: Only 7b versions
680 * all cards play fix ATQA
682 * all cards play fix SAK
684 * cards compute proper BCC0 and BCC1 in anticollision
686 * all cards reply with an ATS
688 #### MIFARE Ultralight C DirectWrite flavour 1
691 * ATS: 0A78008102DBA0C119402AB5
692 * Anticol shortcut (CL1/3000): fails
696 ## NTAG213 DirectWrite
698 Similar to MFUL DirectWrite
705 [+] Magic capabilities : Gen 2 / CUID
710 * UID: Only 7b versions
712 * all cards play fix ATQA
714 * all cards play fix SAK
716 * cards play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
718 * all cards reply with an ATS
720 #### NTAG213 DirectWrite flavour 1
722 * BCC: play blindly the block0 BCC0 and block2 BCC1 bytes, beware!
723 * ATS: 0A78008102DBA0C119402AB5
724 * Anticol shortcut (CL1/3000): succeeds
733 [+] Magic capabilities : NTAG21x
738 Emulates fully NTAG213, 213F, 215, 216, 216F
740 Emulates partially UL EV1 48k/128k, NTAG210, NTAG212, NTAGI2C 1K/2K, NTAGI2C 1K/2K PLUS
742 Anticol shortcut (CL1/3000): fails
744 ### Proxmark3 commands
747 script run hf_mfu_magicwrite -h
752 ## "DESFire" APDU, 7b UID
762 * issue special APDUs
768 * ATS: 0675338102005110 or 06757781028002F0
770 Only mimics DESFire anticollision (but wrong ATS), no further DESFire support
772 ### Proxmark commands
776 hf 14a raw -s -c 0200ab00000704112233445566
780 hf 14a apdu -s 00ab00000704112233445566
788 420200ab00000704112233445566
790 ## "DESFire" APDU, 4b UID
796 * issue special APDUs
800 * ATQA: 0008 ??? This is not DESFire, 0008/20 doesn't match anything
802 * ATS: 0675338102005110 or 06757781028002F0
804 Only mimics DESFire anticollision (but wrong ATS), no further DESFire support
806 ### Proxmark commands
810 hf 14a raw -s -c 0200ab00000411223344
814 hf 14a apdu -s 00ab00000411223344
817 It accepts longer UID but that doesn't affect BCC/ATQA/SAK
819 ### pn53x-tamashell commands
822 420200ab00000411223344
827 The same effect (with better ATQA!) can be obtained with a MFC Gen1A that uses SAK defined in block0:
830 hf mf csetblk --blk 0 -d 1122334444204403A1A2A3A4A5A6A7A8
836 [+] MIFARE DESFire MF3ICD40
843 No such card is available.
845 Some vendor allow to specify an ID (PUPI) when ordering a card.
855 ### Proxmark3 commands
857 Always set a UID starting with `E0`.
860 hf 15 csetuid E011223344556677
864 script run hf_15_magic -u E004013344556677