首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MIFARE经典1k MIFARE 522-python lib

MIFARE经典1k MIFARE 522-python lib
EN

Stack Overflow用户
提问于 2015-03-15 17:06:43
回答 1查看 2.6K关注 0票数 1

我正在学习如何在Raspberry pi中使用MFRC522模块。我使用MFRC522 522-python。

我能够从mifare 1k读取和写入数据,直到我尝试更改密钥为止。我试着改变第7区。是这样的:

代码语言:javascript
复制
[0, 0, 0, 0, 0, 0, 255, 7, 128, 105, 255, 255, 255, 255, 255, 255]

在这样的变化之后:

代码语言:javascript
复制
[0, 0, 0, 0, 0, 0, 255, 7, 128, 105, 250, 250, 250, 250, 250, 250]

修改后,我可以用A键读取0-3扇区:

代码语言:javascript
复制
255, 255, 255, 255, 255, 255

第7区的关键是B:

代码语言:javascript
复制
250,250,250,250,250,250

尝试还原初始设置时,我错误地将扇区7更改为:

代码语言:javascript
复制
[255, 255, 255,255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]

现在我只能读UID了。我知道6-7-8块包含权限,但是我找不到关于这个主题的好文档。如何重置初始设置?

我正在尝试使用以下代码:

代码语言:javascript
复制
# 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"
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-15 22:01:11

这里的关于Mifare经典1k的好医生可以学习如何设置访问位。

我已经完全封锁了所有进入整个地区的通道。

注:

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29063576

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档