Code Monkey home page Code Monkey logo

nfc-iclass's Introduction

nfc-iclass

iClass / Picopass tool for libnfc

A CLI tool for reading and writing HID iClass (Picopass) Access Control cards.

Building & Installing

git submodule update --init
autoreconf -vis
rm -rf build && mkdir build
cd build
../configure
make
sudo make install

Running

Default behaviour is to dump APP1.

For more options:

nfc-iclass -h

Usage: ./src/nfc-iclass [options] [BINARY FILE|HEX DATA]

  Options:

	-c <KEY>      Use CREDIT KEY Kc / APP2 (default is DEBIT KEY Kd / APP1)
	-C <?|CARD>   Create CONFIG card (? prints list of config cards)
	-d <KEY>      Use non-default DEBIT KEY for APP1
	-e            AUTH KEY is ELITE
	-h            You're looking at it
	-k <KEY>      Keyroll KEY for CONFIG card
	-n            Do not DIVERSIFY key
	-o <FILE>     Write TAG data to FILE
	-r <KEY>      Re-Key with KEY (assumes new key is ELITE)
	-R <KEY>      Re-Key to non-ELITE
	-w <BLOCK>    WRITE to tag starting from BLOCK (specify # in HEX)

	If no KEY is specified, default HID Kd (APP1) will be used

Examples

Use ELITE key for APP1:

	nfc-iclass -d DEADBEEFCAFEF00D -e

Dump contents of APP2:

	nfc-iclass -c 0DC442031337D00F

Write APP1 blocks 8 & 9:

	nfc-iclass -w 8 aabbccddaabbccddaabbccddaabbccdd

or

	nfc-iclass -w 8 /tmp/iclass-8-9-dump.icd

Re-key to ELITE key:

        nfc-iclass -r deadbeefcafef00d

Revert to default iClass Kd (note re-key to NON-ELITE with -R)

        nfc-iclass -d deadbeefcafef00d -e -R AFA785A7DAB33378

Show available CONFIG cards:

        nfc-iclass -C ?

Create CONFIG card AV1:

        nfc-iclass -C AV1

Create KEYROLL card:

        nfc-iclass -C KRE -k F00FBEEBD00BEEEE

Config cards

iClass readers can be reconfigured using CONFIG cards. These will normally be provided free of charge upon request but as we now have the master Kd it's easy enough to dump the set and recreate them at will.

The available cards are:

  •   AV1:	Audio/Visual #1 - Beep ON, LED Off, Flash GREEN on read
    
  •   AV2:	Audio/Visual #2 - Beep ON, LED RED, Host must flash GREEN
    
  •   AV3:	Audio/Visual #3 - Beep ON, LED Off, Host must flash RED and/or GREEN
    
  •   KP1:	Keypad Output #1 - Buffer ONE key (8 bit Dorado)
    
  •   KP2:	Keypad Output #2 - Buffer ONE to FIVE kets (standard 26 bit)
    
  •   KP3:	Keypad Output #3 - Local PIN verify
    
  •   CSN1:	Mifare CSN #1 - 32 bit reverse output
    
  •   CSN2:	Mifare CSN #2 - 16 bit output
    
  •   CSN3:	Mifare CSN #3 - 34 bit output
    
  •   KRD:	Keyroll DISABLE - Set ELITE Key and DISABLE Keyrolling
    
  •   KRE:	Keyroll ENABLE - Set ELITE Key and ENABLE Keyrolling
    
  •   RSTR:	Reset READER - Reset READER to defaults
    
  •   RSTE:	Reset ENROLLER - Reset ENROLLER to defaults
    

Note that a config card is slightly different from a standard one in that APP1 uses more blocks. This matters for KEYROLL cards as they need the extra space to store the new keys. Other types may work on a standard card but the most reliable method is to use an existing config card and overwrite it.

nfc-iclass's People

Contributors

adamlaurie avatar bettse avatar doegox avatar ludovicrousseau avatar smortex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nfc-iclass's Issues

Compilation Errors under MinGW

In trying to compile under Windows, I've run into a couple of issues. Some I've been able to workaround, and some I have not.

The pkg-config seems to be unable to detect that libnfc is installed so I have to manually edit some library paths to point to the right /libnfc/include folder and all is well eventually.

err.h is not a supported header under Windows, but it doesn't seem to be actually used by nfc-iclass so commenting that out seems to resolve that issue, but this is the compilation error I cannot resolve:

nfc-iclass.h:2:6: error: conflicting types for 'strncasecmp'
    2 | bool strncasecmp(char *s1, char *s2, int len);
      |      ^~~~~~~~~~~
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/io.h:10,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/unistd.h:10,
                 from nfc-iclass.c:48:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:116:28: note: previous definition of 'strncasecmp' was here
  116 |   __CRT_INLINE int __cdecl strncasecmp (const char *__sz1, const char *__sz2, size_t __sizeMaxCompare) { return _strnicmp (__sz1, __sz2, __sizeMaxCompare); }
      |                            ^~~~~~~~~~~
nfc-iclass.c: In function 'main':
nfc-iclass.c:228:55: error: 'S_IRUSR' undeclared (first use in this function)
  228 |         if((outfile= open(optarg, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) <= 0)
      |                                                       ^~~~~~~
nfc-iclass.c:228:55: note: each undeclared identifier is reported only once for each function it appears in
nfc-iclass.c:228:65: error: 'S_IWUSR' undeclared (first use in this function)
  228 |         if((outfile= open(optarg, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) <= 0)
      |                                                                 ^~~~~~~
nfc-iclass.c:228:75: error: 'S_IRGRP' undeclared (first use in this function)
  228 |         if((outfile= open(optarg, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) <= 0)
      |                                                                           ^~~~~~~
nfc-iclass.c:228:85: error: 'S_IWGRP' undeclared (first use in this function)
  228 |         if((outfile= open(optarg, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) <= 0)
      |                                                                                     ^~~~~~~
nfc-iclass.c: At top level:
nfc-iclass.c:629:6: error: conflicting types for 'strncasecmp'
  629 | bool strncasecmp(char *s1, char *s2, int len)
      |      ^~~~~~~~~~~
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/io.h:10,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/unistd.h:10,
                 from nfc-iclass.c:48:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:116:28: note: previous definition of 'strncasecmp' was here
  116 |   __CRT_INLINE int __cdecl strncasecmp (const char *__sz1, const char *__sz2, size_t __sizeMaxCompare) { return _strnicmp (__sz1, __sz2, __sizeMaxCompare); }
      |                            ^~~~~~~~~~~
make[2]: *** [Makefile:404: nfc-iclass.o] Error 1

I understand this is probably not something that was tested to compile under Windows, but I would be happy to help test any proposed fixes as needed. I've also compiled this successfully under an Ubuntu VM but for some reason performance with a PN533 seems to be really spotty and tags only detect intermittently.

no tag was found - "libnfc.driver.acr122_usb Command Code verification failed"

Hi

My ACR122U-A9 is working for mifare related stuff, but I cannot seem to make it work for ICLASS.
I verified my ICLASS legacy tag on a proxmark to make sure it is not the tag that is the problem.

Any ideas on troubleshooting this issue?

[root@mint:~/nfc-iclass# nfc-scan-device
nfc-scan-device uses libnfc libnfc-1.8.0-41-gd9a04a5
1 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:004]

root@mint:~/nfc-iclass# nfc-iclass 

NFC device: ACS / ACR122U PICC Interface opened
nfc-iclass: ERROR: no tag was found

error	libnfc.driver.acr122_usb	Command Code verification failed

Based on the following, I tried one of the suggested fixes, which did not work either.
https://gist.github.com/danieloneill/3be43d5374c80d89ea73

root@mint:~/nfc-iclass# nfc-list 
NFC device: ACS / ACR122U PICC Interface opened
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed
error	libnfc.driver.acr122_usb	Command Code verification failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.