5

I have a smart card as in the image below. The card is in the card reader which is sticked at the server. It used to get the user authenticated before he can download the data.

I am trying to get the card number or seriel number or RID of the smart card. I am able to get the ATR from it beside other information as 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 only the ATR number

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

This page explains which information has the ATR.

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 the PSE I am getting 6a86 also incorrect P1/P2. When I try to get PPSE I am getting 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 have tried this option as well:

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

The Information I am currently getting:

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 I can 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 Card 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 have sticked this Card in the Card Reader after installing the cardpeek Software --> click analayzer --> click tachograph and I could read the Card data like 'FF544143484F','0520' ids. When I stick the Company Card into the Card Reader --> cardpeek Programm --> analayer --> (here I cound not click the right specification since I tried every single one in the list and I could just read the ATR then I am getting 6700 error)

Mr Asker
  • 2,300
  • 11
  • 31
  • 56
  • Do you know, which specification the card complies to? The optical appearance gives no so much help, except that it seems to be a contactless card, which puts some question marks to the ATR information (since it is likely from the driver instead of the card). SInce the abbreviation PSE is ambiguous (Payment system environment vs. portable security environment) you should describe the purpose in more detail. – guidot Jul 03 '17 at 06:41
  • @guidot: I added some edited part ..please take a look at it. How can I find the specification of the company card? – Mr Asker Jul 07 '17 at 20:52

0 Answers0