Search code examples
smartcardapdu

How to obtain PAN(Primary Account Number) from a debit/credit smart card


I would like to know how to obtain PAN(Primary Account Number) from a debit/credit smart card. I try the Maestro debit card using APDU commands and I get the data in bytes, encoded in TLV. The EMV specification says that PAN is on the tag "A5", but I don't identify it on that tag.

APDU commands:

<<00 A4 04 00 07 A0 00 00 00 04 30 60
>>61 42

<<00 C0 00 00 42
>>6F 40 84 07 A0 00 00 00 04 30 60 A5 35 50 07 4D 41 45 53 54 52 4F 87 01 01 5F 2D 06 65 73 65 6E 70 74 9F 11 01 01 9F 12 07 4D 41 45 53 54 52 4F BF 0C 0F 9F 4D 02 0B 0A 9F 6E 07 08 62 00 00 30 30 00 90 00

decode data:

6F File Control Information (FCI) Template
    84 Dedicated File (DF) Name
        A0000000043060
    A5 File Control Information (FCI) Proprietary Template
        50 Application Label
            M A E S T R O
        87 Application Priority Indicator
            01
        5F2D Language Preference
            e s e n p t
        9F11 Issuer Code Table Index
            01
        9F12 Application Preferred Name
            M A E S T R O
        BF0C File Control Information (FCI) Issuer Discretionary Data
            9F4D Log Entry
                0B0A
            9F6E Unknown tag
                08620000303000
90 Issuer Public Key Certificate

Solution

  • APDU commands:

    <<00 B2 01 0C 00
    >>6C 89
    
    <<00 B2 01 0C 89
    >>70 81 86 9F 42 02 09 37 5F 25 03 17 12 08 5F 24 03 21 12 31 5A 08 XX XX XX XX XX XX XX XX 5F 34 01 00 9F 07 02 FF C0 8C 27 9F 02 06 9F 03 06 9F 1A 02 95 05 5F 2A 02 9A 03 9C 01 9F 37 04 9F 35 01 9F 45 02 9F 4C 08 9F 34 03 9F 21 03 9F 7C 14 8D 0C 91 0A 8A 02 95 05 9F 37 04 9F 4C 08 8E 0C 00 00 00 00 00 00 00 00 42 03 01 03 9F 0D 05 B0 50 BC 88 00 9F 0E 05 00 00 00 00 00 9F 0F 05 B0 70 BC 98 00 5F 28 02 08 62 90 00
    

    where XX XX... is Application Primary Account Number (PAN), encoded in TLV.

    The trick is to know what record to read, where it is, because it is not always in the same place, it depends of the smart card.

    sometimes it is 00 B2 01 0C 00 other00 B2 02 14 00 and other combinations.

    recomiendo leer:Getting information from an EMV chip card with Java and for more details: EMV Integrated Circuit Card Specifications for Payment Systems Book 3