Пример #1
0
 def open_clicked(self, widget, event=None, data=None):
     mrz1 = self.main_window_xml.get_widget("mrz_entry1").get_text()
     mrz2 = self.main_window_xml.get_widget("mrz_entry2").get_text()
     mrz = [e.strip().upper().replace(";","<") for e in mrz1, mrz2]
     
     self.clear_display()
     
     self.main_window_xml.get_widget("mrz_entry1").set_text(mrz[0])
     self.main_window_xml.get_widget("mrz_entry2").set_text(mrz[1])
     
     while gtk.events_pending():
         gtk.main_iteration_do(block=False)
     
     if self.card_factory:
         try:
             card_object = self.card_factory.connect()
             card = cards.new_card_object(card_object)
             cards.generic_card.DEBUG = False
             
             print >>sys.stderr, "Using %s" % card.DRIVER_NAME
             
             p = cards.passport_application.Passport.from_card(card, mrz)
             
             self.set_passport(p)
         except KeyboardInterrupt,SystemExit: raise
         except:
             import traceback
Пример #2
0
 def cmd_connect(self, reader = None):
     "Open the connection to a card"
     if reader is None:
         reader = self.reader
     
     reader_object = readers.connect_to(reader)
     self.card = cards.new_card_object(reader_object)
     
     self.unregister_commands(self, self.NOCARD_COMMANDS)
     self.register_commands(self, self.CARD_COMMANDS)
     self.register_commands(self.card)
     
     self.register_pre_hook(self._update_prompt)
     self.register_pre_hook(self._clear_sw)
     
     shell.fallback = self.do_fancy_apdu
     
     shell.register_post_hook(self._print_sw)
Пример #3
0
        elif option in ("-D", "--dump-contents"):
            dump_contents = not dump_contents
    
    if len(arguments) > 0:
        top_level = ("".join( ["".join(e.split()) for e in arguments] )).split("/")
        top_level = [binascii.unhexlify(e) for e in top_level]
    
    print "Reading /%s from %04X to %04X%s" % (
        top_level is not None and "/".join("%r" % e for e in top_level) or "",
        min_fid,
        max_fid,
        with_dirs and " (DFs treated separately)" or "",
    )
    
    card_object = c.connect()
    card = cards.new_card_object(card_object)
    cards.generic_card.DEBUG = False
    
    print "Using %s" % card.DRIVER_NAME

    card.change_dir()
    if top_level is not None:
        for e in top_level: 
            if len(e) == 2:
                card.change_dir(e)
            else:
                card.select_application(e)
    
    root_node = cards.iso_7816_4_card.iso_node(generic_description="Brute Force Results Tree")
    
    #objective = (0x2f00, 0x5015) ## Test cases on an OpenSC formatted PKCS#15 card
Пример #4
0
 
 def _add_card(self, card):
     self.known_cards[ card.reader ].append(card)
     if not self.tickets.has_key( repr(card) ):
         self.tickets[ repr(card) ] = []
     
     conn = card.createConnection()
     connected = False
     try:
         conn.connect()
         connected = True
     except smartcard.Exceptions.NoCardException, e:
         pass
     
     if connected:
         card_ = cards.new_card_object(conn)
         cards.generic_card.DEBUG = False
         self.connected_cards[ repr(card) ] = card_
         
         for i in range(1,9):
             try:
                 ticket = cards.vrs_application.VrsTicket.from_card(card_, record_no = i)
                 print "Loaded ticket '%s' from record %i" % (ticket, i)
                 self._add_ticket(card, ticket)
             except (KeyboardInterrupt, SystemExit):
                 raise
             except Exception,e:
                 if not str(e).startswith("'No ticket in record no."):
                     print e
             
             if not isinstance(card_, cards.vrs_application.VRS_Application):