Confidence A 2018 Practical Guide To Hacking RFID NFC PDF
Confidence A 2018 Practical Guide To Hacking RFID NFC PDF
Confidence A 2018 Practical Guide To Hacking RFID NFC PDF
slawomir.jasek@securing.pl
slawekja
https://giphy.com/gifs/ZikyVyLF7aEaQ
RFID/NFC usage
https://www.youtube.com/watch?v=M0Z-kYL5CEU
PN532 + libnfc
The cheapest
ones may have
antenna issues
Our „NFC research toolkit”
smartlockpicking.com/nfc-tookit
Place original card on the reader
root@kali:~# nfc-list
nfc-list uses libnfc 1.7.1
NFC device: pn532_uart:/dev/ttyUSB0 opened
1 ISO14443A passive target(s) found:
ISO/IEC 14443A (106 kbps) target: Card UID
ATQA (SENS_RES): 00 04
UID (NFCID1): 3c 3d f1 0d
SAK (SEL_RES): 08
Place „Magic” card on the reader, set new UID
https://giphy.com/gifs/iI6eeGjwScTCM
Detecting magic cards?
such cards.
Chinese answer to this problem?
Battery-powered
99.96 EUR
http://kasper-oswald.de/gb/chameleonmini/
Chameleon: Chinese options
EM4095, starting at $2
Proxmark
https://www.kickstarter.com/projects/1408815241/proxmark3-rdv-40
Brute UID? In some cases it makes sense
125 kHz („low frequency”) 13.56MHz („high frequency”)
RFID NFC
Mostly sequential,
Mostly may be bruted Mostly
random random
Android applications:
NFC Tools:
https://play.google.com/store/apps/details?id=com.wakdev.wdnfc
NCI
We can manipulate NFC Controller
Interface, but it requires root.
NFC chipset
Android: NXP NFC chip (e.g. Nexus 5X)
33 04 XX XX XX XX
NCI parameter Your UID
DEMO
https://youtu.be/94u9YSJQpFA
The same with GUI: NFC card emulator
https://play.google.com/store/apps/details?id=com.yuanwofei.cardemulator
https://youtu.be/f3LmvhHwFNc
CLONE FROM A
PICTURE?
Anyone has such numbers on a tag?
EM tags with printed numbers
Decoding numbers
4 bytes of UID
0281219940 dec = 10 C3 13 64 hex
12784484 dec = C3 13 64 hex
3 bytes of UID
sometimes inversed
EM41XX example tag ID: 3C009141F5
Example number Format Conversion
09519605 DEZ8 Last 6 hex converted to dec (9141F5 hex = 09519605 dec)
0009519605 DEZ10 Last 8 hex converted to dec
00145.16885 DEZ5.5 Digits 4-7 hex converted to dec "." last 4 hex converted to dec
060.16885 DEZ3.5A First 2 hex digits "." last 4 converted to dec
000.16885 DEZ3.5B Digits 3,4 "." last 4 converted to dec
145.16885 DEZ3.5C Digits 5,6 hex converted to dec "." last 4 hex converted to dec
00257707557365 IK2 DEZ14 entire hex converted to dec
Possibility to clone UID from picture?
https://twitter.com/hashtag/protectyouraccesscard
#protectyouraccesscard
https://twitter.com/0xtosh/status/908578046583635968
BTW, humans...
https://twitter.com/cybergibbons/status/999283915218128896
ICLASS
Protected identity data stored on card
125 kHz („low frequency”) 13.56MHz („high frequency”)
RFID NFC
Insecure UID
anyone can read it Protected
UID
iCLASS® was specifically designed to make access control more powerful, more
versatile, and more secure. All radio frequency data transmission between the tag
and reader is encrypted using a secure algorithm. By using industry standard
encryption techniques, iCLASS reduces the risk of compromised data or duplicated
tags. For even higher security, the tag data may also be protected with DES or
triple-DES encryption.
https://www.hidglobal.com/doclib/files/resource_files/iclass_tag_ds_en.pdf
The access key is stored in reader
https://twitter.com/infosecfriends/status/799003935876870144
Introducing iClass SE, Seos, mobile access
http://www.emacs.es/downloads/WP/20140723_iCLASS_Seos_Card_Whitepaper_EXTERNAL_v1.0.pdf
By the way...
protection?
WIEGAND
3 wires – black, green, white
GND
DATA0
DATA1
Transmitting 1’s and 0’s
DATA0 (GREEN)
5V
0V
DATA1 (WHITE)
5V
0V
„0” „1”
Card data transmitted: most common 26-bit
http://www.monkeyboard.org/tutorials/82-protocol/24-wiegand-converter
Typical architecture
Sometimes
secured, or hard
a to clone a card
Most commonly
WIEGAND
cleartext bits
http://www.blekeyrfid.com
ESP32 - wifi
RFID-Tool, $20
www.rfid-tool.com
https://github.com/rfidtool/ESP-RFID-Tool
https://www.youtube.com/watch?v=0o8r_ufRrFo
Best practices?
https://play.google.com/store/apps/details?id=com.samsung.sprc.fileselector
Android mobile application
Ultralight: no security
Ultralight EV1
– Simple password (option)
– ECC authenticity check - possible to clone using special
tags
Ultralight C: 3DES
Mifare Classic
A0A1A2A3A4A5
D3F7D3F7D3F7
000000000000
...
Using Android mobile app?
https://play.google.com/store/apps/details?id=de.syss.MifareClassicTool
The dumped
content
Mifare Classic cracking process
Try default, leaked
h keys
Few seconds
Have all
keys?
YES
HOORAY!
Mifare Classic cracking process
Try default, leaked
h keys
Few seconds
?
NO
Have all
keys?
YES
HOORAY!
Mifare Classic cracking process
Try default, leaked
h keys
Few seconds
NO Have at
Have all
least one
keys?
key?
YES YES
nested
HOORAY!
What if we could not brute the key?
Sector 0
„Nested” attack - exploits weakness in Key: FFFFFFFF
...
How to exploit it?
5 seconds
(about 2s/key)
Mifare Classic cracking process
Try default, leaked
h keys
Few seconds
NO Have at
Have all
least one
keys?
key?
YES YES
nested
HOORAY!
few sec few min
Mifare Classic cracking process
Try default, leaked
h keys
Few seconds
?
NO Have at NO
Have all
least one
keys?
key?
YES YES
nested
HOORAY!
few sec few min
But what if all the keys are unknown?
Sector 0
„Darkside” attack, Nicolas T. Courtois – Key: unknown
side channel. Tech details (2009): Sector 1
Key: unknown
https://eprint.iacr.org/2009/137.pdf
Sector 2
Libnfc: MFCUK by Andrei Costin Key: unknown
https://github.com/nfc-tools/mfcuk Sector 3
Key: unknown
NO Have at NO
Have all
least one darkside
keys?
key?
cracked 1 key
YES YES
nested
HOORAY!
few sec few min
Mifare EV1 – „hardened”
NO Have at
Have all
least one
keys?
key?
YES YES
hardnested
HOORAY!
Several min
Mifare Classic hardened (Plus SL1, EV1) cracking
Try default, leaked
h keys
Few seconds
?
NO Have at NO
Have all
least one
keys?
key?
YES YES
hardnested
HOORAY!
Several min
EV1 with all sectors secured?
1. Set MF_DETECTION
2. Place the Chameleon at reader
3. Download dump
4. „Reckon” (mfkey) – cracks the
key
Cracked key
Mifare Classic hardened (Plus SL1, EV1) cracking
Try default, leaked Trip to the reader
h keys
Few seconds
NO Have at NO
Have all
least one Reader attack
keys?
key?
YES YES
hardnested
HOORAY!
Several min
Final NXP recommendation to upgrade (2015.10)
Configure properly!
• Preferably individual key for each
user.
• There are systems that use DESFire
but check only for UID ;)
https://twitter.com/FailsWork/status/984855234953564160
CARD CONTENT
047D4CBD
Card content 0AAE5980
7D480800
3C040D0D
Data stored on card is often encoded 060A0021
00000000
– e.g. scrambled using individual card 0000F969
UID. B871144B
1B2460BD
F9F9F9F0
4290FC39
06F9F97B
F9F9F9F9
F9F9F9F9
F9F9F922
E7AA8783
Hotel: 2 cards for the same room
Checksum?
http://blog.j-michel.org/post/77378532178/rfid-when-the-manufacturer-matters
The encoded data
Card 1
7E EE 5F 71 06 FC 90 F6 A9 F9 7D 7E C6 7D E2 60 7E
BE 81 7E FF 7E 42 7E 7E 7E 7E 7E 7E 7E 7E 7E 7E
Card 2
82 12 A3 8D FA C0 2B 8B 55 05 81 82 3A 81 1E 9C 82
42 7D 82 03 82 BE 82 82 82 82 82 82 82 82 82 82
The encoded data
Card 1 Repeating 7E
7E EE 5F 71 06 FC 90 F6 A9 F9 7D 7E C6 7D E2 60 7E
BE 81 7E FF 7E 42 7E 7E 7E 7E 7E 7E 7E 7E 7E 7E
Card 2 Repeating 82
82 12 A3 8D FA C0 2B 8B 55 05 81 82 3A 81 1E 9C 82
42 7D 82 03 82 BE 82 82 82 82 82 82 82 82 82 82
Maybe there were 00’s in cleartext?
7E EE 5F 71 06 FC 90 F6 A9 F9 7D 7E C6 7D E2 60 7E
BE 81 7E FF 7E 42 7E 7E 7E 7E 7E 7E 7E 7E 7E 7E
XOR
7E 7E 7E 7E 7E 7E 7E 7E 7E 7E 7E (...)
=
00 90 21 0F 78 82 EE 88 D7 87 03 00 B8 03 9C 1E 00
C0 FF 00 81 00 3C 00 00 00 00 00 00 00 00 00 00
Same room: card 1 XOR 7E; card 2 XOR 82
00 90 21 0F 78 82 EE 88 D7 87 03 00 B8 03 9C 1E 00 C0
FF 00 81 00 3C 00 00 00 00 00 00 00 00 00 00
00 90 21 0F 78 42 A9 09 D7 87 03 00 B8 03 9C 1E 00 C0
FF 00 81 00 3C 00 00 00 00 00 00 00 00 00 00
Same room: card 1 XOR 7E; card 2 XOR 82
00 90 21 0F 78 82 EE 88 D7 87 03 00 B8 03 9C 1E 00 C0
FF 00 81 00 3C 00 00 00 00 00 00 00 00 00 00
Now just a few bytes
differ
00 90 21 0F 78 42 A9 09 D7 87 03 00 B8 03 9C 1E 00 C0
FF 00 81 00 3C 00 00 00 00 00 00 00 00 00 00
First public initial reverse of Vingcard
http://blog.j-michel.org/post/85755629755/rfid-followup-on-
vingcard
Vingcard hack – 2018.04
https://www.f-secure.com/en/web/business_global/electronic-
lock-systems-are-vulnerable
Collect various hotel cards...
https://twitter.com/mikko/status/968067739414925312 https://twitter.com/mikko/status/989154230723334151
Get the hotel software
Ghost in the locks, Tomi Tuominen, Timo Hirvonen, INFILTRATE 2018, https://vimeo.com/267613809
And its license...
Serial number spotted
in software manual ;)
Ghost in the locks, Tomi Tuominen, Timo Hirvonen, INFILTRATE 2018, https://vimeo.com/267613809
The „master” card
Create it using the software? Does not work for real hotel
– individual keys.
Get real „master” card, and fuzz?
Turns out: having any guest card for a given hotel, it takes
just a short brute-force to create master key.
Attack
https://www.f-secure.com/documents/10192/2302132/ghost-in-the-lock.mp4
Other hotel system: guest card data
https://en.wikipedia.org/wiki/Assassination_of_Mahmoud_Al-Mabhouh
thanks Tomi Tuominen &Timo Hirvonen for digging it
https://www.wired.com/2017/08/the-hotel-hacker/
City cards?
https://play.google.com/store/apps/details?id=a
u.id.micolous.farebot
Metrodroid – reversing process
https://www.youtube.com/watch?v=qVvNdfKRw7M
City cards fraud?
https://zaufanatrzeciastrona.pl/post/aplikacja-do-nielegalnego- https://securelist.com/android-nfc-hack-allow-users-to-
ladowania-warszawskiej-karty-miejskiej-za-btc/ have-free-rides-in-public-transportation/67283/
http://www.ilfordrecorder.co.uk/news/crime-
court/sophisticated-370-000-oyster-card-fraud-sees-
seven-kings-man-jailed-for-six-years-and-nine-
months-1-5249071
MOBILE ACCESS
Evolution goes mobile
Host Card Emulation
OS
Software emulates contactless smart card.
Mobile app
Mobile OS provides interface for
communication, the same technology
used for contactless payments.
https://www.theinformation.com/articles/apple-to-expand-secure-wireless-chip-beyond-payments
How does it work? (most cases)
Mobile
app WIEGAND?
How does it work? (most cases)
New
backend
Hello Slawomir,
I will be completely honest with you. Today I stumbled
upon your website, and I briefly read through some of
the articles.
Time...
https://giphy.com/gifs/sherlock-bbc-one-l0MYGtCMbPTYWOzaU
Risk?
Conditions to exploit
impact
smartlockpicking.com/nfc-tookit
Trainings
Next up: HackInParis,
Tutorials 25-29.06.2018
Events
...
https://www.smartlockpicking.com
MORE THAN
SECURITY
TESTING
Slawomir.Jasek@securing.pl slawekja