Help on using pysim to flash a SIM card
domi at tomcsanyi.net
Tue Dec 1 10:29:57 UTC 2020
Have a look at this list for example for APDU response codes to
understand better what is going on.
On Tue, Dec 1, 2020 at 10:24 AM Chunlin Yang <chliny2016 at gmail.com> wrote:
> Hi Vadim and all,
> pyProg.py fails with an error, could you help (btw, I change all real info to xxx :)):
> support at S2600WFT:~/pysim$ python ./pySim-prog.py -p 0 -x 208 -y 93 -t sysmoUSIM-SJS1 -i 208930000000003 --op=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -k xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -s xxxxxxxxxxxxxxxxxxxxx -a xxxxxxxx
> Using PC/SC reader interface
> Ready for Programming: Insert card now (or CTRL-C to cancel)
> Generated card parameters :
> > Name : Magic
> > SMSP : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > ICCID : xxxxxxxxxxxxxxxxxxxx
> > MCC/MNC : 208/93
> > IMSI : xxxxxxxxxxxxxxx
> > Ki : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > OPC : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > ACC : None
> > ADM1(hex): xxxxxxxxxxxxxxxx
> Programming ...
> Card programming failed with an execption:
> Traceback (most recent call last):
> File "./pySim-prog.py", line 719, in <module>
> rc = process_card(opts, first, card_handler)
> File "./pySim-prog.py", line 671, in process_card
> File "/home/support/pysim/pySim/cards.py", line 713, in program
> self._scc.verify_chv(0x0A, h2b(p['pin_adm']))
> File "/home/support/pysim/pySim/commands.py", line 206, in verify_chv
> return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)
> File "/home/support/pysim/pySim/transport/__init__.py", line 104, in send_apdu_checksw
> raise RuntimeError("SW match failed! Expected %s and got %s." % (sw.lower(), rv))
> RuntimeError: SW match failed! Expected 9000 and got 63c9.
> Programming failed: Remove card from reader
> On Tue, Dec 1, 2020 at 1:07 AM Chunlin Yang <chliny2016 at gmail.com> wrote:
>> Thanks a lot Vadim!
>> I have thought it might be an issue between python3 and python2. So I have tried on both versions.
>> on Python3, I got same error.
>> But now with this command 'python ./pySim-read.py -p0', it works. I used to use this command './pySim-read.py -p0' and it gave me the same error.
>> But although 'python ./pySim-read.py -p0' works (reads out the content of the SIM, it gives me an error/prompt at the end:
>> Traceback (most recent call last):
>> File "./pySim-read.py", line 255, in <module>
>> (res, sw) = card.read_ehplmn()
>> AttributeError: 'OpenCellsSim' object has no attribute 'read_ehplmn'
>> maybe I can just ignore this prompt as I don't need ehplmn.
>> On Tue, Dec 1, 2020 at 12:45 AM Vadim Yanitskiy <vyanitskiy at sysmocom.de> wrote:
>>> On 12/1/20 2:17 AM, Chunlin Yang wrote:
>>> > ModuleNotFoundError: No module named 'smartcard'
>>> > BTW, I have manually imported smartcard in python, and it's successful.
>>> I guess you have two Python versions (2.7 and 3.x), so it could be that
>>> you've installed smartcard for 3.x and in works in the shell.
>>> Unfortunately, pySim has not been completely migrated to 3.x yet, so it
>>> starts under 2.7 by default. You can try to run it under 3.x:
>>> python3 ./pySim-read.py -p0
>>> or install the 'smartcard' module for Python 2.7.
>>> Best regards,
>>> - Vadim Yanitskiy <vyanitskiy at sysmocom.de> http://www.sysmocom.de/
>>> * sysmocom - systems for mobile communications GmbH
>>> * Alt-Moabit 93
>>> * 10559 Berlin, Germany
>>> * Sitz / Registered office: Berlin, HRB 134158 B
>>> * Geschaeftsfuehrer / Managing Director: Harald Welte
More information about the OpenBSC