我正在学习如何在Raspberry pi中使用MFRC522模块。我使用MFRC522 522-python。
我能够从mifare 1k读取和写入数据,直到我尝试更改密钥为止。我试着改变第7区。是这样的:
[0, 0, 0, 0, 0, 0, 255, 7, 128, 105, 255, 255, 255, 255, 255, 255]在这样的变化之后:
[0, 0, 0, 0, 0, 0, 255, 7, 128, 105, 250, 250, 250, 250, 250, 250]修改后,我可以用A键读取0-3扇区:
255, 255, 255, 255, 255, 255第7区的关键是B:
250,250,250,250,250,250尝试还原初始设置时,我错误地将扇区7更改为:
[255, 255, 255,255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]现在我只能读UID了。我知道6-7-8块包含权限,但是我找不到关于这个主题的好文档。如何重置初始设置?
我正在尝试使用以下代码:
# Welcome message
print "Welcome to the MFRC522 data read example"
print "Press Ctrl-C to stop."
# This loop keeps checking for chips. If one is near it will get the UID and authenticate
while continue_reading:
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# If a card is found
if status == MIFAREReader.MI_OK:
print "Card detected"
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# If we have the UID, continue
if status == MIFAREReader.MI_OK:
# Print UID
print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3])
# This is the default key for authentication
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
setas = [0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x07,0x80,0x69,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
sect = 7
# Select the scanned tag
MIFAREReader.MFRC522_SelectTag(uid)
# Authenticate
status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, sect, key, uid)
# Check if authenticated
if status == MIFAREReader.MI_OK:
MIFAREReader.MFRC522_Read(sect)
MIFAREReader.MFRC522_Write(sect,setas)
MIFAREReader.MFRC522_Read(sect)
MIFAREReader.MFRC522_StopCrypto1()
else:
print "Authentication error"发布于 2015-03-15 22:01:11
这里的关于Mifare经典1k的好医生可以学习如何设置访问位。
我已经完全封锁了所有进入整个地区的通道。
注:
To further complicate things, there are also 3 “negated” bits per block that are stored as the opposite value of the “normal” bits. So, if
C10 is 1, then C10 must be 0. The tag will check to ensure these negated values all check out, and if they don’t then the tag will assume
the tag’s memory is corrupt or there has been some sort of tampering attempt and completely block all access to the entire sector. It is
essential that the access bits are properly written to the tag or sectors with invalid sector trailers will be unreadable.其他好的文档可以在adafruit文档中找到,如:学习Adafruit
https://stackoverflow.com/questions/29063576
复制相似问题