Mifare 1K 写入块但无法读取值块

问题描述 投票:0回答:2

过去三天我一直在寻找 Mifare 1K 的区块和价值区块。

例如我用这个APDU成功写入数据1.block:

< FF D6 00 01 10 61 79 79 69 6C 64 69 7A 66 61 74 69 68 31 31 31 
    - Start Block 01
    - Number of Bytes to Write: 16
    - Data: ayyildizfatih111
> 90 00
    - Write Binary Block Success

然后我可以阅读如下APDU:

< FF B0 00 01 10
    - Data Read at Start Block 01
    - Number of Bytes Read: 16
> 61 79 79 69 6C 64 69 7A 66 61 74 69 68 31 31 31 90 00 
    - ASCII Mode: ayyildizfatih111
    - Read Binary Block Success

但是当我尝试读取值块时,它给出了这个错误。

< FF B1 00 01 04 
    - ACR122U Read Value Block
> 63 00
    - Operation failed

所以我的问题是有什么区别?当我写入数据时,我应该使用二进制块还是值块。哪个更好?

nfc rfid mifare apdu contactless-smartcard
2个回答
0
投票

读取值块失败,因为您的块 1 不是值块。二进制数据块和值块共享相同的内存,区别只是如何格式化块的内容以及如何设置块的权限。

为了将块 1 转换为值块,您需要设置块访问位以允许值块操作(递减、传输、恢复和(可选)递增)。然后,您可以将该块写入值块(使用 ACR122U V2.02:使用值块操作命令或使用常规更新二进制块命令)。

值块的格式(使用二进制数据块操作时)为:

     +----------+----------+----------+----+----+----+----+
Byte |   0..3   |   4..7   |   8..11  | 12 | 13 | 14 | 15 |
     +----------+----------+----------+----+----+----+----+
Data | xxxxxxxx | yyyyyyyy | xxxxxxxx | uu | vv | uu | vv |
     +----------+----------+----------+----+----+----+----+

其中

xxxxxxxx
是 4 字节有符号(2 的补码)整数(LSB = 字节 0),
yyyyyyyy
xxxxxxxx
的反转值,
uu
是地址字节(可在实现备份机制时使用) ),
vv
uu
的反转值。

是否应该使用二进制数据块或应该使用值格式取决于您的应用程序。如果您想存储 4 字节整数值并且想要使用值块操作,您可能更喜欢使用值块格式。如果你想存储其他数据,不需要值块格式的冗余,只想使用二进制读/写操作,你可能更喜欢使用块作为自由格式的二进制数据块。


0
投票

Michael,你能帮助我更好地理解价值块吗?据我了解,前 4 个字节存储主值,它是一个 4 字节整数。我正在分析 MIFARE Classic 1K 卡的以下块,我认为价值块将位于块 61 和 62 中,但我不考虑该卡的当前余额:8.93

[=] -----+----------------+-------------------------------- ---------------+----------------- [=] 秒 |块|数据| ASCII码 [=]-----+-----+------------------------------------ --------------+----------------- [=] 0 | 0 | D5 E5 3A 39 33 88 04 00 43 22 A4 27 00 11 09 16 | ..:93...C".'.... [=]| 1 | 00 00 00 00 00 04 3C 00 0A 17 4C 49 4D 41 20 20 | ......<... [=] | 2 | 00 00 00 00 00 00 00 00 00 39 3A E5 D5 03 01 00 | .........9:..... [=] | 3 | 50 ED C8 2B 71 03 70 F8 78 00 51 F1 94 E4 2E AD | P..+q.p.x.Q..... [=] 1 | 4 | 00 55 DF 8A 0C 5A 40 00 00 00 00 00 00 00 00 00 | .U...Z@......... [=] | 5 | 00 00 00 00 00 00 00 00 00 00 00 00 00 A4 97 37 | ...............7 [=] | 6 | 00 00 00 00 00 00 00 00 00 39 3A E5 D5 03 01 00 | .........9:..... [=] | 7 | 7A 61 AB 92 E0 71 07 88 7F 00 51 F1 94 E4 2E AD | za...q....Q..... [=] 2 | 8 | 20 FC 01 00 00 00 00 28 31 69 78 01 12 CB 01 2F | ......(1ix..../ [=] | 9 | 72 75 60 00 00 00 00 00 00 00 00 00 00 79 4F 9A | ru

..........yO. [=]      |  10 | 9C 31 2D 02 00 43 28 45 CC CC CC CC CC CC CC CC | .1-..C(E........ [=]      |  11 | BB 8B 43 92 56 A5 07 88 7F 00 51 F1 94 E4 2E AD | ..C.V.....Q..... [=]    3 |  12 | 20 FC 01 00 00 00 00 28 31 69 78 01 12 CB 01 2F |  ......(1ix..../ [=]      |  13 | 72 75 60 00 00 00 00 00 00 00 00 00 00 79 4F 9A | ru
......yO。 [=]| 14 | 14 9B 31 2D 02 00 43 0A 3A A9 20 60 20 00 15 E2 88 | .1-..C.:。
 .... [=]      |  15 | DB DC DB E5 AE FB 07 88 7F 00 51 F1 94 E4 2E AD | ..........Q..... [=]    4 |  16 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  17 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  18 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  19 | CB 1F 7E AA 2F 5F 07 88 7F 00 51 F1 94 E4 2E AD | ..~./_....Q..... [=]    5 |  20 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  21 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  22 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  23 | 06 79 10 A9 4A 46 07 88 7F 00 51 F1 94 E4 2E AD | .y..JF....Q..... [=]    6 |  24 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  25 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  26 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  27 | 29 AF CC A7 3E 3E 07 88 7F 00 51 F1 94 E4 2E AD | )...>>....Q..... [=]    7 |  28 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  29 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  30 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  31 | FF 1B CC 61 31 B4 07 88 7F 00 51 F1 94 E4 2E AD | ...a1.....Q..... [=]    8 |  32 | 00 FC 00 00 10 00 08 00 03 02 22 00 00 00 00 00 | .........."..... [=]      |  33 | 00 00 00 00 00 00 00 00 00 00 00 00 00 5C A2 D1 | .............\.. [=]      |  34 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  35 | A9 2F 40 77 23 58 07 88 7F 00 51 F1 94 E4 2E AD | ./@w#X....Q..... [=]    9 |  36 | 00 00 00 00 10 00 08 00 03 22 22 00 00 00 00 00 | .........""..... [=]      |  37 | 00 00 00 00 00 00 00 00 00 00 00 00 00 BE 1A 34 | ...............4 [=]      |  38 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  39 | 9A 9D BD 89 12 0D 07 88 7F 00 51 F1 94 E4 2E AD | ..........Q..... [=]   10 |  40 | 7E 00 00 E1 01 3B 31 2D 91 A0 60 60 00 09 62 C2 | ~....;1-..``..b. [=]      |  41 | A0 00 0C C0 00 00 00 00 00 00 00 00 00 F8 AB E4 | ................ [=]      |  42 | 7E 00 00 E1 01 3B 31 2D AD 00 60 C0 00 0F A2 88 | ~....;1-..
...... [=]| 43 | 43 F4 29 2C F4 A1 C0 07 88 7F 00 51 F1 94 E4 2E AD | .),.......问...... [=] 11 | 44 | 44 82 00 16 10 00 00 00 00 00 00 00 00 00 98 D0 E5 | ...................... [=]| 45 | 45 7E 00 00 D1 01 34 31 2D AD 00 C0 C0 00 06 42 D1 | 〜....41-......B。 [=]| 46 | 46 00 00 13 00 00 00 00 00 00 00 00 00 00 6A 99 9E | ……………… [=]| 47 | 47 14 56 96 A4 F4 77 07 88 7F 00 51 F1 94 E4 2E AD | .V...w...Q..... [=] 12 | 48 | 48 7E 00 00 D1 01 AC 31 2D 91 A0 C0 60 00 0F A2 B7 | ~.....1-...
.... [=]      |  49 | 02 00 13 00 00 00 00 00 00 00 00 00 00 90 8E CC | ................ [=]      |  50 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  51 | 73 D2 32 10 40 10 07 88 7F 00 51 F1 94 E4 2E AD | [email protected]..... [=]   13 |  52 | E3 D5 FB 44 E1 0C F7 71 46 83 AB DA DB E9 61 5F | ...D...qF.....a_ [=]      |  53 | 2B F2 3E 15 FF DF FC 4B CE 09 E6 08 92 E7 D4 AD | +.>....K........ [=]      |  54 | 4E F0 F7 2D 24 A2 D3 25 07 8F 8A 14 E3 71 CB B0 | N..-$..%.....q.. [=]      |  55 | DE 38 BE C2 27 92 07 88 7F 00 51 F1 94 E4 2E AD | .8..'.....Q..... [=]   14 |  56 | 18 74 C1 7C 4A 6F F4 03 84 A6 49 0E AD 1A D8 6B | .t.|Jo....I....k [=]      |  57 | 0F 54 93 32 11 BB C3 78 EB CB F3 76 10 0E 7A EE | .T.2...x...v..z. [=]      |  58 | 3C B6 AA BE 00 80 BA 42 4F C5 6D 25 A9 73 B4 58 | <......BO.m%.s.X [=]      |  59 | 0C A4 F7 AA E0 CA 07 88 7F 00 51 F1 94 E4 2E AD | ..........Q..... [=]   15 |  60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ [=]      |  61 | 60 FF FF 7F 9F 00 00 80 60 FF FF 7F 0F F0 0F F0 | 
.......`....... [=]| 62 | 62 61 FF FF 7F 9E 00 00 80 61 FF FF 7F 0F F0 0F F0 |一个……一个…… [=]| 63 | 63 69 71 F1 AF 66 6B 66 98 79 00 9B E4 6F 65 F6 A7 | iq..fkf.y...oe.. [=]-----+-----+------------------------------------ --------------+-----------------

© www.soinside.com 2019 - 2024. All rights reserved.