【发布时间】:2020-08-30 11:10:37
【问题描述】:
我有一张NTAG213 NFC 贴纸。我想知道如何使这个贴纸只读。如果稍后我切换到NTAG215,我怎么能让该标签只读。实际制作不同类型的贴纸只读的过程是什么。当我说只读时,我的意思是 NFC 的记录永远不能被修改,但设备仍然可以在没有身份验证的情况下读取记录。
我阅读了https://answers.launchpad.net/nfcpy/+question/242606 并尝试实施它的解决方案
import nfc
from time import sleep
from nfc.clf import RemoteTarget
import ndef
clf = nfc.ContactlessFrontend('usb')
while True:
target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
if target is None:
sleep(1)
continue
serial = target.sdd_res.hex()
tag = nfc.tag.activate(clf, target)
if not tag.ndef:
print("No NDEF records found!")
continue
for record in tag.ndef.records:
print("Found record: " + str(record))
record = ndef.UriRecord("https://www.example.com")
tag.ndef.records = [record]
# Code is fine until it gets to these tag indexes
tag[15] = tag[15] | 0x0F
tag[10] = 0xFF
tag[11] = 0xFF
我得到错误:
File "test.py", line 26, in <module>
tag[15] = tag[15] | 0x0F
TypeError: 'NTAG213' object does not support indexing
【问题讨论】:
-
所有详细信息都在卡的数据表中nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf 有多种方法可以通过写入正确的内存位置来更改锁定位,有两种方法可以永久使内存为只读(每个内存区域一个)或者可能更好的是密码保护写操作(因为如果你知道密码,这可以逆转)
-
tag是一个类,而不是一个数组。您不能通过数组索引访问类。您必须使用此类(或 API)中定义的函数。
标签: python python-3.x nfc access-control lockbits