From: http://www.backtrack-linux.org/wiki/index.php/RFID_Cooking_with_Mifare_Classic
Contents [Hide]
- 1 RFID cooking with Mifare classic
- 2 0x00-Preface
- 3 0x01-hardware
- 4 0x02-Software
- 4.1 acr122u driver
- 4.2 open source near field communication (NFC) Library/libnfc/
- 4.3 mfoc-Mifare classic offline cracker
- 5 0x03-dumping & cooking
- 6 0x04-ISIC issue
- 7 0x06-conclusion
- 8 0x07-What's next?
- 9 0x08-Thanks
- 10 0x09-references & links
- 11 0x0a-about
|
RFID cooking with Mifare classic
Disclaimer: The information and reference implementation is provided:
- For informational use only as part of academic or research study, especially in the field of informational security, cryptography and secure systems
- As-is without any warranty, support or liability-any damages or consequences obtained as a result of consulting this information if purely on the side of the reader
- Not to be used in illegal circumstances (for example to abuse, hack or trick a system which the reader does not have specific authorizations to such as ticketing systems, public transport, University/ISIC cards, building Access systems or whatsoever systems using Mifare classic as core technology)
Notes:
- This article contain no original research. All the research and implementation was made by other people and communities and is publicly available. We made this two cents just for fun and because we love backtrack.
- This is not A-Z guide so try harder!
0x00-Preface
Some of you may have read that the proprietary specified Ric key cryptographic algorithm of the Mifare classic card has been broken. the Mifare classic card is used in physical access control systems (PACS) and Contact less payment systems (including tollway and public transportation systems ). by some estimates, there are 500 million Mifare cards deployed worldwide, and the majority of them are Mifare classic cards.
Mifare Classic is a inexpensive, entry-level chip, based on ISO/IEC 14443 Type A, 1kb or 4kb. uses 13.56 MHz contactless smartcard standard, proprietary crypto1 with 48 bits keys. there is no protection against cloning or modifications. anyone with 50 € reader can use this weakness against your infrastructure. at least one sector is always encrypted with default key. after cracking all keys, hackers are able to change name, Students University number, expiration date... this cookbook is proof of concept how easy that can be done. chosen ingredients: backtrack | touchatag starter package tested on: backtrack 4 R2, backtrack 5 Final, (32bit)
Dependencies
root@bt:~# apt-get install flex libpcsclite-dev libusb-dev checkinstall
0x01-hardwaretouchatag-acr122u
Touchatag is ACS acr122 (u) NFC reader usb rfid reader. the USB reader works at 13.56 MHz (high frequency RFID) and has a readout distance of about 4 cm (1 inch) when used with the touchatag RFID tags. this product is made by Advanced Card Systems Limited and seems to be available in different layouts but hardware doesn't differ so much. they are all using a pn532 NFC controller chip and a st7 microcontroler unit.
0x02-softwareacr122u driver
root@bt:~# wget http://www.acs.com.hk/drivers/eng/ACR122U_driver_Lnx_Mac10.5_10.6_1.02_P.zip root@bt:~# unzip -d acr122u ACR122U_driver_Lnx_Mac10.5_10.6_1.02_P.zip root@bt:~# cd acr122u root@bt:~# tar -jxvf acsccid-1.0.2.tar.bz2root@bt:~# cd acsccid-1.0.2 root@bt:~# ./configureroot@bt:~# make root@bt:~# checkinstall -D -y --install
Open source near field communication (NFC) Library/libnfc/
Libnfc is the first free nfc sdk and programmers API released under the GNU lesser General Public License.
root@bt:~# apt-get install -y debhelper libtool && wget http://libnfc.googlecode.com/files/libnfc-1.4.2.tar.gz root@bt:~# tar xfvz libnfc-1.4.2.tar.gz &&cd libnfc-1.4.2 root@bt:~# svn checkout http://libnfc.googlecode.com/svn/tags/libnfc-1.4.2/debian root@bt:~# dpkg-buildpackage -rfakerootroot@bt:~# dpkg -i ../libnfc*.deb
Check your reader/target with NFC-list.
root@bt:~# nfc-list nfc-list use libnfc 1.4.2 (r891) Connected to NFC device: ACS ACR122U 00 00 / ACR122U103 - PN532 v1.6 (0x07) 1 ISO14443A passive target(s) was found: ATQA(SENS_RES):00 02 UID (NFCID1): xx xx xx xx SAK (SEL_RES): 18
If your reader is rejected because of the firmware (Log message: „ firmware (x. y) is bogus! ") Just disable version checking. All you need to do is change ifddriveroptions (line 55 in info. plist) to skip version checking like this:
root@bt:~# nano /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plistifdDriverOptions0×0005
Afterwards, restart the pcscd daemon and your touchatag reader shoshould be recognized and ready.
Mfoc-Mifare classic offline cracker
Mifare classic offline cracker is a tool that can recover keys from Mifare classic cards. thanks to Norbert szetei and Pavol luptak for their attack's implementation. mfoc is utility to compute (crack) All keys (a and B) to all sectors, providing at least one of the keys is already known. keys file is the file, where mfoc will store cracked keys. format of that file is compatible with NFC-mfclassic, so you can then use it to dump the card into file, or write a dump onto the card.
root@bt:~# wget http://nfc-tools.googlecode.com/files/mfoc-0.10.2.tar.gz && tar -xvzf mfoc-0.10.2.tar.gz root@bt:~# cd mfoc-0.10.2 root@bt:~# autoreconf -vis root@bt:~# ./configure root@bt:~# makeroot@bt:~# checkinstall -D -y --install
0x03-dumping & cooking
Psscd coordinates the loading of drivers for card readers. it allows applications to access smart cards and readers without knowing details of the card or reader. it is a resource manager that coordinates communications with smart card readers and smart cards and cryptographic tokens that are connected to the system. I prefer start pcscd in foreground (no Daemon) with pcscd-f. then it's time to start mfoc. use high number of probes, because default number of probes for a key recovery for one sector is 20. whole cracking cocould take from 30 minutes to 30 hours.
You can also use the-K key parameter, to add a key to the list of known keys, which is being tried against your card in the initial phase. the-K option somehow didn't work for me, so I always compile my known keys directly into mfoc. c search for "array with default Mifare classic keys" not sure about other countries, but in country where I live keys are the same. once you have keys from all sectors, you should be able to use RFID-fu against other cards, which is epic fail.
root@bt:~# nfc-mfclassic --help Usage: nfc-mfclassic r|w a|b <dump.mfd> [<keys.mfd>]r|w- Perform read from (r) or write to (w) card a|b- Use A or B keys for action <dump.mfd>- MiFare Dump (MFD) used to write (card to MFD) or (MFD to card)<keys.mfd>- MiFare Dump (MFD) that contain the keys (optional)Or: nfc-mfclassic x <dump.mfd> <payload.bin> x- Extract payload (data blocks) from MFD <dump.mfd>- MiFare Dump (MFD) that contains wanted payload <payload.bin> - Binary file where payload will be extracted
Keep in mind that card uid will be not affected (not changed) with this process. buy some blank card or proxmark III if that is what you want. if you are now thinking about dumping your electronic wallet right after recharge and when credit comes to zero, writing content back, then please don't do it. what can stop you from doing that? Well, probably only your conscience, but if the card gets blocked in 24 hours after first use then don't complain. Yes, there are online checking and billing systems out there for basic cards.
0x04-ISIC issue
With ISIC-International Student Identity Card attacker can abuse around ten service not only one. ISIC cards are widely used for entrance, transportation, dining payments and varous others services or discounts. according to homepage there are 4.5 million cardholders in 120 countries. cards shoshould be replaced with more secure types ASAP. it is possible to do much more than that, but sufficient for demonstration let's play a little...
At some universities, there is only one entry security check-ISIC. as you can see this is trivial to bypass. we did deletests with public transportation systems and with university systems. results are all the same-those systems are easily hackable.
0x06-conclusion
Finally, when will people learn their lesson? Cryptographic algorithms shocould be public so that they can be scrutinized and tested. secret algorithms aren't more valuable because they are secret. anyone needing a highly secure Smart Card shocould make sure there's layered security and not just depend on the chip's encryption.
0x07-What's next?
- Since I have access to proxmark III which is universal RFID hacking tool which can be used for 100% accurate cloning (even UID ), I may once write second edition about c00king with Mifare classic and hid prox...
- Arming backtrack with GSM attack suite?
0x08-Thanks
This cookbook was made with great help from h4f guys, too thanks to vulcano and back.
0x09-references & links
For further reading about this topic please see following:
- Http://www.cs.virginia.edu /~ Kn5f/pdf/K. nohl. PhD implementable.privacy.for.rfid.systems.pdf
- Http://events.ccc.de/congress/2007/Fahrplan/events/2378.en.html
- Http://packetstorm.rlz.cl/papers/wireless/2008-esorics.pdf
- Http://www.nethemba.com/mifare-classic-slides.pdf
- Http://code.google.com/p/nfc-tools/wiki/mfoc
0x0a-about
Mi1 is a "full time security enthusiast" with university degree in the field of informatics. Recently focusing his passion to USRP and RFID stuff.