Project

General

Profile

Wiki » History » Version 65

laforge, 03/23/2024 09:08 AM

1 40 fixeria
h1. pySim WiKi
2 4 wirelesss
3 40 fixeria
{{>toc}}
4 1 laforge
5 49 laforge
pySim is a suite of programs (develped in python) for interfacing with SIM/UICC/USIM/ISIM cards.
6 1 laforge
7 64 laforge
* [[pySim-shell]] is an interactive command line tool for navigating around the card file system, reading/writing data to the files as well as administrative commands. It is the most sophisticated general purpose tool of the pySim suite and has long surpassed the capabilities of its older cousins like @pySim-prog@.
8
* [[pySim-prog]] is a small command line utility for programming a small subset of parameters like IMSI, K, OP[c], SMSP in (batches of) various programmable SIM/USIM cards.
9 49 laforge
* @pySim-read@ is a small command line utility for reading some commonly used fields of a SIM card
10 65 laforge
* [[pySim-trace]] is a high-level decoder of SIM card protocol traces (for example, traces generated by [[SIMtrace2:]])
11 49 laforge
12 39 laforge
Such SIM/USIM cards are special cards, which - unlike those issued by regular commercial operators - come with the kind of keys that allow you to write the files/fields that normally only an operator can program.
13 1 laforge
14
This is useful particularly if you are running your own cellular network, and want to issue your own SIM/USIM cards for that network.
15
16
h2. Supported Cards
17
18 49 laforge
* Generic SIM/UICC/USIM/ISIM card
19
** only ETSI/3GPP standard files supported on generic cards
20
** writing of most fields is typically not possible as nobody except the card-issuing operator posesses the keys / ADM1 PIN to write
21
* Actively supported, fully programmable cards
22 56 laforge
** [[cellular-infrastructure:sysmoISIM-SJA2]] (3GPP Release 16 SIM + USIM + ISIM)
23
** [[cellular-infrastructure:sysmoISIM-SJA5]] (3GPP Release 17 SIM + USIM + ISIM + HPSIM)
24 49 laforge
* Older fully programmable cards
25
** [[cellular-infrastructure:sysmoUSIM-SJS1]] (SIM + USIM)
26
* Older much less configurable cards
27
** [[cellular-infrastructure:GrcardSIM]] (SIM)
28
** [[cellular-infrastructure:GrcardSIM2]] (SIM)
29
** [[cellular-infrastructure:MagicSIM]] (SIM)
30 1 laforge
31 49 laforge
h2. Supported Card Interfaces ("Readers")
32 1 laforge
33 49 laforge
The best-supported/recommended configuration is to use a Smart Card Interface device compliant with the _USB CCID_ specification, using the libccid/pcsc-lite driver stack.
34 41 laforge
35 49 laforge
However, pySim supports multiple card interface back-ends:
36
37
* @pcsc@: any reader suppored by "pcsc-lite":https://pcsclite.apdu.fr/
38 41 laforge
** pcsc-lite supports any reader that provides a so-called @ifd_handler@ driver. Those could come e.g. from reader vendors, but
39 54 laforge
** pcsc-lite is very well integrated with "libccid":https://ccid.apdu.fr/, whose reader support status is indicated at https://ccid.apdu.fr/ccid/section.html
40 49 laforge
* @serial@: simple serial/UART based readers, as sometimes shipped with GRcard SIMs
41
* @calypso@: A calypso chipset based mobile phone runnung [[OsmocomBB:]]
42
* @modem_atcmd@: Any cellular modem offering the @AT+CSIM@ command
43 47 laforge
44 55 laforge
The pySim developers as well as the continuous integration / automatic testing are utilizing USB-CCID readers via pcsc-lite.  Your milage with other backends (not used much, not automatically tested) may vary!
45
46 47 laforge
h2. Documentation
47
48
h3. User Manual
49
50
The manual / documentation can be built from the source code by @(cd docs && make html latexpdf)@.
51 48 laforge
52 47 laforge
Pre-rendered versions of the current @master@ branch are available as "PDF":https://ftp.osmocom.org/docs/latest/osmopysim-usermanual.pdf and "HTML":https://downloads.osmocom.org/docs/latest/pysim/
53
54
h3. Video on pySim-shell usage
55
56
On April 9. 2021 @laforge gave a presentation on @pySim-shell@, a video recording can be found at 
57
https://people.osmocom.org/tnt/osmodevcall/osmodevcall-20210409-laforge-pysim-shell_h264_420.mp4
58
59 62 laforge
h3. Installation instructions
60 1 laforge
61 60 laforge
Please follow the instructions provided in [source:README.md]
62
63 61 laforge
h3. Usage instructions
64 16 wirelesss
65 37 wirelesss
* Connect SIM card reader.
66 1 laforge
* Insert programmable SIM card
67 37 wirelesss
68 61 laforge
h4. Check the status of connection by entering the following command:
69 37 wirelesss
70 34 wirelesss
<pre>
71 37 wirelesss
 pcsc_scan
72 5 wirelesss
</pre>
73 37 wirelesss
74 32 wirelesss
* If SIM card reader is recognised then we can expect something similar to the below output:
75 37 wirelesss
76 5 wirelesss
<pre>
77
 $ pcsc_scan
78 1 laforge
 PC/SC device scanner
79 5 wirelesss
 V 1.4.25 (c) 2001-2011, Ludovic Rousseau ludovic.rousseau@free.fr
80
 Compiled with PC/SC lite version: 1.8.14
81
 Using reader plug'n play mechanism
82
 Scanning present readers...
83
 0: SCM Microsystems Inc. SCR 3310 [CCID Interface] 00 00 
84
 Tue Oct 18 11:48:08 2016
85
 Reader 0: SCM Microsystems Inc. SCR 3310 [CCID Interface] 00 00
86
 Card state: Card inserted, 
87
 ATR: 3B 99 18 00 11 88 22 33 44 55 66 77 60
88
 + TS = 3B --> Direct Convention
89
 + T0 = 99, Y(1): 1001, K: 9 (historical bytes)
90 20 wirelesss
  TA(1) = 18 --> Fi=372, Di=12, 31 cycles/ETU
91 1 laforge
  129032 bits/s at 4 MHz, fMax for Fi = 5 MHz => 161290 bits/s
92 20 wirelesss
  TD(1) = 00 --> Y(i+1) = 0000, Protocol T = 0 
93 1 laforge
 -----
94
 + Historical bytes: 11 88 22 33 44 55 66 77 60
95 20 wirelesss
 Category indicator byte: 11 (proprietary format)
96 1 laforge
 Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
97
 3B 99 18 00 11 88 22 33 44 55 66 77 60
98
 sysmocom sysmoSIM-GR1
99
100 20 wirelesss
</pre>
101 37 wirelesss
102 20 wirelesss
** Exit pcsc_scan : _Ctrl+C_
103 37 wirelesss
104 61 laforge
h4. Read (a few fields of) your SIM card
105 5 wirelesss
106
 ./pySim-read.py -p0 or ./pySim-read.py -p1 
107 32 wirelesss
108 37 wirelesss
* Using sysmoSIM-GR1 and if everything is done correctly, you will see something similar to:
109 1 laforge
 
110 37 wirelesss
<pre>
111 1 laforge
 $ ./pySim-read.py -p0 
112 5 wirelesss
 Reading ...
113
 ICCID: 1791198229180000071
114
 IMSI: 001640000000071
115
 SMSP: ffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
116
 ACC: ffff
117
 MSISDN: Not available
118
 Done !
119 37 wirelesss
120 43 laforge
</pre>
121 44 roh
122 63 laforge
h4. bulk programming of some common SIM parameters
123
124
See [[pySim-prog]] 
125
126
h4. interactive exploration and/or programming of any parameter in any file
127
128
See [[pySim-shell]]
129
130 61 laforge
h2. Continuous Integration / Automatic Testing
131 45 laforge
132 44 roh
pySim is continuously and automatically tested by a [[TestRig]] run by sysmocom
133 45 laforge
134 1 laforge
{{include(cellular-infrastructure:MacroCommercialSupport)}}
Add picture from clipboard (Maximum size: 48.8 MB)