Skip to content

Instantly share code, notes, and snippets.

@ceres-c
Last active March 16, 2022 11:47
Show Gist options
  • Save ceres-c/b84935799f5d65a4e41328d3ceaa075c to your computer and use it in GitHub Desktop.
Save ceres-c/b84935799f5d65a4e41328d3ceaa075c to your computer and use it in GitHub Desktop.
Using mfcuk r65 with libnfc 1.5.1 in 2018

You first need to download both libnfc 1.5.1 and mfcuk r65. The former is available among github releases wile the latter can be obtained via git rebase.

If you're on Arch you'll need pcsclite, if on Debian derivates libpcsclite-dev

Let's compile libnfc (<user> is your username)

mkdir -p ~/builds/nfc
cd ~/builds/nfc
wget https://github.com/nfc-tools/libnfc/releases/download/libnfc-1.5.1/libnfc-1.5.1.tar.gz
tar zxf libnfc-1.5.1.tar.gz
cd libnfc-1.5.1
./configure --prefix=/home/<user>/builds/nfc/prefix --with-drivers=all --sysconfdir=/etc/nfc --enable-serial-autoprobe
make
make install
cd ..

./configure options are needed to enable editing options via the usual /etc/nfc/libnfc.conf file and to allow using a PN532 shield with a USB-UART interface.

Then, for mfcuk

git clone https://github.com/nfc-tools/mfcuk mfcuk-r65
cd mfcuk-r65
git reset --hard 1b6d022
autoreconf -is
LIBNFC_CFLAGS=-I/home/<user>/builds/nfc/prefix/include LIBNFC_LIBS="-L/home/<user>/builds/nfc/prefix/lib -lnfc" ./configure --prefix=/home/<user>/builds/nfc/prefix
make

If needed, uncomment last line in /etc/nfc/libnfc.conf to enable PN532 discovery. You'll now need to run these last 2 commands

cd /home/<user>/builds/nfc/mfcuk-r65/src
LD_LIBRARY_PATH=/home/<user>/builds/nfc/prefix/lib ./mfcuk -C -R 0:A -v 3

Sorry for the poorly written doc, it's mostly a personal reminder for future reference

@funkyfoenky
Copy link

Hi, I got an error on "make" with mfcuk

/home/ubuntu/builds/nfc/mfcuk-r65/src/mifare.c:98: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mifare.c:103: undefined reference to nfc_initiator_transceive_bytes'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mifare.c:110: undefined reference to nfc_perror' /home/ubuntu/builds/nfc/mfcuk-r65/src/mifare.c:112: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mifare.c:99: undefined reference to nfc_perror' /home/ubuntu/builds/nfc/mfcuk-r65/src/mifare.c:115: undefined reference to nfc_configure'
mfcuk.o: In function mfcuk_darkside_select_tag': /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:908: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:914: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:921: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:931: undefined reference to nfc_initiator_select_passive_target' mfcuk.o: In function mfcuk_verify_key_block':
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:283: undefined reference to iso14443a_crc_append' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:286: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:292: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:295: undefined reference to nfc_initiator_transceive_bytes'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:299: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:350: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:355: undefined reference to nfc_initiator_transceive_bits' mfcuk.o: In function mfcuk_key_recovery_block':
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:437: undefined reference to iso14443a_crc_append' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:440: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:443: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:447: undefined reference to nfc_initiator_transceive_bytes'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:452: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:634: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:640: undefined reference to nfc_initiator_transceive_bits' mfcuk.o: In function mfcuk_darkside_reset_advanced':
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:865: undefined reference to nfc_configure' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:871: undefined reference to nfc_configure'
mfcuk.o: In function mfcuk_darkside_select_tag': /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:891: undefined reference to nfc_configure'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:901: undefined reference to nfc_configure' mfcuk.o: In function main':
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1877: undefined reference to nfc_disconnect' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1591: undefined reference to nfc_connect'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1599: undefined reference to nfc_initiator_init' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1734: undefined reference to nfc_initiator_select_passive_target'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1792: undefined reference to nfc_disconnect' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1795: undefined reference to nfc_connect'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1803: undefined reference to nfc_initiator_init' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1806: undefined reference to nfc_disconnect'
/home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1612: undefined reference to nfc_disconnect' /home/ubuntu/builds/nfc/mfcuk-r65/src/mfcuk.c:1437: undefined reference to iso14443a_crc_append'
collect2: error: ld returned 1 exit status
Makefile:342: recipe for target 'mfcuk' failed
make[2]: *** [mfcuk] Error 1
make[2]: Leaving directory '/home/ubuntu/builds/nfc/mfcuk-r65/src'
Makefile:358: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ubuntu/builds/nfc/mfcuk-r65'
Makefile:299: recipe for target 'all' failed
make: *** [all] Error 2

Any idea?

Thank you!

@r0metheus
Copy link

Go to ~/builds/nfc/mfcuk-r65/src, then edit the Makefile at line 197:

-LIBS =
+LIBS = $(LIBNFC_LIBS)

@funkyfoenky
Copy link

Thanks! it worked!!
However I can't figure out how to use it with my ACR122U reader and have it recognized under ubuntu. :(

@ceres-c
Copy link
Author

ceres-c commented Apr 15, 2018

Does lsusb list the ACR?
I was using a PN532 and don't own an ACR yet, so I can't really help you at the moment... :-/

@SnoopyTools
Copy link

What version and revision of Linux did yous compile libnfc and mfcuk r65 on? Thanks

@Unknown6555
Copy link

Unknown6555 commented Oct 17, 2018

Hi all !

I followed instruction for install mcfuk R65 with libnfc 1.5.1 , and I dont understand why the console say after start :

mfcuk: ERROR: initializing NFC reader: ACS ACR122U PICC Interface 00 00 / ACR122U214

I dont understand why ? 😞

@blackdevil8975
Copy link

blackdevil8975 commented Oct 30, 2018

Hi, getting the Error:

mfcuk: error while loading shared libraries: libnfc.so.2: cannot open shared object file: No such file or directory

when executing mfcuk

@seasonw
Copy link

seasonw commented Nov 17, 2018

Hi, getting the Error:

mfcuk: error while loading shared libraries: libnfc.so.2: cannot open shared object file: No such file or directory

when executing mfcuk

You must set library path while you run mfcuk, eg:-
LD_LIBRARY_PATH=/home/<user>/builds/nfc/prefix/lib ./mfcuk

@steve77r
Copy link

Hi when I try this I get "ERROR: connecting to NFC reader.

My reader is shown in lsusb, ARC122U

Can anyone help? Thanks

@alexhng1
Copy link

noobie here. just wondering what is meant by:
Go to ~/builds/nfc/mfcuk-r65/src, then edit the Makefile at line 197:

-LIBS =
+LIBS = $(LIBNFC_LIBS)

I tried opening that file and and not sure what I'm changing. I'm getting the same error previously posted when I try to
make' mfcuk.

@ceres-c
Copy link
Author

ceres-c commented Jan 6, 2019

@alexhng1 it means you have to replace the line LIBS = with LIBS = $(LIBNFC_LIBS)

This is gnu's diff notation

@ceres-c
Copy link
Author

ceres-c commented Jan 6, 2019

@steve77r Have you tried with sudo? Maybe you udev rules are not allowing you to access the device...

BTW Sorry for late answers, I don't get notifications for comments here...

@gozzolino95
Copy link

When executing mfcuk I got Endless time and some mfcuk_key_recovery_block() error (code 0x03)
What's wrong?

@alexhng1
Copy link

alexhng1 commented Feb 11, 2019

Thanks guys. Compiled and finally working mfcuk r65 with libnfc1.5.1, but getting endless mfcuk_key_recovery_block() error (code 0x09). I think this has been posted elsewhere nfc-tools/mfcuk#56, but just wondering if anyone else has ideas? Thanks

@kopolindo
Copy link

Thank you so much. It works for me to on Arch Linux (5.2.6-arch1-1-ARCH [20190807]) but it stop the scan after a while, with this error:
mfcuk: ERROR: mfcuk_key_recovery_block() (error code=0x08) mfcuk: ERROR: configuring NDO_ACTIVATE_FIELD
Does anyone know how to handle it? I cannot figuring out how to fix

@ceres-c
Copy link
Author

ceres-c commented Aug 11, 2019

@gozzolino95 You better read issues in mfuck original repo for that
@alexhng1 No idea, sorry. mfcuk isn't that reliable, I guess
@kopolindo I have never stumbled upon this particular error, partially because I don't really need to use mfcuk owning two proxmarks.
Similar errors were present in MFOC and were due to timing issues, you could have a look at the code to see if there are similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment