MacGyver's Return - An EMV Chip Cloning Case
MacGyver's Return - An EMV Chip Cloning Case
MacGyver's Return - An EMV Chip Cloning Case
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 2
Quick websearch revealed first answers…
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 3
Digging deeper into carder boards and other black markets
revealed more answers…
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 4
Prices, available Tools, working BINLists…
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 5
Hunting on Virustotal revealed tools for cloning creditcard
data on EMV chips exist like sand on the sea.
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 6
So what hardware is needed to clone a creditcard?
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 7
Counterfeit creditcards - professional style
Cardprinter
Cloned card
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 8
The analysis target SDA EMV Chip Writer
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 9
Status after deleting, formating and saving track data to
EMV-Chip
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 10
Findings so far….
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 11
Network communication when trying to write to the chip
After selecting „Save Track to JCOP chip“ feature, the tool secretly tries to send the Track2 data to a
server on the internet. If it fails the tool crashes. Reason why the reporter failed to get it working!
Patching the assembly code made it work.
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 12
Reversing the code…
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 13
Understanding the TerminalEMV chip communication
via Application Protocol Data Units (APDU)
Command APDU
HEADER BODY
CLA INS P1 P2 Lc DATA Le
Response APDU
BODY STATUS WORD
DATA SW1 SW2
CLA: Class byte, defines command class, e.g. using secure messaging or not
INS: Instruction byte, to indicate instruction code
P1-P2: Parameter bytes of instruction code
Lc: Number of bytes in data field
Data: Field with data
Le: max. number of bytes expected in data field with next response APDU
SW: status word of the applet. Reader notifys occurences and exceptions via SWs
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 14
Understanding the EMV filesystem
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 15
EMV cryptography – Authentication standards 1/2
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 16
EMV cryptography – Authentication standards 2/2
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 17
SDA EMV Chip Writer features under the hood 1/3
GPSHELL commands to delete the default VISA PSE
mode_211
enable_trace
establish_context
card_connect
select -AID a000000003000000 VISA card manager
open_sc -scp 2 -scpimpl 0x15 -security 1 -keyind 0 -keyver 0 -mac_key
404142434445464748494a4b4c4d4e4f -enc_key
404142434445464748494a4b4c4d4e4f Secure channel key
get_status -element 20
delete -AID 315041592e5359532e4444463031 PSE (1PAY.SYS.DDF01)
card_disconnect
release_context
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 18
SDA EMV Chip Writer features under the hood 2/3
GPSHELL commands to install MacGyver.cap as
counterfeit VISA PSE
mode_211
enable_trace
establish_context
card_connect
select -AID a000000003000000
open_sc -scp 2 -scpimpl 0x15 -security 1 -keyind 0 -keyver 0 -mac_key
404142434445464748494a4b4c4d4e4f -enc_key
404142434445464748494a4b4c4d4e4f
install -file MacGyver.cap -nvDataLimit 1000 -instParam 00 -priv 4
card_disconnect
release_context
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 19
SDA EMV Chip Writer features under the hood 3/3
GPSHELL commands to generate a VISA card
Some annotated fields
within the APDU data being
send to the JAVA smartcard,
generating a VISA SDA card
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 20
Smart Card Shell script to dump the full content of
the cloned VISA card data
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 21
Dumped data of the cloned VISA card
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 22
Java Smartcard structure
Java Smartcard structure
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 23
Reverse engineering MacGyver.cap 1/3
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 24
Reverse engineering MacGyver.cap 2/3
The most important file is Method.cap, containing JAVA smartcard bytecode
To decompile the bytecode to human readable JAVA-code 3 steps are needed:
1. Generating JASMIN (JVM assembler) code from java smartcard bytecode (Small Python script)
2. Generating a class file from assembly code using JASMIN
3. Decompiling the class file with JVM bytecode decompiler CFR
Parsecap.py
generates the
JASMIN code
25
Reverse engineering MacGyver.cap 3/3
The decompiled MacGyver.cap including some annotations
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 26
POS Terminal PIN Check of a cloned card
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 27
Attack Sequence of cloned card
POS Terminal
1. Select application
2. Send fake SDA data Cloned card
3. POS sets TAC code C8000000 to
request an online authentication
4. Card selects SDA mode
5. Request a PIN check
6. MacGyver.cap sends „PIN OK“
in any case
7. ARQC request
8. Send fake ARQC
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 28
Lessons learned…
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 29
BINList-Service to identify vulnerable Banks derived
from cloned cards
MacGyver's return - An EMV Chip cloning case - Frank Boldewin (@r3c0nst)– Area 41 security conference Zurich/CH 30
The End!