OSX下安装mfoc

这次重装系统以后,打算尽可能不用虚拟机了,所有工具能移植的移植,不能移植的就找替代品,全部原生使用。brew可以安装大部分常用工具,个别brew更新不及时的工具就需要自己下载编译,比如mfoc

首先安装编译mfoc所需的环境工具:

brew install libtool
brew install automake
brew install autoconf
brew install libusb
brew install pkg-config
brew install glib

然后下载libnfc,并编译安装:

git clone https://github.com/nfc-tools/libnfc
cd libnfc
autoreconf -vis
./configure --with-drivers=acr122_pcsc
make install

如果一切顺利就可以下载安装mfoc了,方法类似:

git clone https://github.com/nfc-tools/mfoc
cd mfoc
autoreconf -vis
./configure
make install

为了正常运行mfoc以及nfc-list,osx系统还需要做一些额外的配置,否则会出现nfc-list找不到设备之类的情况

首先要关闭sip,开机按command+R进入恢复模式,然后执行

csrutil disable

接下来保证pcscd服务正常运行,在主系统增加一个kext

/System/Library/Extensions/DUMMY.kext/Contents/Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- This is a dummy driver which binds to ACR122U. It -->
<!-- contains no actual code; its only purpose is to -->
<!-- prevent Apple's USBHID driver from exclusively -->
<!-- opening the device. -->
<plist version="1.0">
   <dict>
      <key>CFBundleDevelopmentRegion</key>
      <string>English</string>
      <key>CFBundleIconFile</key>
      <string />
      <key>CFBundleIdentifier</key>
      <string>com.ACR122U.dummy.kext</string>
      <key>CFBundleInfoDictionaryVersion</key>
      <string>6.0</string>
      <key>CFBundlePackageType</key>
      <string>KEXT</string>
      <key>CFBundleSignature</key>
      <string>????</string>
      <key>CFBundleVersion</key>
      <string>1.0.0d1</string>
      <key>IOKitPersonalities</key>
      <dict>
         <!-- The ACR122U USB interface -->
         <key>ACR122U</key>
         <dict>
            <key>CFBundleIdentifier</key>
            <string>com.ACR122U.dummy.kext</string>
            <key>IOClass</key>
            <string>com.ACR122U.dummy.kext</string>
            <key>IOProviderClass</key>
            <string>IOUSBInterface</string>
            <key>bConfigurationValue</key>
            <integer>1</integer>
            <key>bInterfaceNumber</key>
            <integer>0</integer>
            <key>idProduct</key>
            <integer>XXXXXXXXXXXXXXXXXXXXX</integer>
            <key>idVendor</key>
            <integer>XXXXXXXXXXXXXXXXXXXXX</integer>
         </dict>
      </dict>
      <key>OSBundleLibraries</key>
      <dict>
         <key>com.apple.iokit.IOUSBFamily</key>
         <string>1.8</string>
      </dict>
   </dict>
</plist>

其中idProduct和idVendor可以通过

system_profiler SPUSBDataType

获得,最后执行

sudo kextload -verbose /System/Library/Extensions/DUMMY.kext

加载kext

OSX下安装mfoc》上有6个想法

  1. 我有几个问题想向你请教
    1. 在我的mac上跑mfoc,到试密码时acr122容易断开连接,要重新拔插才能识别到。
    Using sector 00 as an exploit sector
    Sector: 5, type A, probe 0, distance 19315 …..
    Sector: 5, type A, probe 1, distance 19321 ….nfc_initiator_init!!: Input / Output Error

    Using sector 00 as an exploit sector
    Sector: 5, type A, probe 0, distance 19269
    nfc_initiator_init(pdi)=0, *pdi= 0x7fbebb801600

    nfc_initiator_init(pdi)=0, *pdi= 0x7fbebb801600
    .
    nfc_initiator_init(pdi)=0, *pdi= 0x7fbebb801600
    .
    nfc_initiator_init(pdi)=-1, *pdi= 0x7fbebb801600
    nfc_initiator_init!!: Input / Output Error

    这是因为我没有在主系统增加你说的这个kext吗?

    2. DUMMY.kext里面是只有Contents下面的Info.plist你给出的一个文件吗?
    我关闭了sip
    但加载kext时还是有错
    Requesting load of /System/Library/Extensions/DUMMY.kext.
    /System/Library/Extensions/DUMMY.kext failed to load – (libkern/kext) not found; check the system/kernel logs for errors or try kextutil(8).

    谢谢~

    • 这个是很久以前弄得了,当时严格按照这个步骤,确实成了,效果很好。DUMMY.kext我也是看stackoverflow上说的,具体原理我也不太知道。难道是我这个info.plist粘贴的有问题??你可以看看原贴:https://stackoverflow.com/questions/20253350/unable-to-claim-usb-interface-with-c-libusb-on-mac-os-x。话说前一段重装系统以后,好像也出现了经常断开的情况。

      不过现在改装linux+osx双系统了,不用在osx下折腾本来不属于它的了,终于出坑。尽管装linux以后也要稍微折腾一下配置什么的,但还是比osx下每次遇到一个什么工具就要折腾一次要好。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注