APDU 在 mifare classic 上写入块命令 [英] APDU Write block commands on mifare classic

查看:137
本文介绍了APDU 在 mifare classic 上写入块命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将一些数据写入我的 mifare 经典卡.首先我发送这两个返回 90 00 的命令:

I have been trying to write some data to my mifare classic cards. first I send these two commands which returns 90 00:

加载 Mifare 密钥:

FF 82 20 01 06 FF FF FF FF FF FF

FF 82 20 01 06 FF FF FF FF FF FF

验证:

FF 86 00 00 05 01 00 01 60 01

FF 86 00 00 05 01 00 01 60 01

现在我可以向扇区 0 和块 1 + 2 写入命令

now I can write commands to sector 0 and block 1 + 2

ff d6 00 01 10 14 01 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1

ff d6 00 01 10 14 01 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1

ff d6 00 02 10 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1

ff d6 00 02 10 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1

我错误地覆盖了块 3 几次,使该扇区看起来不可读:

i mistakenly overwritten block 3 a few times rendering this sector unreadable it seems:

如果我发送命令ff d6 00 04 10 我收到返回错误 69 82,我在谷歌上搜索为身份验证错误

if I send the command ff d6 00 04 10 I get return error 69 82 which i googled as authentication error

我需要对每个部门进行身份验证吗?如果是这样,对下一个和后续扇区执行此操作的命令是什么?

do I need to authenticate to every sector? if so what is the command to do this for the next and following sectors?

推荐答案

是的,您必须在对该扇区的块进行读/写之前对每个扇区进行身份验证.现在您已执行身份验证命令并覆盖块 3(扇区预告片),这意味着密钥和访问权限已更改.

yes, You have to authenticate every sector before read/write on the block of that sector.Now you have execute Authentication command and you overwrite the block 3(sector trailer) that means the keys and access right has been change.

用于验证块的 APDU:-

Authenticate a block 的 APDU 格式应为以下格式.

The APDU format for Authenticate a block should be in following format.

CLA+ INS+ P1+ P2+ Lc+(版本+ AddMSB + AddLSB + KeyID + KeyNumber)

CLA+ INS+ P1+ P2+ Lc+ (Version + AddMSB + AddLSB + KeyID + KeyNumber)

例如:-

CLA = FF

INS = 86

P1 = 00

P2 = 01(验证块号)

P2 = 01 (Block Number for Authentication)

Lc = 05(数据字段的长度)

Lc = 05 (Length of Data Field)

数据字段 = 版本 + AddMSB + AddLSB + KeyId + KeyNumber

Data Field = Version + AddMSB + AddLSB + KeyId + KeyNumber

版本=01

添加MSB=00

AddLSB=05(区块编号)

AddLSB=05 (Block Number)

KeyID=60/61(keyA 为 60,keyB 为 61)

KeyID=60/61 (60 for keyA and 61 for keyB)

KeyNo= 00(读卡器的Key Slot号)

KeyNo= 00 (Key Slot number of reader)

FF 86 00 00 05 01 00 05 60 00

FF 86 00 00 05 01 00 05 60 00

这篇关于APDU 在 mifare classic 上写入块命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆