GithubHelp home page GithubHelp logo

simlab's People

Contributors

kamwar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simlab's Issues

Can't Install In Ubuntu...PLZ help

Hi I've tried to follow the wiki exactly and all required packages listed seemed to download, but i get this when I try to run the program.

root@simLAB# python ./tests/runner.py Traceback (most recent call last): File "./tests/runner.py", line 14, in <module> from sim import sim_router File "./tests/../sim/sim_router.py", line 14, in <module> import sim_shell File "./tests/../sim/sim_shell.py", line 13, in <module> import sim_reader File "./tests/../sim/sim_reader.py", line 11, in <module> from sim_soft import sim_soft_ctrl File "./tests/../sim_soft/sim_soft_ctrl.py", line 11, in <module> import sim_xml File "./tests/../sim_soft/sim_xml.py", line 8, in <module> from lxml import etree ImportError: /usr/local/lib/python2.7/dist-packages/lxml/etree.so: undefined symbol: PyFPE_jbuf

Support for 2G SIMs?

Hey there,

first let me start by saying thank you for sharing your work!
simLAB looks really quite impressive and I'd love to get it working to emulate a 2G SIM (I have simtrace hw handy).

Unfortunately, I cannot get 2G SIMs to work with the mim_live.py, even though I've edited it to use the SIM instead of USIM type (also as parameter for SimCard()).

When starting, this will be displayed:

C-APDU0: A070000001
R-APDU0: 6D00
Incorrect SW: INVALID_INSTRUCTION_OR_NOT_SUPPORTED, expecting: NO_ERROR. SW1=UNKNOWN_INSTRUCTION_CODE
Failed to init logical channel for simId:0

C-APDU0: A070000001
R-APDU0: 6D00
Incorrect SW: INVALID_INSTRUCTION_OR_NOT_SUPPORTED, expecting: NO_ERROR. SW1=UNKNOWN_INSTRUCTION_CODE
Failed to init logical channel for simId:0

And I guess this is because it tries to open a channel (in sim_ctrl_2g.py) and for some reason this is just not supported on at least 3 SIMs I have (all 2G).

Also, note that some commands will work after that, such as ls:

ls:
status OK
data 7F10/,7F20/,2FE2

Can you tell me if this is in any way required, or if I can skip this and focus on getting backup to work?

Thanks in advance for any response!

Best,
Fabian

Using simLab or simTrace with other readers?

Great Work! Nice to see that Osmocom simTrace SW has finally reached maturity.

However, I am always asking myself why we still use the (Osmocom) SIMtrace? AFAICT, SIMtrce simply provide a USB interface (like any other reader) but with the ISO 7816, T=0/1 options for the USART, and power. Everything else seem rather redundant, like JTAG and multiple serial ports etc.

The USART of the AT91SAM7S is capable of T=0. The documentation only mentions it in clock-master mode, like you would run it in a smart card reader to actively talk to a smart card. However, by using the USART input clock multiplexer, you can use an externally-generated CLK like the one from the SIM card socket of the phone.

Unfortunately, the Rx Timeout feature of the USART is not working in T=0 mode, so I had to re-implement Rx timeout (waiting time) handling by means of the TC (timer/counter) block 0. Due to technical limitations, we will wait up to one byte (12 etu) more than we should.

and from here or here:

Protocol type T
The four least significant bits of any interface character TDi indicate a protocol type T, specifying rules to be used to process transmission protocols. When TDi is not transmitted, T=0 is used.
T=0 is the asynchronous half duplex character transmission protocol.
T=1 is the asynchronous half duplex block transmission protocol.

However, this should be also possible using a Raspberry Pi (or any other embedded Linux device) using its GPIO's and UART's possibly by also tuning the CPU frequency.

So what is the actual communication between the SIMtrace and simLab, needed?
I.e. What would it take to support, let's say an RPi?

Random exception with the simLab

Hi,
I am trying to implement a tool for simcard which uses simLAB as infrastructure. everything is ok, but sometimes during communicating with Simcard I get an exception with the "Failed to transmit with protocol T0. Transaction failed." message.

Below you can see the traceback. any thought to solve the problem would be appreciated.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/zerorpc/core.py", line 153, in _async_task
    functor.pattern.process_call(self._context, bufchan, event, functor)
  File "/usr/local/lib/python2.7/dist-packages/zerorpc/patterns.py", line 30, in process_call
    result = functor(*req_event.args)
  File "/usr/local/lib/python2.7/dist-packages/zerorpc/decorators.py", line 44, in __call__
    return self._functor(*args, **kargs)
  File "/home/firoozian/GitProj/simLAB/mim/../sim/pyscard_rpc_ctrl.py", line 209, in c_transmit
    data, sw1, sw2 = self.getCard(index).transmit(apdu)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/CardConnectionDecorator.py", line 82, in transmit
    return self.component.transmit(bytes, protocol)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 203, in doTransmit
    SCardGetErrorMessage(hresult))
CardConnectionException: Failed to transmit with protocol T0. Transaction failed.
ERROR:root:c_transmit() failed!
    return self.component.transmit(bytes, protocol)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 203, in doTransmit
    SCardGetErrorMessage(hresult))
CardConnectionException: Failed to transmit with protocol T0. Transaction failed.


Exception in thread MainLoopThread:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "../../../sim/sim_router.py", line 702, in run
    self.simRouter.mainloop()
  File "../../../sim/sim_router.py", line 444, in mainloop
    self.tick()
  File "../../../sim/sim_router.py", line 428, in tick
    responseApduTemp = self.handleApdu(cardData, apdu)
  File "../../../sim/sim_router.py", line 303, in handleApdu
    responseApdu = card.apdu(apdu)
  File "../../../sim/sim_card.py", line 98, in apdu
    raise Exception("Failed to transmit C_APDU: " + hextools.bytes2hex(c_apdu) + "\n" + str(e))
Exception: Failed to transmit C_APDU: 00A40804047FFF6FB3
c_transmit() failed!
    return self.component.transmit(bytes, protocol)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "/home/firoozian/.local/lib/python2.7/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 203, in doTransmit
    SCardGetErrorMessage(hresult))
CardConnectionException: Failed to transmit with protocol T0. Transaction failed.


^CTraceback (most recent call last):
  File "sc.py", line 634, in <module>
    main()
  File "sc.py", line 607, in main
    res = analyze_metric_file(Metric, my_shell, html)
  File "sc.py", line 495, in analyze_metric_file
    rule2_res += rule2_security_check(shell, html, current_file_address, expected_security_condition, ef)
  File "sc.py", line 263, in rule2_security_check
    arrRecord, arrValue = shell.simCtrl.getArrRecordForFile(path)
  File "../../../sim/sim_ctrl_3g.py", line 746, in getArrRecordForFile
    arrFileId, arrRecord = self.getLinkedArrFile(path)
  File "../../../sim/sim_ctrl_3g.py", line 610, in getLinkedArrFile
    sw1, sw2, data = self.selectFileByPath(path)
  File "../../../sim/sim_ctrl_3g.py", line 528, in selectFileByPath
    sw1, sw2, data = self.selectFileFromMf(path)
  File "../../../sim/sim_ctrl_3g.py", line 228, in selectFileFromMf
    sw1, sw2, data = self.sendApdu("00A40804%02X%s" %(len(fids)/2, fids))
  File "../../../sim/sim_ctrl_3g.py", line 121, in sendApdu
    rapdu = self.router.injectApdu(apdu, self.getSrvCtr(), mode=mode)
  File "../../../sim/sim_router.py", line 556, in injectApdu
    return self.waitRapduInject()
  File "../../../sim/sim_router.py", line 547, in waitRapduInject
    time.sleep(0.001)
KeyboardInterrupt

Unable to change SPN of operator SIM card

We are trying to use simLAB to update the SPN of a batch of our own operator sim cards.
I have the ADM4 key, and have verified that it is working.

I'm getting the following error : AttributeError: 'module' object has no attribute 'ADM_5'

Ful log:

/ADF0/6F38>readi /ADF_USIM/EF_SPN

C-APDU0: 01A40804047FFF6F46
R-APDU0: 611D

C-APDU0: 01C000001D
R-APDU0: 621B8202412183026F46A5038001718A01058B036F06158002001188009000

C-APDU0: 01A40804047FFF6F46
R-APDU0: 611D

C-APDU0: 01C000001D
R-APDU0: 621B8202412183026F46A5038001718A01058B036F06158002001188009000

C-APDU0: 01A40004026F06
R-APDU0: 6121

C-APDU0: 01C0000021
R-APDU0: 621F8205422100301783026F06A5038001718A01058B036F0601800204508801B89000

C-APDU0: 01B2150430
R-APDU0: 80011CA40683010B950108800102A010A40683010B950108A40683010E9501088001019000FFFFFFFFFFFFFFFFFFFFFF9000

C-APDU0: 01A40804047FFF6F46
R-APDU0: 611D

C-APDU0: 01C000001D
R-APDU0: 621B8202412183026F46A5038001718A01058B036F06158002001188009000

C-APDU0: 01B0000011
R-APDU0: 00436974796D657368FFFFFFFFFFFFFFFF9000

readi:
status OK
data name=Citymesh,display=00

/ADF0/6F46>writei /ADF_USIM/EF_SPN "name=test,display=1"

C-APDU0: 01A40804047FFF6F46
R-APDU0: 611D

C-APDU0: 01C000001D
R-APDU0: 621B8202412183026F46A5038001718A01058B036F06158002001188009000

C-APDU0: 01A40804047FFF6F46
R-APDU0: 611D

C-APDU0: 01C000001D
R-APDU0: 621B8202412183026F46A5038001718A01058B036F06158002001188009000

C-APDU0: 01A40004026F06
R-APDU0: 6121

C-APDU0: 01C0000021
R-APDU0: 621F8205422100301783026F06A5038001718A01058B036F0601800204508801B89000

C-APDU0: 01B2150430
R-APDU0: 80011CA40683010B950108800102A010A40683010B950108A40683010E9501088001019000FFFFFFFFFFFFFFFFFFFFFF9000

C-APDU0: 0120000B00
R-APDU0: 6A88
Couldn't get attempts left
AttributeError: 'module' object has no attribute 'ADM_5'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.