Quantcast
Channel: LinE's Blog
Viewing all articles
Browse latest Browse all 25

把树莓派打造成NFC破解神器

$
0
0

基础准备

近来闲来无事,遂把手边的树莓派做成了一个便携的NFC破解工具
使用的是树莓派B+,NFC读卡器使用的是ACR122U,安装了ACR122U的驱动,使用的是GNU LibNFC作为读写软件,使用mfoc作为破解软件
具体硬件如下


相关软件下载地址:
raspbian-jessie-lite
https://downloads.raspberrypi.org/raspbian_lite_latest
Win32DiskImager
https://sourceforge.net/projects/win32diskimager/files/latest/download
龙杰ACR122U读卡器Linux驱动
http://www.acs.com.hk/download-driver-unified/5864/ACS-Unified-PKG-Lnx-112-P.zip
LibNFC
http://dl.bintray.com/nfc-tools/sources/libnfc-1.7.1.tar.bz2
mfoc
https://mfoc.googlecode.com/files/mfoc-0.10.6.tar.gz

操作系统

操作系统方面我使用的是Raspbian,版本为2016-02-26-raspbian-jessie-lite
使用Win32DiskImager把镜像写入到TF卡中,为了能够让树莓派开机的时候把图像输出到HDMI,需要修改写入后的一个配置文件,该文件在镜像写入后,电脑上有个名为boot的60M的分区
编辑里面的config.txt


将选中这行的注释去掉

# For more options and information see
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

然后把卡插入树莓派,给小派加电,启动操作系统

基础配置

首先是需要给小派配置一个IP地址,以便于远程SSH的访问,我这里配置的IP地址为192.168.100.2,网关为192.168.100.254
编辑/etc/network/intarfaces
添加如下内容

vi /etc/network/intarfaces
# ----------------
auto eth0
iface eth0 inet static
address 192.168.100.2
netmask 255.255.255.0
gateway 192.168.100.254

然后重启网络,就可以使用ssh访问了

service networking restart

使用ssh连接小派,账号为pi,密码为raspberry,因为我个人比较习惯使用root进行操作,所以这里我登陆上去之后更改了root的密码,开启了ssh的root登陆

$ sudo su
passwd root
# 输入预设置的root密码

然后修改ssh配置文件,编辑/etc/ssh/sshd_config

vi /etc/ssh/sshd_config
# ----------------
# 28行,改为
PermitRootLogin yes

然后重启ssh服务

service ssh restart

接下来,设置小派的软件源,我这里使用的是阿里云的源
修改 /etc/apt/sources.list

vi /etc/apt/sources.list
# ----------------
deb http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib

然后进行更新

apt-get update
apt-get upgrade

然后安装vim等工具

apt-get install -y vim

配置NFC读取环境

首先是安装ACR122U的驱动
将ACS-Unified-PKG-Lnx-112-P.zip上传至小派,然后解包,使用dpkg安装

unzip ACS-Unified-PKG-Lnx-112-P.zip
cd acsccid_linux_bin-1.1.2/raspbian/jessie/
dpkg -i libacsccid1_1.1.2-1~bpo8+1_armhf.deb

然后安装libnfc
首先安装编译环境,然后将libnfc-1.7.1.tar.bz2上传至小派,解包,进行编译安装

apt-get install make gcc libusb-dev libpcsclite-dev
tar -jxvf libnfc-1.7.1.tar.bz2
cd libnfc-1.7.1/
./configure --with-drivers=acr122_usb --prefix=/usr --sysconfdir=/etc  
make
make install

然后编译安装mfoc,将mfoc-0.10.6.tar.gz上传到小派,解包,进行编译安装

apt-get install autoconf checkinstall
tar -jxvf mfoc-0.10.6.tar.gz
cd mfoc-0.10.6/
autoreconf -vis
./configure
make
checkinstall -D -y --install
make install

然后禁用掉pn533的内核模块,不然小派是没办法去识别ACR122U的

modprobe -r pn533 nfc
vi /etc/modprobe.d/fbdev-blacklist.conf
# ----------
# 末尾加入
blacklist pn533 nfc

然后将ACR122U连接到小派,查看一下是否识别

nfc-list

进行破解

我这里随便问同事要了张Mifare 1K的卡,先用手机上的MCT进行读取,发现扇区1加密,没办法读取,其他扇区是可以成功读取的,尝试使用mfoc进行破解


把卡片放到ACR122U上

键入如下命令开始破解,破解完成之后保存的文件名为mycard.mfd
mfoc -P 50 -T 30 -O mycard.mfd


大约等了10分钟左右,破解完成!

查看一下mycard.mfd,卡中数据已经完全可以看到了

Viewing all articles
Browse latest Browse all 25

Trending Articles