">
sudo apt-get install libpcsclite1 pcscd pcsc-tools
sudo service pcscd restart
pip install pyscard
from smartcard.scard import (
SCardTransmit, SCardEstablishContext,
SCardListReaders, SCardConnect, SCARD_SCOPE_USER,
SCARD_SHARE_SHARED, SCARD_PROTOCOL_T1, SCARD_PCI_T1
)
class ACSWalletMate:
def __init__(self, reader_index=0):
_, self.context = SCardEstablishContext(SCARD_SCOPE_USER)
_, readers = SCardListReaders(self.context, [])
if len(readers) == 0:
raise Exception("No readers found")
self.reader = readers[reader_index]
_, self.card, self.protocol = SCardConnect(
self.context, self.reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T1
)
print(f"Connected to {self.reader}")
if __name__ == "__main__":
reader = ACSWalletMate(1)
python walletmate.py
def send_apdu(self, command):
_, response = SCardTransmit(self.card, SCARD_PCI_T1, command)
return ''.join(f'{x:02x}' for x in response)
def enter_emulation_mode(self):
res = self.send_apdu([0xE0, 0x00, 0x00, 0x40, 0x03, 0x02, 0x00, 0x00])
if res != "e100000003020000":
raise Exception("Failed emulation mode")
print("Emulation mode activated. Reader LED off.")
if __name__ == "__main__":
reader = ACSWalletMate()
reader.enter_emulation_mode()
def generate_write_apdu_for_url(self, url):
prefix_code, stripped_url = 0x04, url.replace("https://", "")
uri_payload = [prefix_code] + list(map(ord, stripped_url))
ndef_record = [0xD1, 0x01, len(uri_payload), 0x55] + uri_payload
tlv = [0x03, len(ndef_record)] + ndef_record + [0xFE]
memory = [0xE1, 0x10, 0xF4, 0x00] + tlv
memory += [0x00] * (4 - len(memory) % 4)
total_len = len(memory)
return [0xE0, 0x00, 0x00, 0x60, 4 + total_len, 0x01, 0x02, 0x00, total_len] + memory
def write_ndef_url(self, url):
apdu = self.generate_write_apdu_for_url(url)
self.send_apdu(apdu)
print(f"URL '{url}' written to reader.")
if __name__ == "__main__":
reader = ACSWalletMate(reader_index=1)
reader.enter_emulation_mode()
reader.write_ndef_url("https://example.com")
pip install accessgrid
from accessgrid import AccessGrid
from smartcard.scard import (
SCardTransmit, SCardEstablishContext,
SCardListReaders, SCardConnect, SCARD_SCOPE_USER,
SCARD_SHARE_SHARED, SCARD_PROTOCOL_T1, SCARD_PCI_T1
)
class ACSWalletMate:
def __init__(self, reader_index=0):
_, self.context = SCardEstablishContext(SCARD_SCOPE_USER)
_, readers = SCardListReaders(self.context, [])
if len(readers) == 0:
raise Exception("No readers found")
self.reader = readers[reader_index]
_, self.card, self.protocol = SCardConnect(
self.context, self.reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T1
)
print(f"Connected to {self.reader}")
def send_apdu(self, command):
_, response = SCardTransmit(self.card, SCARD_PCI_T1, command)
return ''.join(f'{x:02x}' for x in response)
def enter_emulation_mode(self):
res = self.send_apdu([0xE0, 0x00, 0x00, 0x40, 0x03, 0x02, 0x00, 0x00])
if res != "e100000003020000":
raise Exception("Failed emulation mode")
print("Emulation mode activated. Reader LED off.")
def generate_write_apdu_for_url(self, url):
prefix_code, stripped_url = 0x04, url.replace("https://", "")
uri_payload = [prefix_code] + list(map(ord, stripped_url))
ndef_record = [0xD1, 0x01, len(uri_payload), 0x55] + uri_payload
tlv = [0x03, len(ndef_record)] + ndef_record + [0xFE]
memory = [0xE1, 0x10, 0xF4, 0x00] + tlv
memory += [0x00] * (4 - len(memory) % 4)
total_len = len(memory)
return [0xE0, 0x00, 0x00, 0x60, 4 + total_len, 0x01, 0x02, 0x00, total_len] + memory
def write_ndef_url(self, url):
apdu = self.generate_write_apdu_for_url(url)
self.send_apdu(apdu)
print(f"URL '{url}' written to reader.")
client = AccessGrid("account_id", "secret_key")
card = client.access_cards.provision(
card_template_id="template_id",
employee_id="12345",
card_number="67890",
site_code="01",
full_name="Alice Smith",
email="[email protected]",
phone_number="+1234567890",
classification="Employee",
title="Engineer",
start_date="2025-01-01T00:00:00Z",
expiration_date="2026-01-01T00:00:00Z"
)
# Now integrate with your Wallet Mate reader:
if __name__ == "__main__":
reader = ACSWalletMate(reader_index=1)
reader.enter_emulation_mode()
reader.write_ndef_url(card.url)
print("Tap your smartphone on the reader to open the URL securely provisioned by AccessGrid.")
Learn how to configure your ACS Wallet Mate 2 reader to emulate an NFC tag that opens a URL autom...
Got a VTAP Reader? Not sure how to configure it for Apple Access Passes? Look no further!