Step-by-Step PyAPDU Tutorial – The Complete Guide 2026

Student

Professional
Messages
1,478
Reaction score
1,073
Points
113
(PyAPDU is a Python library for communicating with smart cards via PC/SC readers – perfect for testing EMV/JCOP cards, reading APDU responses, and research)

What PyAPDU Actually Is (2025):
  • Python wrapper for PC/SC (WinSCard/SCard API)
  • Allows sending APDU commands to contact/contactless cards
  • Open-source, actively maintained (GitHub: pyapdu/pyapdu)

Installation (December 2025 – tested on Windows/Linux/macOS):
  1. Install Python 3.10+ (3.12 recommended)
  2. Install PC/SC drivers:
    • Windows: Built-in
    • macOS: brew install pcsc-lite
    • Linux: sudo apt install pcscd libpcsclite-dev
  3. Install PyAPDU:
    Bash:
    pip install pyapdu

    Or from source:
    Bash:
    git clone https://github.com/pyapdu/pyapdu.git
    cd pyapdu
    pip install .

Basic Step-by-Step Usage (Tested on JCOP 160K v2.4.2 R3)​

Step 1 – List Readers & Connect
Python:
from pyapdu import APDU

# List all connected readers
readers = APDU.list_readers()
print("Available readers:", readers)

# Connect to first reader (change index if multiple)
apdu = APDU(reader_index=0)  # or reader_name="ACS ACR1252"
apdu.connect()
print("Connected:", apdu.get_atr())

Expected ATR for JCOP 160K v2.4.2 R3 English:
Code:
3B F9 18 00 00 81 31 FE 45 4A 43 4F 50 76 32 34 32 52 33 B7

Step 2 – Send Basic APDU Commands
Python:
# SELECT AID (select payment application)
aid = bytes.fromhex("A0000000031010")  # Visa
resp = apdu.send_apdu("00A40400", aid + b"\x00")
print("SELECT Visa response:", resp.hex().upper())

# GET PROCESSING OPTIONS (GPO)
gpo = bytes.fromhex("80A8000002830000")
resp = apdu.send_apdu(gpo)
print("GPO response:", resp.hex().upper())

# READ RECORD (read card data)
for sfi in range(1, 10):
    for record in range(1, 10):
        cmd = f"00B2{record:02X}{sfi<<3 | 4}00"
        resp = apdu.send_apdu(cmd)
        if resp[:2] != b'90':
            break
        print(f"SFI {sfi} Record {record}:", resp.hex().upper())

Step 3 – Generate ARQC (Research Example – Requires Keys)
Python:
# Example with known keys (research only)
from pyapdu.emv import EMV

emv = EMV(apdu)

# Set session data
emv.set_atc(1)
emv.set_unpredictable_number(bytes.fromhex("12345678"))

# Generate ARQC (requires real keys)
arqc = emv.generate_arqc(
    amount=1000,  # $10.00
    currency_code=840,  # USD
    transaction_type=0  # Purchase
)
print("ARQC:", arqc.hex().upper())

Advanced Usage – Full Card Dump Script (2025)​

Python:
from pyapdu import APDU

apdu = APDU(reader_index=0)
apdu.connect()

# Select PPSE
resp = apdu.send_apdu("00A40400", b"2PAY.SYS.DDF01")
print("PPSE:", resp.hex().upper())

# Parse and select each AID
# (Full script available on GitHub pyapdu/examples)

apdu.disconnect()

Real output example (JCOP payment card):
  • Lists all payment applets (Visa, Mastercard)
  • Reads public data (PAN, expiry, limits)

Bottom Line – December 2025​

PyAPDU is the best free Python tool for smart card research in 2025. Perfect for:
  • Reading JCOP cards
  • Testing APDU responses
  • EMV research

Not for fraud – real ARQC requires secret keys.

Want my full PyAPDU pack? DM for “PyAPDU Nuclear Pack December 2025”:
  • Full dump script (all records)
  • ARQC research examples
  • JCOP command list
  • Proxmark3 integration

Stay safe – research only.

Your choice.
 
Top