Beispiel #1
0
 def setUpClass(cls):
     cls.simCard = sim_card.SimCard(mode=MODE_SIM, type=SIM_TYPE)
     cls.simCard.removeAllReaders()
     try:
         cls.simCard.connect(0)
     except Exception as e:
         if "no card in reader" in str(e):
             cls.simCard.stop()
             raise Exception("No card in reader")
     cls.simRouter = sim_router.SimRouter(cards=[cls.simCard],
                                          type=SIM_TYPE,
                                          mode=sim_router.SIMTRACE_OFFLINE)
     cls.simRouter.run(mode=sim_router.ROUTER_MODE_DISABLED)
     cls.shell = cls.simRouter.shell
Beispiel #2
0
 def setUpClass(cls):
     cls.sim1 = sim_card.SimCard()
     cls.sim1.removeAllReaders()
     cls.sim1.connect(0)
     cls.sim2 = sim_card.SimCard(mode=sim_reader.MODE_SIM_SOFT,
                                 type=SIM_TYPE)
     try:
         cls.sim2.connect(0)
     except Exception as e:
         if "no card in reader" in str(e):
             cls.sim2.stop()
             raise Exception("No card in reader")
     cls.simRouter = sim_router.SimRouter(cards=[cls.sim1, cls.sim2],
                                          type=types.TYPE_USIM,
                                          mode=sim_router.SIMTRACE_OFFLINE)
     cls.simRouter.run(mode=sim_router.ROUTER_MODE_DISABLED)
     #update soft SIM for SAT handling
     cls.simRouter.getMainCard(1).routingAttr.insReplaced = sim_card.SAT_INS
     cls.sendApdu = cls.simRouter.simCtrl.sendApdu
     cls.shell = cls.simRouter.shell
simType=types.TYPE_USIM

sim1 = sim_card.SimCard()
sim1.connect(sim_reader.READER_ID_0)
atr1 = sim1.getATR()

sim2 = sim_card.SimCard()
sim2.connect(sim_reader.READER_ID_1)
atr2 = sim2.getATR()

sim3 = sim_card.SimCard(mode=sim_reader.MODE_SIM_SOFT)
sim3.connect(sim_reader.READER_ID_0)
atr3 = sim3.getATR()

simRouter = sim_router.SimRouter(cards=[sim1, sim2, sim3],
                       atr=atr1, type=simType)

#sim2.routingAttr.filesReplaced = sim_card.FILES_REG
#sim2.routingAttr.insReplaced = ['INTERNAL_AUTHENTICATE']

# Forward SAT to sim3.
sim3.routingAttr.insReplaced = sim_card.SAT_INS

'''
When SIM is invalidated, uncomment below.
# Files which need to be the same on all sim cards.
simRouter.getMainCard(0).routingAttr.filesReplaced += ['EF_ADN', 'EF_SDN', 'EF_SMS']
# Uncomment when card resets after quering status. UE migth expect.
# Different AID after SIM card switching if UE doesn't read EF_DIR on the basic channel.
sim1.routingAttr.filesReplaced += ['EF_DIR']
sim1.routingAttr.filesReplaced = ['STATUS']
Beispiel #4
0
from sim import sim_card
from sim import sim_reader
from util import hextools
from util import types

logging.basicConfig(level=logging.INFO, format='%(message)s')

readers = sim_card.SimCard().listReaders()
if "Dell" in readers[0]:
    readerFirst = sim_reader.READER_ID_0
else:
    readerFirst = sim_reader.READER_ID_1

simType = types.TYPE_USIM

sim1 = sim_card.SimCard()
sim1.removeAllReaders()
sim1.connect(readerFirst)
atr1 = sim1.getATR()

sim2 = sim_card.SimCard()
sim2.connect(not readerFirst)
atr2 = sim2.getATR()

simRouter = sim_router.SimRouter(cards=[sim1, sim2], atr=atr2, type=simType)

sim2.routingAttr.filesReplaced = sim_card.FILES_REG
sim2.routingAttr.insReplaced = ['INTERNAL_AUTHENTICATE']
# Uncomment to forward SAT to sim2.
#sim2.routingAttr.insReplaced.append(sim_card.SAT_INS)
simRouter.run(mode=sim_router.ROUTER_MODE_INTERACTIVE)
Beispiel #5
0
#!/usr/bin/python
# LICENSE: GPL2
# (c) 2013 Tom Schouten <*****@*****.**>
# (c) 2014 Kamil Wartanowicz <*****@*****.**>
import sys, os.path

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import logging

from sim import sim_router
from sim import sim_card
from sim import sim_reader
from util import types

logging.basicConfig(level=logging.INFO, format='%(message)s')
simType = types.TYPE_USIM

simCard = sim_card.SimCard()
simCard.removeAllReaders()
simCard.connect(sim_reader.READER_ID_0)

simRouter = sim_router.SimRouter(cards=[simCard], atr=None, type=simType)
simRouter.run(mode=sim_router.ROUTER_MODE_INTERACTIVE)