def testcase_AnyCardType(self): """Test smartcard.AnyCardType.""" ct = AnyCardType() for reader in readers(): if [] != expectedATRinReader[str(reader)]: connection = reader.createConnection() connection.connect() self.assertEqual(True, ct.matches(connection.getATR())) self.assertEqual(True, ct.matches(connection.getATR(), reader)) connection.disconnect()
def testcase_AnyCardType(self): """Test smartcard.AnyCardType.""" ct = AnyCardType() for reader in readers(): if [] != expectedATRinReader[str(reader)]: connection = reader.createConnection() connection.connect() self.assertEquals(True, ct.matches(connection.getATR())) self.assertEquals(True, ct.matches(connection.getATR(), reader)) connection.disconnect()
def __init__(self, filename="aid_list.txt"): self._cardtype = AnyCardType() self._cardrequest = CardRequest(timeout=10, cardType=self._cardtype) self._cardservice = self._cardrequest.waitforcard() self._cardservice.connection.connect() #print toHexString(self._cardservice.connection.getATR()) self.aids = self._getAids(filename)
def __init__(self): cardtype = AnyCardType() self.resetCmd = [ 0x0, 0xA4, 0x4, 0x0, 0x8, 0xA0, 0x0, 0x0, 0x0, 0x54, 0x48, 0x0, 0x1 ] self.resetCmd1 = [0x0, 0xC0, 0x0, 0x0, 0xA] self.citizenCmd = [0x80, 0xB0, 0x0, 0x4, 0x2, 0x0, 0xD] self.citizenResponse = [0x0, 0xC0, 0x0, 0x0, 0xD] try: # request card insertion cardrequest = CardRequest(timeout=5, cardType=cardtype) self.cardservice = cardrequest.waitforcard() # attach the console tracer # observer = ConsoleCardConnectionObserver() # self.cardservice.connection.addObserver(observer) # connect to the card and perform a few transmits self.cardservice.connection.connect() except CardRequestTimeoutException: print 'time-out: no card inserted during last 5s' except: import sys print sys.exc_info()[1]
def connectionObserver(): # request any card type cardtype = AnyCardType() cardrequest = CardRequest(timeout=1, cardType=cardtype) cardservice = cardrequest.waitforcard() observer = ConsoleCardConnectionObserver() cardservice.connection.addObserver(observer) cardservice.connection.connect() print('ATR: ' + toHexString(cardservice.connection.getATR())) # get reader used for the connection # device = cardservice.connection.getReader() GET_RESPONSE = [0XA0, 0XC0, 00, 00] SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02] DF_TELECOM = [0x7F, 0x10] apdu = SELECT + DF_TELECOM response, sw1, sw2 = cardservice.connection.transmit(apdu) if sw1 == 0x9F: apdu = GET_RESPONSE + [sw2] response, sw1, sw2 = cardservice.connection.transmit(apdu) else: print('no DF_TELECOM')
def __init__(self): self.readerList = readers() self.cardtype = AnyCardType() self.cardrequest = CardRequest(readers=self.readerList, timeout=7000, cardType=self.cardtype) self.cardservice = self.cardrequest.waitforcard()
def writeTag(value): page = 4 cardtype = AnyCardType() cardreq = CardRequest(timeout=100, cardType=cardtype) cardservice = cardreq.waitforcard() cardservice.connection.connect() print(toHexString(cardservice.connection.getATR())) WRITE_COMMAND = [ 0xFF, 0xD6, 0x00, 0x04, 0x04, int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16), int(value[6:8], 16) ] print(WRITE_COMMAND) #[0xFF, 0xD6, 0x00, int(page), 0x04, int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16), int(value[6:8], 16)] #Let's write a page Page 9 is usually 00000000 #resp = cardservice.connection.transmit(AUTHENTICATE_COMMAND) #print(resp) resp = cardservice.connection.transmit(WRITE_COMMAND) print(resp) if resp[1] == 144: print("Wrote " + str(value)) else: print("Error occured during write operation")
def getATR(self): cardtype = AnyCardType() cardrequest = CardRequest(timeout=1, cardType=cardtype) cardservice = cardrequest.waitforcard() cardservice.connection.connect() return toHexString(cardservice.connection.getATR())
def nextg_apdu(self,rand=None,autn=None,debug=False,trigger=None): trigger.disarm() self.cardrequest = CardRequest(timeout=5,cardType=AnyCardType()) self.cardservice = self.cardrequest.waitforcard() if debug: obs = ConsoleCardConnectionObserver() self.cardservice.connection.addObserver(obs) self.cardservice.connection.connect() self.c = self.cardservice.connection # print("ATR... : %s" % self.cardservice.connection.getATR()) r,sw1,sw2 = self.c.transmit([0x00, 0xa4, 0x08, 0x04, 0x02, 0x2f, 0x00]) r,sw1,sw2 = self.c.transmit([0x00, 0xc0, 0x00, 0x00, sw2]) r,sw1,sw2 = self.c.transmit([0x00, 0xb2, 0x01, 0x04, r[7]]) r,sw1,sw2 = self.c.transmit([0x00,0xA4,0x04,0x04] + list(r[3:4 + r[3]])) r,sw1,sw2 = self.c.transmit([0x00,0xC0,0x00,0x00] + [sw2]) r,sw1,sw2 = self.c.transmit([0x00,0xA4,0x00,0x04,0x02,0x6F,0x07]) r,sw1,sw2 = self.c.transmit([0x00, 0xc0, 0x00, 0x00, sw2]) # r,sw1,sw2 = self.c.transmit([0x00, 0xb0, 0x00, 0x00, r[7]]) # r,sw1,sw2 = # r,sw1,sw2 = self.c.transmit([0x00, 0xb2, 0x01, 0x04, r[7]]) if rand is None and autn is None: authcmd = [0x00, 0x88, 0x00, 0x81, 0x22, 0x10] + [0xaa] * 16 + [0x10] + [0xbb] * 16 else: authcmd = [0x00, 0x88, 0x00, 0x81, 0x22, 0x10] + rand + [0x10] + autn trigger.arm() print("Arming") r,sw1,sw2 = self.c.transmit(authcmd)
def __init__(self, client): # request any card type #self.print_error("** client", client, " ** handler", client.handler) self.client = client self.parser = client.parser self.cardtype = AnyCardType() self.needs_2FA = None try: # request card insertion self.cardrequest = CardRequest(timeout=10, cardType=self.cardtype) self.cardservice = self.cardrequest.waitforcard() # attach the console tracer self.observer = LogCardConnectionObserver( ) #ConsoleCardConnectionObserver() self.cardservice.connection.addObserver(self.observer) # attach the card removal observer self.cardmonitor = CardMonitor() self.cardobserver = RemovalObserver(self) self.cardmonitor.addObserver(self.cardobserver) # connect to the card and perform a few transmits self.cardservice.connection.connect() # cache PIN self.pin_nbr = None self.pin = None except CardRequestTimeoutException: self.print_error('time-out: no card inserted during last 10s') except Exception as exc: self.print_error("Error during connection:", repr(exc), traceback.format_exc())
def testcase_CardRequestNewCardInReaderNotPresentInfiniteTimeOut(self): """Test smartcard.CardRequest for any new card in a specific reader not present without time-out.""" print('please remove a smart card reader') _readerz = readers() while True: readerz = readers() if len(_readerz) > len(readerz): break time.sleep(.1) for reader in readerz: _readerz.remove(reader) cardtype = AnyCardType() cardrequest = CardRequest( timeout=None, readers=[_readerz[0]], cardType=cardtype, newcardonly=True) print('Re-insert reader ', _readerz[0], 'with a card inside') cardservice = cardrequest.waitforcard() cardservice.connection.connect() print(toHexString( cardservice.connection.getATR()), \ 'in', cardservice.connection.getReader()) cardservice.connection.disconnect()
def nextg_apdu(self, rand=None, autn=None, debug=False): self.cardrequest = CardRequest(timeout=5, cardType=AnyCardType()) self.cardservice = self.cardrequest.waitforcard() if debug: obs = ConsoleCardConnectionObserver() self.cardservice.connection.addObserver(obs) self.cardservice.connection.connect() self.c = self.cardservice.connection # print("ATR... : %s" % self.cardservice.connection.getATR()) r, sw1, sw2 = self.c.transmit( [0x00, 0xa4, 0x08, 0x04, 0x02, 0x2f, 0x00]) r, sw1, sw2 = self.c.transmit([0x00, 0xc0, 0x00, 0x00, 0x28]) r, sw1, sw2 = self.c.transmit([0x00, 0xb2, 0x01, 0x04, 0x26]) r, sw1, sw2 = self.c.transmit([ 0x00, 0xa4, 0x04, 0x04, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x02, 0xff, 0x33, 0xff, 0xff, 0x89, 0x01, 0x01, 0x01, 0x00 ]) r, sw1, sw2 = self.c.transmit([0x00, 0xc0, 0x00, 0x00, 0x3e]) r, sw1, sw2 = self.c.transmit( [0x00, 0xa4, 0x00, 0x04, 0x02, 0x6f, 0x07]) r, sw1, sw2 = self.c.transmit([0x00, 0xc0, 0x00, 0x00, 0x25]) r, sw1, sw2 = self.c.transmit([0x00, 0xb0, 0x00, 0x00, 0x09]) if rand is None and autn is None: authcmd = [0x00, 0x88, 0x00, 0x81, 0x22, 0x10 ] + [0xaa] * 16 + [0x10] + [0xbb] * 16 else: authcmd = [0x00, 0x88, 0x00, 0x81, 0x22, 0x10] + rand + [0x10 ] + autn r, sw1, sw2 = self.c.transmit(authcmd)
def initialize(card_type=""): if card_type == "": cardtype = AnyCardType() # for accepting any type of card else: cardtype = ATRCardType(card_type) cardrequest = CardRequest(timeout=1, cardType=cardtype) # print("Waiting for card") cardservice = cardrequest.waitforcard() # print("Card found") # connecting to card cardservice.connection.connect() reader = cardservice.connection.getReader() print(f"Success: NFC Connection established on reader {reader}") # set up object nfc_connection = NFCconnection( cardservice=cardservice, metadata={}, ) # get metadata nfc_connection.get_card_atr_info() nfc_connection.get_card_uid() nfc_connection.get_card_size() uid = nfc_connection.metadata["UID"] size = nfc_connection.metadata["Size"] print(f"Success: NFC Connection identified as {uid} with size {size}") return nfc_connection
def main(): # Log config global logging_level, logging_file if logging_file is not None: logging.basicConfig( level=logging_level, filename=logging_file, format= "%(asctime)s [%(levelname)s] %(module)s/%(lineno)d - %(message)s") else: logging.basicConfig( level=logging_level, format= "%(asctime)s [%(levelname)s] %(module)s/%(lineno)d - %(message)s") global devices_list_manager global card_manager # Create card manager (Singleton) devices_list_manager = DevicesListManager.getInstance() devices_list_manager.start() card_manager = CardManager(request_timeout=10, card_type=AnyCardType(), share_mode=share_mode) try: leave_main_menu = False menu_util.printMainMenu() while not leave_main_menu: leave_main_menu = not main_menu() devices_list_manager.stop() except KeyboardInterrupt: pass
def detect_smartcard_reader(self): print_error("[satochip] SatochipPlugin: detect_smartcard_reader" ) #debugSatochip self.cardtype = AnyCardType() try: cardrequest = CardRequest(timeout=5, cardType=self.cardtype) cardservice = cardrequest.waitforcard() print_error( "[satochip] SatochipPlugin: detect_smartcard_reader: found card!" ) #debugSatochip return [ Device(path="/satochip", interface_number=-1, id_="/satochip", product_key=(SATOCHIP_VID, SATOCHIP_PID), usage_page=0) ] #transport_ui_string='ccid')] except CardRequestTimeoutException: print('time-out: no card inserted during last 5s') return [] except Exception as exc: print("Error during connection:", exc) return [] return []
def __init__(self): """ Generic constructor """ cardtype = AnyCardType() cardrequest = CardRequest(timeout=3, cardType=cardtype) self.seq = None self.kSessEnc = None self.kSessMac = None self.index = 0 # Wait for the card print('Waiting for the CIE...') try: self.cardservice = cardrequest.waitforcard() except CardRequestTimeoutException: print('Card not found, exiting') sys.exit(1) # Connect to the card if found self.cardservice.connection.connect() print('Connected!')
def __init__(self, threadindex): '''Connect to a card with an ExclusiveTransmitCardConnection.''' threading.Thread.__init__(self) self.threadindex = threadindex # request any card type cardtype = AnyCardType() cardrequest = CardRequest(timeout=5, cardType=cardtype) cardservice = cardrequest.waitforcard() # attach our decorator cardservice.connection = ExclusiveTransmitCardConnection( cardservice.connection) # uncomment to attach the console tracer #observer=ConsoleCardConnectionObserver() #cardservice.connection.addObserver(observer) # connect to the card cardservice.connection.connect() self.cardservice = cardservice # this event will signal the end of the thread self.evtStop = threading.Event() # this timer will set the event stop event in 30s timer = threading.Timer(30, signalEvent, [self.evtStop]) timer.start() self.countTransmitted = 0
def french_apdu(self, rand=None, autn=None, scope=None, debug=False, trigger=None): if trigger is not None: trigger.disarm() self.cardrequest = CardRequest(timeout=5, cardType=AnyCardType()) self.cardservice = self.cardrequest.waitforcard() if debug: obs = ConsoleCardConnectionObserver() self.cardservice.connection.addObserver(obs) self.cardservice.connection.connect() self.c = self.cardservice.connection r, sw1, sw2 = self.c.transmit( [0x00, 0xa4, 0x08, 0x04, 0x02, 0x2f, 0x00]) r, sw1, sw2 = self.c.transmit([0x00, 0xC0, 0x00, 0x00] + [sw2]) r, sw1, sw2 = self.c.transmit([0x00, 0xB2, 0x01, 0x04] + [r[7]]) r, sw1, sw2 = self.c.transmit([0x00, 0xA4, 0x04, 0x04] + list(r[3:4 + r[3]])) r, sw1, sw2 = self.c.transmit([0x00, 0xC0, 0x00, 0x00] + [sw2]) if rand is None and autn is None: authcmd = [0x00, 0x88, 0x00, 0x81, 0x22, 0x10 ] + [0xaa] * 16 + [0x10] + [0xbb] * 16 else: authcmd = [0x00, 0x88, 0x00, 0x81, 0x22, 0x10] + rand + [0x10 ] + autn if trigger is not None: trigger.arm() scope.arm() r, sw1, sw2 = self.c.transmit(authcmd)
def __init__(self, client): # request any card type self.client = client self.parser = client.parser self.cardtype = AnyCardType() try: # request card insertion self.cardrequest = CardRequest(timeout=10, cardType=self.cardtype) self.cardservice = self.cardrequest.waitforcard() # attach the console tracer self.observer = LogCardConnectionObserver( ) #ConsoleCardConnectionObserver() self.cardservice.connection.addObserver(self.observer) # attach the card removal observer self.cardmonitor = CardMonitor() self.cardobserver = RemovalObserver(self) self.cardmonitor.addObserver(self.cardobserver) # connect to the card and perform a few transmits self.cardservice.connection.connect() # cache PIN self.pin_nbr = None self.pin = None except CardRequestTimeoutException: _logger.exception('time-out: no card inserted during last 10s') except Exception as exc: _logger.exception("Error during connection: {str(exc)}")
def __init__(self, srv, db, user, pwd): # this will wait until card inserted in any reader self.channel = CardRequest( timeout=10, cardType=AnyCardType()).waitforcard().connection # using T=0 for compatibility (i.e., DigiID) and simplicity self.channel.connect() print "[+] Leitor:", self.channel.getReader() # Card Results self.card_results() # Odoo connection common = xmlrpclib.ServerProxy('%s/xmlrpc/2/common' % (srv)) self.api = xmlrpclib.ServerProxy('%s/xmlrpc/2/object' % (srv)) self.uid = common.authenticate(db, user, pwd, {}) self.pwd = pwd self.db = db self.model = 'res.partner' toaster.show_toast( "CART\xc3O DO CIDAD\xc3O", "A ligar ao odoo!", icon_path="custom.ico", duration=0, ) # Insert in Odoo #a = self.get() id = self.set() print "/n>>> Registo inserido no odoo/n" url = 'http://odoo9-cartaocidadao-pedroposeiro.c9users.io/web#id=%s&view_type=form&model=res.partner' % ( id) webbrowser.open_new(url)
def getATR(self): cardtype = AnyCardType() cardrequest = CardRequest(timeout=1, cardType=cardtype) cardservice = cardrequest.waitforcard() cardservice.connection.connect() atr = toHexString(cardservice.connection.getATR()) self.writeToLog("ATR: {0}".format(atr))
def __init__(self, request_timeout=1, cardtype=None): Reader.__init__(self) self.reader_type = ReaderType.PCSC self.request_timeout = request_timeout if cardtype == None: self.cardtype = AnyCardType() self.cardrequest = None self.reader_name = None
def get_photo_byte(): cardtype = AnyCardType() cardrequest = CardRequest(timeout=1, cardType=cardtype) try: cardservice = cardrequest.waitforcard() except: resultdict = { 'status': 'inactive' } return json.dumps(resultdict) cardservice.connection.connect() REQ_PHOTO_P1 = [0x80, 0xB0, 0x01, 0x7B, 0x02, 0x00, 0xFF] REQ_PHOTO_P2 = [0x80, 0xB0, 0x02, 0x7A, 0x02, 0x00, 0xFF] REQ_PHOTO_P3 = [0x80, 0xB0, 0x03, 0x79, 0x02, 0x00, 0xFF] REQ_PHOTO_P4 = [0x80, 0xB0, 0x04, 0x78, 0x02, 0x00, 0xFF] REQ_PHOTO_P5 = [0x80, 0xB0, 0x05, 0x77, 0x02, 0x00, 0xFF] REQ_PHOTO_P6 = [0x80, 0xB0, 0x06, 0x76, 0x02, 0x00, 0xFF] REQ_PHOTO_P7 = [0x80, 0xB0, 0x07, 0x75, 0x02, 0x00, 0xFF] REQ_PHOTO_P8 = [0x80, 0xB0, 0x08, 0x74, 0x02, 0x00, 0xFF] REQ_PHOTO_P9 = [0x80, 0xB0, 0x09, 0x73, 0x02, 0x00, 0xFF] REQ_PHOTO_P10 = [0x80, 0xB0, 0x0A, 0x72, 0x02, 0x00, 0xFF] REQ_PHOTO_P11 = [0x80, 0xB0, 0x0B, 0x71, 0x02, 0x00, 0xFF] REQ_PHOTO_P12 = [0x80, 0xB0, 0x0C, 0x70, 0x02, 0x00, 0xFF] REQ_PHOTO_P13 = [0x80, 0xB0, 0x0D, 0x6F, 0x02, 0x00, 0xFF] REQ_PHOTO_P14 = [0x80, 0xB0, 0x0E, 0x6E, 0x02, 0x00, 0xFF] REQ_PHOTO_P15 = [0x80, 0xB0, 0x0F, 0x6D, 0x02, 0x00, 0xFF] REQ_PHOTO_P16 = [0x80, 0xB0, 0x10, 0x6C, 0x02, 0x00, 0xFF] REQ_PHOTO_P17 = [0x80, 0xB0, 0x11, 0x6B, 0x02, 0x00, 0xFF] REQ_PHOTO_P18 = [0x80, 0xB0, 0x12, 0x6A, 0x02, 0x00, 0xFF] REQ_PHOTO_P19 = [0x80, 0xB0, 0x13, 0x69, 0x02, 0x00, 0xFF] REQ_PHOTO_P20 = [0x80, 0xB0, 0x14, 0x68, 0x02, 0x00, 0xFF] PHOTO = [REQ_PHOTO_P1, REQ_PHOTO_P2, REQ_PHOTO_P3, REQ_PHOTO_P4, REQ_PHOTO_P5, REQ_PHOTO_P6, REQ_PHOTO_P7, REQ_PHOTO_P8, REQ_PHOTO_P9, REQ_PHOTO_P10, REQ_PHOTO_P11, REQ_PHOTO_P12, REQ_PHOTO_P13, REQ_PHOTO_P14, REQ_PHOTO_P15, REQ_PHOTO_P16, REQ_PHOTO_P17, REQ_PHOTO_P18, REQ_PHOTO_P19, REQ_PHOTO_P20] photobytearray = bytearray() apdu = SELECT+THAI_ID_CARD response, sw1, sw2 = cardservice.connection.transmit(apdu) # custom fphoto = open("photos/current.jpeg", "wb") for d in PHOTO: response, sw1, sw2 = cardservice.connection.transmit(d) if sw1 == 0x61: GET_RESPONSE = [0X00, 0XC0, 0x00, 0x00] apdu = GET_RESPONSE + [sw2] response, sw1, sw2 = cardservice.connection.transmit(apdu) photobytearray.extend(bytearray(response)) # custom fphoto.write(bytearray(response)) return photobytearray
def connect_to_smartcard(verbose=True): cardtype = AnyCardType() cardrequest = CardRequest(timeout=.2, cardType=cardtype) cardservice = cardrequest.waitforcard() cardservice.connection.connect() atr = cardservice.connection.getATR() if verbose == True: print("ATR: " + toHexString(atr)) return cardservice
def __init__(self, request_timeout=10, card_type=AnyCardType(), disposition=SCARD_LEAVE_CARD, share_mode=SCARD_SHARE_SHARED): self.request_timeout = request_timeout self.__card_type = card_type self.__disposition = disposition self.__share_mode = share_mode self.__card_service = None self.__card_request = None
def __init__(self, clientkey_enc, clientcert_enc, clientkey_sig, clientcert_sig, tp_key, tp_cert, key_transport=False, mutual_auth=True, cert_verif=True, debug=False, chan=0, vuln=True): self.vuln = vuln if chan > 3 or chan < 0: raise ValueError("Logical channel number must be in [0, 3]") self.cla = self.DEFAULT_CLA + chan self.security_lvl = 0x42 # ANY_AUTHENTICATED + C_DECRYPTION self.clientKey_enc = RsaKeyHolder(clientkey_enc) self.clientCert_enc = CVCertificate(clientcert_enc) self.clientKey_sig = RsaKeyHolder(clientkey_sig) self.clientCert_sig = CVCertificate(clientcert_sig) self.tp_key = RsaKeyHolder(tp_key) self.tp_cert = CVCertificate(tp_cert) self.cardKey_enc = None self.cardCert_enc = None self.cardKey_sig = None self.cardCert_sig = None self.key_transport = key_transport self.mutual_auth = mutual_auth self.cert_verif = cert_verif self.session_keys = [] self.session_ivs = [] self.client_secret = [] self.card_secret = [] # Wait for any card to be put on a reader, and initiate a connection card_type = AnyCardType() card_request = CardRequest(timeout=None, cardType=card_type) self.card = card_request.waitforcard() self.card.connection.connect() error_chain = [] error_chain = [ ErrorCheckingChain(error_chain, ISO7816_4ErrorChecker()) ] self.card.connection.setErrorCheckingChain(error_chain) # Set an observer for debugging if debug: observer = SCP10Observer() self.card.connection.addObserver(observer)
def cashLoadBack(self, authKey=None, keyType="B", block=[0x01]): authKey = self.keyB card = sCard() cardtype = AnyCardType() timeout = 10 card.cardConnect(timeout, cardtype) try: self.cursor.execute( "select miktar, id from yuklemes where kartid ='%s' order by updated_at desc limit 1" % (toHexString(card.UID))) self.cn.commit() miktar, yukleme_id = self.cursor.fetchone() opr = Operation(card.target_num, card.UID, keyType, block, card.cardservice) err, sw1, sw2 = opr.authenticate(authKey) if sw1 == 0x90 and not err: cash = float2hex(miktar) err, sw1 = opr.decrement(block, cash) if sw1 == 0x90 and not err: err, sw1 = opr.transfer(block) if sw1 == 0x90 and not err: data = opr.read(block) err = data[0] if not err: self.cursor.execute( "delete from yuklemes where id ='%s'" % (yukleme_id)) self.cursor.execute( "update cards set bakiye=%.2f where kartid='%s'" % (hex2float(data[1:5]), toHexString(card.UID))) self.cn.commit() self.ui.label_7.setText( _fromUtf8("Son yukleme geri alındı")) success = QtGui.QPixmap("icons/ok.png") self.ui.label_8.setPixmap(success) else: self.ui.label_7.setText( _fromUtf8("Kart Bakiyesi okunamadi..")) self.ui.label_8.setPixmap(self.errImg) else: self.ui.label_7.setText( _fromUtf8("Geri alma islemi basarısız...")) self.ui.label_8.setPixmap(self.errImg) else: self.ui.label_7.setText( _fromUtf8("Azaltma islemi basarısız...")) self.ui.label_8.setPixmap(self.errImg) else: self.ui.label_7.setText(_fromUtf8("Authenticate basarısız...")) self.ui.label_8.setPixmap(self.errImg) except: self.ui.label_7.setText(_fromUtf8("Geri Alınacak Bakiye Yok.")) self.ui.label_8.setPixmap(self.errImg)
def connect(): try: cardtype = AnyCardType() cardrequest = CardRequest(cardType=cardtype) cardservice = cardrequest.waitforcard() cardservice.connection.connect() return cardservice except: print(RED + "[x] please enter your card" + ENDC) sys.exit()
def __init__(self): cardtype = AnyCardType() cardrequest = CardRequest(timeout=10, cardType=cardtype) self.card = cardrequest.waitforcard() self.card.connection.connect() self.ins_db = [] self.ins_db_update(INS_DB) self.log = [] self.auto_get_response = True
def readTag(): cardtype = AnyCardType() cardrequest = CardRequest( timeout=10, cardType=cardtype ) cardservice = cardrequest.waitforcard() cardservice.connection.connect() COMMAND = [0xFF, 0xCA, 0x00, 0x00, 0x00] #cmd necessari per inicialitzar la transmissió de dades tagID, sw1, sw2 = cardservice.connection.transmit(COMMAND) #retorna 3 dades print("\t>>> Your UID is: ") print("\t>>> 0x{}".format(listenToString(toHexString(tagID))))
def testcase_CardRequestAnyCardTypeInSelectedReaderNewCard(self): """Test smartcard.AnyCardType.""" for reader in expectedReaders: atr = expectedATRinReader[reader] ct = AnyCardType() cr = CardRequest(newcardonly=True, timeout=1, readers=[reader], cardType=ct) self.assertRaises(CardRequestTimeoutException, cr.waitforcard)