How to get PSE cards for reading RID or AIP or card number

I have a smart card, as in the image below. The card is in a card reader that is attached to the server. It was used to authenticate the user before he could download the data.

I am trying to get a card number or serial number or RID of a smart card. I can get ATR from it, among other information, as shown below.

ATR:

3b 9f 96 c0 0a 31 fe 45 43 54 31 69 0b 01 00 01 00 00 00 00 00 00 00 0d 

In this question

SmartCardIO EMV Reader, find my card type with ATR number only

someone mentioned that AID (Application ID) = RID(Registered Application ID) || PIX (Property Application Extension) AID (Application ID) = RID(Registered Application ID) || PIX (Property Application Extension)

This page explains what information the ATR has.

https://flomio.com/forums/topic/list-of-apdu-codes/

  Answer-To-Reset (ATR) Init| T0| TD1| TD2| T1| Tk| Len | RID | Std | Card | RFU | TCK Hdr | | | | | | | | | Name | | 3B | 8F| 80 | 01 | 80| 4F| 0C | A0 00 00 03 06| 03 | 00 03| 00 00 00 00| 68 

When I try to get PSE, I get 6a86 also the wrong P1 / P2. When I try to get PPSE, I get 6700 wrong length.

 command : 00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 response without data : 6a 86 command : 00 A4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00 response without data : 67 00 

http://techqa.info/programming/question/36297722/SmartCardIO-EMV-Reader--find-my-card-type-with-only-the-ATR-number

I also tried this option:

 // byte[] pseFileName = "1PAY.SYS.DDF01".getBytes(); //PSE byte[] pseFileName = "2PAY.SYS.DDF01".getBytes(); // PPSE CommandAPDU command = new CommandAPDU(0x00, 0xA4, 0x04, 0x00, pseFileName); 

Information I am currently receiving:

 Terminals list: [PC/SC terminal Generic Smart Card Reader Interface 0] ATR: 3b 9f 96 c0 0a 31 fe 45 43 54 31 69 0b 01 00 01 00 00 00 00 00 00 00 0d command : 00 a4 02 0c 02 00 02 response without data : 90 00 command : 00 b0 00 00 09 response with data: : 00 00 01 98 fa 03 16 14 ad command : 00 a4 04 0c 06 ff 54 41 43 48 4f response without data : 90 00 command : 00 a4 02 0c 02 05 01 response without data : 90 00 command : 00 b0 00 00 01 response with data: : 04 command : 00 22 c1 b6 0a 83 08 00 00 00 05 09 02 ff a1 response without data : 90 00 command : 00 88 00 00 10 e9 96 79 ec 74 27 e6 50 00 00 00 05 09 02 ff a1 80 response with data: : 32 a9 bf e6 91 18 8d c8 34 87 d8 c5 6d 78 f3 90 24 db 98 60 37 f0 05 f3 1f 22 24 65 27 90 43 ff 4f ec 4f ae 7c 2e d9 4c 6d a0 bc 14 9a af df fb 81 0b 5a 4f 4d 1d ee df 38 3b 0d dd 63 7d 22 69 77 27 5b f3 0d ce 51 a3 5c fc 7f 4a fc 8c f1 da d9 ce c7 9b a1 23 e0 e6 1d b0 73 e8 3b 4b 8a 60 38 e8 0d ad 30 80 12 ef d3 76 72 75 95 2f af 09 10 e0 37 78 25 84 2e 19 0e 2e 17 9e 9d de 34 b7 

How can I get the card number (5b) on the Card and RID and AID? Why can I get the PSE of my card?

enter image description here

code

 import java.util.ArrayList; import java.util.List; import javax.smartcardio.ATR; import javax.smartcardio.Card; import javax.smartcardio.CardChannel; import javax.smartcardio.CardException; import javax.smartcardio.CardTerminal; import javax.smartcardio.CommandAPDU; import javax.smartcardio.ResponseAPDU; import javax.smartcardio.TerminalFactory; import javax.xml.bind.DatatypeConverter; public class CardIdTest { public static void main(String[] args) { try { TerminalFactory factory = TerminalFactory.getDefault(); List<CardTerminal> terminals; terminals = factory.terminals().list(); CardTerminal terminal = terminals.get(0); Card card = terminal.connect("T=1"); System.out.println("Terminals list: " + terminals); ATR atr = card.getATR(); byte[] atrArray = atr.getBytes(); String atrHex = CardIdTest.printData(atrArray); System.out.println("ATR: " + atrHex); CardChannel channel = card.getBasicChannel(); String command1 = "00 a4 02 0c 02 00 02"; // select file String command2 = "00 b0 00 00 09"; // length 19 works at the end instead of 09. // read binary String command3 = "00 a4 04 0c 06 ff 54 41 43 48 4f"; String command4 = "00 a4 02 0c 02 05 01"; // String command5 = "00 b0 00 00 01"; String command6 = "00 22 c1 b6 0a 83 08 00 00 00 05 09 02 ff a1"; String command7 = "00 88 00 00 10 e9 96 79 ec 74 27 e6 50 00 00 00 05 09 02 ff a1 80"; String pseString = "00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31"; String ppseString = "00 A4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00"; List<String> list = new ArrayList<String>(); // list.add(command1); // list.add(command2); // list.add(command3); // list.add(command4); // list.add(command5); // list.add(command6); // list.add(command7); list.add(pseString); list.add(ppseString); for (String item : list) { String commandWithoutSpace = item.replace(" ", ""); byte[] apdu = DatatypeConverter.parseHexBinary(commandWithoutSpace); CommandAPDU command = new CommandAPDU(apdu); ResponseAPDU responseAPDU = channel.transmit(command); byte[] reponseData = responseAPDU.getData(); String response = responseAPDU.toString(); if (reponseData.length > 0) { String dataHex = CardIdTest.printData(reponseData); System.out.println("command : " + item); System.out.println("response with data: :" + dataHex); } else { byte[] bytes = responseAPDU.getBytes(); String responseHex = CardIdTest.printData(bytes); System.out.println("command : " + item); System.out.println("response without data :" + responseHex); } } card.disconnect(true); // reset } catch (CardException e) { e.printStackTrace(); } } public static String printData(byte[] byteArray) { StringBuilder sb = new StringBuilder(); for (byte b : byteArray) { sb.append(String.format(" %02x", b)); } return sb.toString(); } } 

Edit

I have another Driver card , and I can read the card number with the following APDU

  String masterFile = "00 A4 04 0C 06 FF544143484F"; String elementaryFile = "00 A4 02 0C 02 0520"; String readBinary = "00 B0 00 01 10"; // B0 read binary; 01 offset 1; 10 decimal equal 16 bytes to read. 

I inserted this Card into the Card Reader after installing the cardpeek Software → click analayzer → click tachograph software, and I could read the Card data, such as “FF544143484F”, “0520”. When I attach the company card to the card reader → cardpeek Programm → analayer → (here I cannot click the right specification, since I tried everything in the list and I could just read ATR, then I get error 6700)

+5
source share

Source: https://habr.com/ru/post/1269394/


All Articles