使用小米手机nfc模拟加密门卡

前言

支持nfc的小米可以模拟不加密的门卡,加密的需要使用小米白卡功能到物业里写入。嗯。。。物业怎么可能配合嘛!不如自己破解折腾一下,成本也不会太高。

本教程仅支持Mifare Classic 1K卡的破解,和写入小米手机的过程。不能用于其它非法用途。

原理

破解后的卡信息

上图中,扇区0里保存着卡的id信息,一般都会被写保护,但是有不锁扇区0的uid卡。扇区5是加密扇区,浅绿色是keyA,深绿色是keyB。我们就是通过破解加密扇区的keyA、keyB来获取该扇区数据信息并最终写入到小米手机中。

准备工作

  • 硬件:支持nfc的小米手机;要破解的门卡;pn532,淘宝30几块钱,最好买usb芯片焊好的;uid白卡滴胶卡,不锁扇区0的,淘宝5块钱一大把,买前问下掌柜。
  • 软件:win驱动,破解工具nfc-tools(pn532文件夹下),mifare。链接: https://pan.baidu.com/s/1sHoHCWKlv8s_GFpNVEVi7g 提取码: vp89

先在手机上安装mifare。
然后电脑安装驱动。有两个版本,v1200是最新的版本,v110是老版。我的win10不能使用v1200驱动,会出现感叹号。

v1200

这种情况下安装v100驱动,并在设备管理器里的设备上右键选择更新驱动程序->浏览我的计算机以查找驱动程序软件->让我从计算机上的可用驱动程序列表中选取

选择驱动版本

选择2009年的版本,点下一步安装

驱动安装成功

这时设备上的感叹号应该没有了,并且挂载到了COM5端口

打开pn532文件夹下的libnfc.conf文件

修改端口

将配置里的端口改成你实际挂载的端口

最后测试一下。把你的门卡放在pn532上。在下载的pn532文件夹下shift加右键打开菜单,选择在此处打开powershell窗口,输入.\nfc-list命令

PS C:\apps\pn532> .\nfc-list
C:\apps\pn532\nfc-list.exe uses libnfc 1.7.1
NFC device: pn532_uart:COM5 opened
1 ISO14443A passive target(s) found:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
       UID (NFCID1): 24  99  01  dd
      SAK (SEL_RES): 08

如果出现以上信息,说明pn532运行成功了

操作

使用mfoc破解加密卡

把门卡放在pn532上,在终端输入.\mfoc -P 50 -T 30 -O mycard.mfd命令开始破解

PS C:\apps\pn532> .\mfoc -P 50 -T 30 -O mycard.mfd
Found Mifare Classic 1k tag
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
* UID size: single
* bit frame anticollision supported
       UID (NFCID1): 24  99  01  dd
      SAK (SEL_RES): 08
* Not compliant with ISO/IEC 14443-4
* Not compliant with ISO/IEC 18092

Fingerprinting based on MIFARE type Identification Procedure:
* MIFARE Classic 1K
* MIFARE Plus (4 Byte UID or 4 Byte RID) 2K, Security level 1
* SmartMX with MIFARE 1K emulation
Other possible matches based on ATQA & SAK values:

Try to authenticate to all sectors with default keys...
Symbols: '.' no key found, '/' A key found, '\' B key found, 'x' both keys found

[Key: ffffffffffff] -> [xxxxx.xxxx......]
[Key: a0a1a2a3a4a5] -> [xxxxx.xxxx......]
[Key: d3f7d3f7d3f7] -> [xxxxx.xxxx......]
[Key: 000000000000] -> [xxxxx.xxxx......]
[Key: b0b1b2b3b4b5] -> [xxxxx.xxxx......]
[Key: 4d3a99c351dd] -> [xxxxx.xxxx......]
[Key: 1a982c7e459a] -> [xxxxx.xxxx......]
[Key: aabbccddeeff] -> [xxxxx.xxxx......]
[Key: 714c5c886e97] -> [xxxxx.xxxx......]
[Key: 587ee5f9350f] -> [xxxxx.xxxx......]
[Key: a0478cc39091] -> [xxxxx.xxxx......]
[Key: 533cb6c723f6] -> [xxxxx.xxxx......]
[Key: 8fd0a4f256e9] -> [xxxxx.xxxx......]

Sector 00 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 01 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 02 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 03 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 04 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 05 - Unknown Key A               Unknown Key B
Sector 06 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 07 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 08 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 09 - Found   Key A: ffffffffffff Found   Key B: ffffffffffff
Sector 10 - Unknown Key A               Unknown Key B
Sector 11 - Unknown Key A               Unknown Key B
Sector 12 - Unknown Key A               Unknown Key B
Sector 13 - Unknown Key A               Unknown Key B
Sector 14 - Unknown Key A               Unknown Key B
Sector 15 - Unknown Key A               Unknown Key B


Using sector 00 as an exploit sector
Sector: 5, type A, probe 0, distance 12969 .....
Sector: 5, type A, probe 1, distance 13027 .....
Sector: 5, type A, probe 2, distance 12823 .....
Sector: 5, type A, probe 3, distance 12879 .....
Sector: 5, type A, probe 4, distance 12519 .....
Sector: 5, type A, probe 5, distance 12619 .....
Sector: 5, type A, probe 6, distance 12679 .....
Sector: 5, type A, probe 7, distance 12527 .....
Sector: 5, type A, probe 8, distance 12525 .....
Sector: 5, type A, probe 9, distance 12577 .....
Sector: 5, type A, probe 10, distance 12569 .....
Sector: 5, type A, probe 11, distance 12625 .....
Sector: 5, type A, probe 12, distance 12615 .....
Sector: 5, type A, probe 13, distance 12669 .....
Sector: 5, type A, probe 14, distance 12565 .....
Sector: 5, type A, probe 15, distance 12623 .....
Sector: 5, type A, probe 16, distance 12569 .....
  Found Key: A [3aa93eb6a6eb]
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
Sector: 10, type A, probe 0, distance 12571 .....
Sector: 10, type A, probe 1, distance 12569 .....
  Found Key: A [bdbb578b6c89]
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
Sector: 11, type A
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
  Found Key: A [bdbb578b6c89]
Sector: 12, type A
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
  Found Key: A [bdbb578b6c89]
Sector: 13, type A
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
  Found Key: A [bdbb578b6c89]
Sector: 14, type A
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
  Found Key: A [bdbb578b6c89]
Sector: 15, type A
  Data read with Key A revealed Key B: [000000000000] - checking Auth: Failed!
  Found Key: A [bdbb578b6c89]
Sector: 5, type B, probe 0, distance 12721 .....
Sector: 5, type B, probe 1, distance 12621 .....
Sector: 5, type B, probe 2, distance 12621 .....
Sector: 5, type B, probe 3, distance 12573 .....
  Found Key: B [0604acbb55d5]
Sector: 10, type B
  Found Key: B [bdbb578b6c89]
Sector: 11, type B
  Found Key: B [bdbb578b6c89]
Sector: 12, type B
  Found Key: B [bdbb578b6c89]
Sector: 13, type B
  Found Key: B [bdbb578b6c89]
Sector: 14, type B
  Found Key: B [bdbb578b6c89]
Sector: 15, type B
  Found Key: B [bdbb578b6c89]
Auth with all sectors succeeded, dumping keys to a file!
Block 63, type A, key bdbb578b6c89 :00  00  00  00  00  00  7f  07  88  69  00
00  00  00  00  00
....

从输出信息中可以发现mfoc找到了3个key: 3aa93eb6a6ebbdbb578b6c890604acbb55d5。记一下,之后会用到。

运行成功后会在pn532文件夹下生成mycard.mfd文件

写入uid白卡

把从淘宝上买的白卡放到pn532下,运行.\nfc-mfclassic W a mycard.mfd。运行成功后会克隆一张与原门卡信息一样的卡。

PS C:\apps\pn532> .\nfc-mfclassic W a mycard.mfd
NFC reader: pn532_uart:COM5 opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
       UID (NFCID1): 24  99  01  dd
      SAK (SEL_RES): 08
Guessing size: seems to be a 1024-byte card
Sent bits:     50  00  57  cd
Sent bits:     40 (7 bits)
Received bits: a (4 bits)
Sent bits:     43
Received bits: 0a
Writing 64 blocks |................................................................|
Done, 64 of 64 blocks written.

需要注意的是,输出的最后一行一定要有Done,否则都是失败。

清空白卡数据扇区

目前克隆好的白卡和原门卡一样,存在加密扇区,是不能直接模拟到小米手机上的。我们需要把白卡里除扇区0的数据都清掉。

打开手机上的mifare软件。选择增加密钥文件,新建一个mykey.keys文件。第一行固定为FFFFFFFFFFFF,然后把上面用mfoc找到的密钥复制进去并保存。回到主菜单选择写标签->工厂格式化,勾选自定义的密钥文件。将克隆好的白卡放到手机背部,识别后点击启动映射并格式化标签。完成后使用读标签功能看下除扇区0外其他扇区是不是都清空了。

清空数据扇区

将扇区0克隆到手机上

打开小米钱包app,选择门卡->模拟实体门卡。点开始检测后,将清了数据的白卡放到手机背部,检测到并通过认证后开始模拟。模拟完成后双击电源键可以看到我们模拟的卡。


克隆到手机上

写入其它数据扇区

双击电源键找到模拟的卡,手机提示请靠近读卡器后,将手机背面放到pn532上。终端输入命令.\nfc-mfclassic w a mycard.mfd。注意中间的w是小写。

PS C:\apps\pn532> .\nfc-mfclassic w a mycard.mfd
NFC reader: pn532_uart:COM5 opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
       UID (NFCID1): 24  99  01  dd
      SAK (SEL_RES): 28
Guessing size: seems to be a 1024-byte card
Writing 64 blocks |...............................................................|
Done, 63 of 64 blocks written.

但输出为Done后,加密门卡模拟就全部成功了。去刷门禁试试吧。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,302评论 5 470
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,232评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,337评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,977评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,920评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,194评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,638评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,319评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,455评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,379评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,426评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,106评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,696评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,786评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,996评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,467评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,043评论 2 341

推荐阅读更多精彩内容