args = parser.parse_args() if args.pcsc is not None: from pySim.transport.pcsc import PcscSimLink sl = PcscSimLink(args.pcsc) elif args.serialport is not None: from pySim.transport.serial import SerialSimLink sl = SerialSimLink(device=args.serialport, baudrate=9600) else: raise RuntimeError("Need to specify either --serialport or --pcsc") sc = SimCardCommands(sl) ac = AppLoaderCommands(sl) if not args.smpp: sl.wait_for_card(newcardonly=args.new_card_required) time.sleep(args.sleep_after_insertion) if not args.smpp: # Get the ICCID # print "ICCID: " + swap_nibbles(sc.read_binary(['3f00', '2fe2'])[0]) ac.select_usim() ac.send_terminal_profile() if len(args.aram_apdu) > 0: # Select the ARA-M applet from its AID aram_rv = rv = ac._tp.send_apdu('00A4040009A00000015141434C00') if '9000' != aram_rv[1]: raise RuntimeError("SW match failed! Expected %s and got %s." % ('9000', aram_rv[1])) # Add/Delete Access rules list in ARA-M
elif opts.osmocon_sock is not None: print("Using Calypso-based (OsmocomBB, sock=%s) reader interface" % opts.osmocon_sock) from pySim.transport.calypso import CalypsoSimLink sl = CalypsoSimLink(sock_path=opts.osmocon_sock) else: # Serial reader is default print("Using serial reader (port=%s, baudrate=%d) interface" % (opts.device, opts.baudrate)) from pySim.transport.serial import SerialSimLink sl = SerialSimLink(device=opts.device, baudrate=opts.baudrate) # Create command layer scc = SimCardCommands(transport=sl) # Wait for SIM card sl.wait_for_card() # Program the card print("Reading ...") # Initialize Card object by auto detecting the card card = card_detect("auto", scc) or Card(scc) # EF.ICCID (res, sw) = card.read_iccid() if sw == '9000': print("ICCID: %s" % (res, )) else: print("ICCID: Can't read, response code = %s" % (sw, )) # EF.IMSI
scc = SimCardCommands(transport=sl) # Batch mode init init_batch(opts) # Iterate done = False first = True card = None while not done: if opts.dry_run is False: # Connect transport print "Insert card now (or CTRL-C to cancel)" sl.wait_for_card(newcardonly=not first) # Not the first anymore ! first = False if opts.dry_run is False: # Get card card = card_detect(opts, scc) if card is None: if opts.batch_mode: first = False continue else: sys.exit(-1) # Probe only
parser.add_argument('-p', '--pcsc', nargs='?', const=0, type=int) args = parser.parse_args() if args.pcsc is not None: from pySim.transport.pcsc import PcscSimLink sl = PcscSimLink(args.pcsc) elif args.serialport is not None: from pySim.transport.serial import SerialSimLink sl = SerialSimLink(device=args.serialport, baudrate=9600) else: raise RuntimeError("Need to specify either --serialport or --pcsc") sc = SimCardCommands(sl) ac = MessageCommands(sl) sl.wait_for_card(0) print "ICCID: " + swap_nibbles(sc.read_binary(['3f00', '2fe2'])[0]) ac.send_terminal_profile() # Send OTA SMS-PP Download messages (with incrementing CNTR) for x in range(0,1): # Send following binary data # a0a40000023f00 = Select master file 3f00 (data, status) = ac.send_ota_sms('a0a40000023f00') print "Status Code: " + status # If it succeeds a response of length 0x18 is waiting, so read it data = ac.send_read_data(0x18) print "OTA Response: " + data[0]
'A000000476416E64726F69644354534C', 'A000000476416E64726F69644354534D', 'A000000476416E64726F69644354534E', 'A000000476416E64726F69644354534F', ] for aid in selectable_aids: self.testTransmitApdu(aid) self.testLongSelectResponse(aid) self.testSegmentedResponseTransmit(aid) self.testStatusWordTransmit(aid) self.testP2Value(aid) parser = argparse.ArgumentParser(description='Android Secure Element CTS') parser.add_argument('-p', '--pcsc', nargs='?', const=0, type=int) args = parser.parse_args() transport = None if args.pcsc is not None: transport = PcscSimLink(args.pcsc) else: transport = PcscSimLink() commandif = CommandInterface(transport) transport.wait_for_card() commandif.send_terminal_profile() omapi = OmapiTest(commandif) omapi.execute_all()
parser.add_argument('--sqlite-db', nargs=1) args = parser.parse_args() if args.pcsc is not None: from pySim.transport.pcsc import PcscSimLink sl = PcscSimLink(args.pcsc) elif args.serialport is not None: from pySim.transport.serial import SerialSimLink sl = SerialSimLink(device=args.serialport, baudrate=9600) else: raise RuntimeError("Need to specify either --serialport or --pcsc") sc = SimCardCommands(sl) sl.wait_for_card(newcardonly=args.new_card_required) time.sleep(args.sleep_after_insertion) # Get the ICCID print("ICCID: %s" % swap_nibbles(sc.read_binary(['3f00', '2fe2'])[0])) if args.pin: sc.verify_chv(1, args.pin) if args.print_info: print("--print-info not implemented yet.") if args.disable_pin: sl.send_apdu_checksw('0026000108' + args.disable_pin.encode("hex") + 'ff' * (8 - len(args.disable_pin))) if args.dump_phonebook: