mitshell / card

Facilitates communications with telco smartcard (especially SIM and USIM)
http://michau.benoit.free.fr/
GNU General Public License v2.0
144 stars 56 forks source link

Reading sysmocom ISIM cards and is not working. #9

Closed fasferraz closed 3 years ago

fasferraz commented 3 years ago

I use this module in some applicatons i have done, and I was trying to use it with sysmocom ISIM, and when i try to select USIM application to read the IMSI or to do an authenticate operation, it fails:

root@ubuntu:/home/fabricio/Documents#python3 Python 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from card.USIM import * a = USIM(0) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/USIM.py", line 195, in init File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/USIM.py", line 205, in SELECT_ADF_USIM File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/ICC.py", line 1244, in select File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/ICC.py", line 1594, in parse_file File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/ICC.py", line 728, in parse_file File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/ICC.py", line 788, in parse_FCP File "/usr/local/lib/python3.8/dist-packages/card-0.3-py3.8.egg/card/ICC.py", line 940, in parse_compact_security_attribute NameError: name 'self' is not defined

Using this slightly modified version https://github.com/sysmocom/sysmo-usim-tool/tree/master/card it works:

root@ubuntu:/home/fabricio/Documents# cd sysmo-usim-tool/ root@ubuntu:/home/fabricio/Documents/sysmo-usim-tool# python3 Python 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from card.USIM import * a = USIM(0) a.get_imsi() '901700000050900'

cn0xroot commented 3 years ago

Maybe you can try osmocom office tool pysim https://github.com/osmocom/pysim

mitshell commented 3 years ago

Thank you for reporting Fabricio. I can see some changes (probably bugfixes) in the card/{ICC.py, USIM.py, utils.py} files, from https://github.com/sysmocom/sysmo-usim-tool/commit/8dd52e04ac5abbb56c8e3168d36486ce6db3d42e#diff-18bdfd456cc9bae99d99f9de1dfaf618c2cf1d4a1289a8dc8abfbc56959ce836

I need to investigate further and will commit some patches next week. And true for pysim : the osmocom library has received numerous contributions in the last months, is nicely documented, and should work great with all the sysmocom cards.

mitshell commented 3 years ago

I just pushed some little fixes and enhancement: I hope this to solve your error. Do a fresh checkout, retry and let me know how it goes.

fasferraz commented 3 years ago

Hi @mitshell Problem solved! Thanks!