Project

General

Profile

Wiki » History » Version 46

laforge, 10/14/2020 04:49 PM
add sysmoISIM-SJA2 to suppored cards

1 40 fixeria
h1. pySim WiKi
2 4 wirelesss
3 40 fixeria
{{>toc}}
4 1 laforge
5
pySim-prog is a small command line utility written in python, which is used for programming various programmable SIM/USIM cards.
6
7 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.
8
9
This is useful particularly if you are running your own cellular network, and want to issue your own SIM/USIM cards for that network.
10
11 37 wirelesss
h2. Supported Cards
12 1 laforge
13 46 laforge
* [[cellular-infrastructure:sysmoISIM-SJA2]]
14 33 wirelesss
* [[cellular-infrastructure:sysmoUSIM-SJS1]]
15 1 laforge
* [[cellular-infrastructure:GrcardSIM]]
16
* [[cellular-infrastructure:GrcardSIM2]]
17
* [[cellular-infrastructure:MagicSIM]]
18
19 41 laforge
h2. Supported Readers
20
21
pySim-prog supports two readar back-ends:
22
23
* simple serial/UART based readers, as sometimes shipped with GRcard SIMs
24
* any reader suppored by "pcsc-lite":https://pcsclite.apdu.fr/
25
** pcsc-lite supports any reader that provides a so-called @ifd_handler@ driver. Those could come e.g. from reader vendors, but
26
** pcsc-lite is very well integrated with "libccid":https://ccid.apdu.fr/ccid, whose reader support status is indicated at https://ccid.apdu.fr/ccid/section.html
27 1 laforge
28 37 wirelesss
h2. Usage instructions
29 1 laforge
30
31 37 wirelesss
h3. Install dependencies:
32
33
<pre>
34 38 wirelesss
 sudo apt-get install pcscd pcsc-tools libccid libpcsclite-dev python-pyscard
35 37 wirelesss
</pre>
36 36 neels
37 37 wirelesss
* Connect SIM card reader.
38 16 wirelesss
39 37 wirelesss
* Insert programmable SIM card
40 1 laforge
41 37 wirelesss
h3. Check the status of connection by entering the following command:
42 1 laforge
43 37 wirelesss
<pre>
44 34 wirelesss
 pcsc_scan
45 37 wirelesss
</pre>
46 5 wirelesss
47 37 wirelesss
* If SIM card reader is recognised then we can expect something similar to the below output:
48 32 wirelesss
49 37 wirelesss
<pre>
50 5 wirelesss
 $ pcsc_scan
51
 PC/SC device scanner
52
 V 1.4.25 (c) 2001-2011, Ludovic Rousseau ludovic.rousseau@free.fr
53
 Compiled with PC/SC lite version: 1.8.14
54
 Using reader plug'n play mechanism
55
 Scanning present readers...
56
 0: SCM Microsystems Inc. SCR 3310 [CCID Interface] 00 00 
57
 Tue Oct 18 11:48:08 2016
58
 Reader 0: SCM Microsystems Inc. SCR 3310 [CCID Interface] 00 00
59
 Card state: Card inserted, 
60
 ATR: 3B 99 18 00 11 88 22 33 44 55 66 77 60
61
 + TS = 3B --> Direct Convention
62
 + T0 = 99, Y(1): 1001, K: 9 (historical bytes)
63 20 wirelesss
  TA(1) = 18 --> Fi=372, Di=12, 31 cycles/ETU
64 1 laforge
  129032 bits/s at 4 MHz, fMax for Fi = 5 MHz => 161290 bits/s
65 20 wirelesss
  TD(1) = 00 --> Y(i+1) = 0000, Protocol T = 0 
66 1 laforge
 -----
67
 + Historical bytes: 11 88 22 33 44 55 66 77 60
68 20 wirelesss
 Category indicator byte: 11 (proprietary format)
69 1 laforge
 Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
70
 3B 99 18 00 11 88 22 33 44 55 66 77 60
71
 sysmocom sysmoSIM-GR1
72 20 wirelesss
73 37 wirelesss
</pre>
74 20 wirelesss
75 37 wirelesss
** Exit pcsc_scan : _Ctrl+C_
76 20 wirelesss
77 1 laforge
78 37 wirelesss
h3. Get the code of PySIM by entering command:
79
80
<pre>
81 1 laforge
 git clone git://git.osmocom.org/pysim pysim
82 37 wirelesss
</pre>
83 1 laforge
84 37 wirelesss
<pre>
85 5 wirelesss
 cd pysim
86 37 wirelesss
</pre>
87 32 wirelesss
88 37 wirelesss
h3. Read your SIM card
89 5 wirelesss
90
 ./pySim-read.py -p0 or ./pySim-read.py -p1 
91 32 wirelesss
92 37 wirelesss
* Using sysmoSIM-GR1 and if everything is done correctly, you will see something similar to:
93 1 laforge
 
94 37 wirelesss
<pre>
95 1 laforge
 $ ./pySim-read.py -p0 
96 5 wirelesss
 Reading ...
97
 ICCID: 1791198229180000071
98
 IMSI: 001640000000071
99
 SMSP: ffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
100
 ACC: ffff
101
 MSISDN: Not available
102
 Done !
103
104 37 wirelesss
</pre>
105 5 wirelesss
106 37 wirelesss
h3. Program your SIM card
107 17 wirelesss
108 37 wirelesss
* Enter   @./pySim-prog.py -help@   to get overview of possible options. 
109 1 laforge
110 7 wirelesss
Similar result should appear: 
111 5 wirelesss
112
 $ ./pySim-prog.py -help
113
 Usage: pySim-prog.py [options]
114
 Options:
115
   -h, --help            show this help message and exit
116
   -d DEV, --device=DEV  Serial Device for SIM access [default: /dev/ttyUSB0]
117
   -b BAUD, --baud=BAUD  Baudrate used for SIM access [default: 9600]
118
   -p PCSC, --pcsc-device=PCSC
119
                         Which PC/SC reader number for SIM access
120
   -t TYPE, --type=TYPE  Card type (user -t list to view) [default: auto]
121
   -a PIN_ADM, --pin-adm=PIN_ADM
122
                         ADM PIN used for provisioning (overwrites default)
123
   -e, --erase           Erase beforehand [default: False]
124
   -S SOURCE, --source=SOURCE
125
                         Data Source[default: cmdline]
126
   -n NAME, --name=NAME  Operator name [default: Magic]
127
   -c CC, --country=CC   Country code [default: 1]
128
   -x MCC, --mcc=MCC     Mobile Country Code [default: 901]
129
   -y MNC, --mnc=MNC     Mobile Network Code [default: 55]
130
   -m SMSC, --smsc=SMSC  SMSP [default: '00 + country code + 5555']
131
   -M SMSP, --smsp=SMSP  Raw SMSP content in hex [default: auto from SMSC]
132
   -s ID, --iccid=ID     Integrated Circuit Card ID
133
   -i IMSI, --imsi=IMSI  International Mobile Subscriber Identity
134 1 laforge
   -k KI, --ki=KI        Ki (default is to randomize)
135 5 wirelesss
   -o OPC, --opc=OPC     OPC (default is to randomize)
136
   --op=OP               Set OP to derive OPC from OP and KI
137
   --acc=ACC             Set ACC bits (Access Control Code). not all card types
138
                         are supported
139
   -z STR, --secret=STR  Secret used for ICCID/IMSI autogen
140
   -j NUM, --num=NUM     Card # used for ICCID/IMSI autogen
141
   --batch               Enable batch mode [default: False]
142
   --batch-state=FILE    Optional batch state file
143
   --read-csv=FILE       Read parameters from CSV file rather than command line
144
   --write-csv=FILE      Append generated parameters in CSV file
145
   --write-hlr=FILE      Append generated parameters to OpenBSC HLR sqlite3
146
   --dry-run             Perform a 'dry run', don't actually program the card
147 32 wirelesss
148 37 wirelesss
h3. Example of how to program a sysmoSIM-GR1 card 
149 18 wirelesss
150 5 wirelesss
The GRcard SIM is a programmable GSM SIM card. It uses a mixture of TS11.11 / ISO7816-4 and proprietary commands for programming.
151
152 1 laforge
In the below example, we are changing the card’s IMSI to 901700000003080 (option -i) and we are specifying a new set of -n NAME (Operator name), -t TYPE (Card type), -c CC (Country code), -x MCC (Mobile Country Code), -y MNC (Mobile Network Code) and -s ID (Integrated Circuit Card ID) values.
153
 
154 25 wirelesss
 $ ./pySim-prog.py -p 0 -n OpenBSC -t sysmosim-gr1 -i 901700000003080 -c 001 -x 001 -y 02 -s 1791198229180000075
155 5 wirelesss
 Insert card now (or CTRL-C to cancel)
156
 Generated card parameters :
157
  > Name    : OpenBSC
158
  > SMSP    : e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
159
  > ICCID   : 1791198229180000075
160
  > MCC/MNC : 1/2
161
  > IMSI    : 901700000003080
162
  > Ki      : 7edaeb6addbd72d2b2cc6ed7bfecc9c9
163
  > OPC     : 23f075ab9b1a113d4db822d8195ea20c
164
  > ACC     : None
165 1 laforge
 Programming ...
166 5 wirelesss
 Done !
167 32 wirelesss
168 37 wirelesss
h3. Example of how to program a sysmoUSIM-SJS1 card
169 31 wirelesss
170 5 wirelesss
(U)SIM cards are Java capable and there is the Globalplatform that specifies standards API. SMS can be addressed directly to the SIM card, the SIM card will get events for network selection and others, it can modify call establishment attempts.
171
172
173
Provisioning of different identities or keys.
174 13 wirelesss
 
175 5 wirelesss
If you have a variant of the card-individual ADM1 key of your sysmoUSIM-SJS1 card,  you can change any identity (IMSI, ICCID, MSISDN) stored on the (U)SIM, as well as the private key data (K, OPC).
176
177 1 laforge
In the below example, we are changing the card’s IMSI to 901700000003080 (option -i) and we are specifying a new set of -t TYPE (Card type), - a ADM_PIN (ADM PIN used for provisioning), -x MCC (Mobile Country Code), -y MNC (Mobile Network Code), -s ID (Integrated Circuit Card ID), -o OPC and -k KI (Ki) values.
178 26 wirelesss
179 5 wirelesss
 $ ./pySim-prog.py -p 0 -t sysmoUSIM-SJS1 -a 58001006  -x 901 -y 71 -i 901700000010659 -s 8988211000000110000 -o 398153093661279FB1FC74BE07059FEF -k 1D8B2562B992549F20D0F42113EAA6FA
180 11 wirelesss
 Insert card now (or CTRL-C to cancel)
181 5 wirelesss
 Generated card parameters :
182
  > Name    : Magic
183
  > SMSP    : e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
184
  > ICCID   : 8988211000000110000
185
  > MCC/MNC : 901/71
186 6 wirelesss
  > IMSI    : 901700000010659
187 5 wirelesss
  > Ki      : 1D8B2562B992549F20D0F42113EAA6FA
188
  > OPC     : 398153093661279FB1FC74BE07059FEF
189
  > ACC     : None
190 6 wirelesss
 Programming ...
191 5 wirelesss
 Done !
192
193 37 wirelesss
h3. Example of how to program a Magic SIM / SuperSIM 16-in-1 / X-sim card
194 5 wirelesss
195
The 16-in-1 SIM cards are intended for COMP128v1 based cloning and enable the user to aggregate up to 16 SIM card identities in a single card. This multi-IMSI property is not used in the context of Osmocom.
196
197 1 laforge
Below example shows how we can change the card’s IMSI to 901990000000018 (option -i) and at the same time we are specifying a new set of -x MCC (Mobile Country Code), -y MNC (Mobile Network Code), -s ID (Integrated Circuit Card ID) , -o OPC and -k KI (Ki) values.
198
199 5 wirelesss
 $ ./pySim-prog.py -p 0 -x 801 -y 71 -i 901990000000018 -s 8988211000000110000 -o 398153093661279FB1FC74BE07059FEF -k 1D8B2562B992549F20D0F42113EAA6FA
200
 Insert card now (or CTRL-C to cancel)
201
 Autodetected card type fakemagicsim
202
 Generated card parameters :
203
  > Name    : Magic
204
  > SMSP    : e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
205
  > ICCID   : 8988211000000110000
206
  > MCC/MNC : 801/71
207 1 laforge
  > IMSI    : 901990000000018
208 5 wirelesss
  > Ki      : 1D8B2562B992549F20D0F42113EAA6FA
209 1 laforge
  > OPC     : 398153093661279FB1FC74BE07059FEF
210 5 wirelesss
  > ACC     : None
211
 Programming ...
212
 Done !
213
214 37 wirelesss
h3. README 
215 6 wirelesss
216 37 wirelesss
pySim comes with following README file: 
217 5 wirelesss
218 42 gnutoo
https://git.osmocom.org/pysim/tree/README.md
219 43 laforge
220 44 roh
h3. Testing
221
222 45 laforge
pySim is continuously and automatically tested by a [[TestRig]] run by sysmocom
223 44 roh
224 45 laforge
{{include(cellular-infrastructure:MacroCommercialSupport)}}
Add picture from clipboard (Maximum size: 48.8 MB)