Skip to content

Instantly share code, notes, and snippets.

@arjan
Created October 12, 2015 15:10
Show Gist options
  • Save arjan/25ab3f6175920c5b719b to your computer and use it in GitHub Desktop.
Save arjan/25ab3f6175920c5b719b to your computer and use it in GitHub Desktop.
import time
from smartcard.CardType import AnyCardType
from smartcard.CardRequest import CardRequest
from smartcard.util import toHexString
from smartcard.System import readers
print readers()
import webbrowser
cardtype = AnyCardType()
while True:
req = CardRequest( timeout=1, cardType=cardtype )
svc = None
print "Waiting for card..."
while svc is None:
try:
svc = req.waitforcard()
except Exception, e:
pass
svc.connection.connect()
atr = toHexString( svc.connection.getATR() ).replace(" ", "")
uid = [0xFF, 0xCA, 0x00, 0x00, 0x00]
data, sw1, sw2 = svc.connection.transmit(uid)
tag = toHexString(data).replace(" ", "")
print "Got card:", tag
webbrowser.open("http://magik/?rfid=" + tag)
time.sleep(15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment