text
[RRG-proxmark3.git] / doc / emv_notes.md
blob2766e67619bb65b66fcf9ac48ec7bdf95d6cad9e
1 # EMV commands
2 <a id="top"></a>
4 ### EMV Implemented parts:
6 - Get ATR|ATS
7 - Get AID by PSE (`emv pse`)
8 - Get AID by application list (`emv search`)
9 - Select application (`emv select`)
10 - Format PDOL (look at next part)
11 - Execute GPO (`emv gpo` this step and format PDOL)
12 - Get records from AFL (`emv readrec`)
13 - Make SDA (check records from GPO)
14 - Make DDA (`emv challenge` `emv intauth`)
15 - Check PIN (`not implemented`)
16 - Fill CDOL1 and CDOL2 (look at next part)
17 - Execute AC1 (with CDA support) (`emv genac`)
18 - Check ARQC (bank part) (`not implemented`)
19 - Make ARPC (bank part) (`not implemented`)
20 - Execute external authenticate (`not implemented`)
21 - Execute AC2 (with CDA support) (`not implemented`)
22 - Check ARQC cryptogram (`not implemented`)
23 - Issuer scripts processing (`not implemented`)
25 ### Working parts of qVSDC:
26 ^[Top](#top)
28 - Get ATR|ATS
29 - Get AID by PSE (`emv pse`)
30 - Get AID by application list (`emv search`)
31 - Select application (`emv select`)
32 - Format PDOL (look at next part)
33 - Execute GPO (`emv gpo` this step and format PDOL)
34 - Get records from AFL (`emv readrec`)
35 - Make fDDA (`emv challenge` `emv intauth`)
36 - External authenticate command (`not implemented`)
37 - Issuer scripts processing (`not implemented`)
39 ### `not implemented` parts of EMV
40 ^[Top](#top)
42 They can be implemented, but it needs to know issuer's card keys (usually 3DES) and now this parts can be tested only on special test cards.
44 ### Commands
45 ^[Top](#top)
47 All this commands are parts of command `emv exec`. 
48 command `emv exec` executes EMV transaction. it have parameters:
49 ```
50     -j, -J, --jload      Load transaction parameters from `emv/defparams.json` file.
51     -f, -F, --forceaid   Force search AID. Search AID instead of execute PPSE.
52     By default:          Transaction type - MSD
53     -v, -V, --qvsdc      Transaction type - qVSDC or M/Chip.
54     -c, -C, --qvsdccda   Transaction type - qVSDC or M/Chip plus CDA (SDAD generation).
55     -x, -X, --vsdc       Transaction type - VSDC. 
56     -g, -G, --acgpo      VISA. generate AC from GPO.
57     -w, -W, --wired      Send data via contact (iso7816) interface. Contactless interface set by default.
58 ```
59 It works for VISA(r) and Mastercard(r) transactions. It may work with other EMV payment system's card (and it works in general cases that is described in EMV).
61 ### VISA(r) transactions:
62 ^[Top](#top)
64 MSD - Magnetic Stripe mode
65 VSDC - contact transaction
66 qVSDC - contactless transaction
68 ### Mastercard(r) transactions
69 ^[Top](#top)
71 MSD - Magnetic Stripe mode
72 M/Chip - contact and contactless transaction
74 Different cards have different modes on/of and different behavior in them. So needs to check card in all this modes.
75 MSD - compatibility mode. Now it work always. But it less secure and in near future it will be slowly) disabled.
77 ### all commands:
78 ^[Top](#top)
80 ```
81 exec             Executes EMV contactless transaction.
82 pse              Execute PPSE. It selects 2PAY.SYS.DDF01 or 1PAY.SYS.DDF01 directory.
83 search           Try to select all applets from applets list and print installed applets.
84 select           Select applet.
85 gpo              Execute GetProcessingOptions.
86 readrec          Read files from card.
87 genac            Generate ApplicationCryptogram.
88 challenge        Generate challenge.
89 intauth          Internal authentication.
90 scan             Scan EMV card and save it contents to json file for emulator.
91 test             Crypto logic test.
92 list             List ISO7816 history
93 roca             Extract public keys and run ROCA test
94 ```
96 All main commands are parts of EMV specification. Commands than not described there:
98 `emv scan` - scans card and saves all records to json file. Can be executed with or without tags disassembly. 
100 `emv roca` - extract public keys from cards (part of `emv scan`)
102 `emv test` - test all crypto code from emv part of proxmark.
104 ### Useful links:
105 ^[Top](#top)
107 EMV specifications
108 http://www.emvco.com/specifications.aspx?id=155
110 Excelent explanation of EMV
111 http://www.openscdp.org/scripts/emv/index.html
113 Fully working terminal written in Ruby.
114 https://code.google.com/p/ruby-pboc2-lib/source/browse/trunk/lib/pboc.rb
116 EMV kernel written in C++
117 https://github.com/ntufar/EMV/tree/master/EMV_Library
119 C EMV library (part of this library uses proxmark)
120 https://github.com/lumag/emv-tools
122 Resources (keys, country codes, etc):
123 https://github.com/binaryfoo/emv-bertlv/tree/master/src/main/resources
125 ### EMV kernels
126 ^[Top](#top)
128 POS terminal checks card and selects one of EMV kernels and launches it for EMV transaction. Different kernels have different rules to make EMV transaction.
130 This list from:
132 EMVco Architecture and General Requirement V2.4 volume A.
133 EMVco Entry Point specification V2.4 volume B
135 - EMVco C-1 Kernel 1 V2.4 for some cards with JCB AIDs and some cards with Visa AIDs
136 - EMVco C-2 Kernel 2 V2.4 for MasterCards AIDs
137 - EMVco C-3 Kernel 3 V2.4 for Visa AIDs
138 - EMVco C-4 Kernel 4 V2.4 for American Express AIDs
139 - EMVco C-5 Kernel 5 V2.4 for JCB AIDs
140 - EMVco C-6 Kernel 6 V2.4 for Discover AIDs
141 - EMVco C-7 Kernel 7 V2.4 for UnionPay AIDs