blob: 811ef61769a08cab35a0da5f6abea9964868bcc1 [file] [log] [blame]
Harald Welte94e87352021-04-02 13:38:00 +02001pySim-shell
2===========
Harald Weltebe9516f2021-04-03 11:30:10 +02003
4pySim-shell is an interactive command line shell for all kind of interactions with SIM cards.
5
6The interactive shell provides command for
7
8* navigating the on-card filesystem hierarchy
9* authenticating with PINs such as ADM1
10* CHV/PIN management (VERIFY, ENABLE, DISABLE, UNBLOCK)
11* decoding of SELECT response (file control parameters)
12* reading and writing of files and records in raw, hex-encoded binary format
13* for some files where related support has been developed:
14
15 * decoded reading (display file data in JSON format)
16 * decoded writing (encode from JSON to binary format, then write)
17
18By means of using the python ``cmd2`` module, various useful features improve usability:
19
20* history of commands (persistent across restarts)
21* output re-direction to files on your computer
22* output piping through external tools like 'grep'
23* tab completion of commands and SELECT-able files/directories
24* interactive help for all commands
25
Harald Weltef2e761c2021-04-11 11:56:44 +020026Running pySim-shell
27-------------------
28
29pySim-shell has a variety of command line arguments to control
30
31* which transport to use (how to use a reader to talk to the SIM card)
32* whether to automatically verify an ADM pin (and in which format)
33* whether to execute a start-up script
34
35.. argparse::
36 :module: pySim-shell
37 :func: option_parser
Harald Weltef422eb12023-06-09 11:15:09 +020038 :prog: pySim-shell.py
Harald Weltef2e761c2021-04-11 11:56:44 +020039
Merlin Chlosta69b69d42023-05-11 12:59:01 +020040Usage Examples
41--------------
42.. toctree::
43 :maxdepth: 1
44 :caption: Tutorials for pySIM-shell:
45
46 suci-tutorial
Harald Weltef2e761c2021-04-11 11:56:44 +020047
Harald Weltebe9516f2021-04-03 11:30:10 +020048
49cmd2 basics
50-----------
51
52FIXME
53
54
55
56ISO7816 commands
57----------------
58
59This category of commands relates to commands that originate in the ISO 7861-4 specifications,
60most of them have a 1:1 resemblance in the specification.
61
62select
63~~~~~~
64
65The ``select`` command is used to select a file, either by its FID, AID or by its symbolic name.
66
67Try ``select`` with tab-completion to get a list of all current selectable items:
68
69::
70
Harald Welte237ddb52023-10-22 10:36:58 +020071 pySIM-shell (00:MF)> select
Harald Weltebe9516f2021-04-03 11:30:10 +020072 .. 2fe2 a0000000871004 EF.ARR MF
73 2f00 3f00 ADF.ISIM EF.DIR
74 2f05 7f10 ADF.USIM EF.ICCID
75 2f06 7f20 DF.GSM EF.PL
76 2f08 a0000000871002 DF.TELECOM EF.UMPC
77
78Use ``select`` with a specific FID or name to select the new file.
79
80This will
81
82* output the [JSON decoded, if possible] select response
83* change the prompt to the newly selected file
84* enable any commands specific to the newly-selected file
85
86::
87
Harald Welte237ddb52023-10-22 10:36:58 +020088 pySIM-shell (00:MF)> select ADF.USIM
Harald Weltebe9516f2021-04-03 11:30:10 +020089 {
90 "file_descriptor": {
Harald Welte747a9782022-02-13 17:52:28 +010091 "file_descriptor_byte": {
92 "shareable": true,
93 "file_type": "df",
94 "structure": "no_info_given"
95 }
Harald Weltebe9516f2021-04-03 11:30:10 +020096 },
97 "df_name": "A0000000871002FFFFFFFF8907090000",
98 "proprietary_info": {
99 "uicc_characteristics": "71",
100 "available_memory": 101640
101 },
102 "life_cycle_status_int": "operational_activated",
103 "security_attrib_compact": "00",
104 "pin_status_template_do": "90017083010183018183010A83010B"
105 }
Harald Welte237ddb52023-10-22 10:36:58 +0200106 pySIM-shell (00:MF/ADF.USIM)>
Harald Weltebe9516f2021-04-03 11:30:10 +0200107
108
Harald Welted01bd362022-02-15 15:56:48 +0100109status
110~~~~~~
111
112The ``status`` command [re-]obtains the File Control Template of the
113currently-selected file and print its decoded output.
114
115Example:
116
117::
118
Harald Welte237ddb52023-10-22 10:36:58 +0200119 pySIM-shell (00:MF/ADF.ISIM)> status
Harald Welted01bd362022-02-15 15:56:48 +0100120 {
121 "file_descriptor": {
122 "file_descriptor_byte": {
123 "shareable": true,
124 "file_type": "df",
125 "structure": "no_info_given"
126 },
127 "record_len": null,
128 "num_of_rec": null
129 },
130 "file_identifier": "ff01",
131 "df_name": "a0000000871004ffffffff8907090000",
132 "proprietary_information": {
133 "uicc_characteristics": "71",
134 "available_memory": 101640
135 },
136 "life_cycle_status_integer": "operational_activated",
137 "security_attrib_compact": "00",
138 "pin_status_template_do": {
139 "ps_do": "70",
140 "key_reference": 11
141 }
142 }
143
Harald Weltebe9516f2021-04-03 11:30:10 +0200144
145change_chv
146~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200147.. argparse::
148 :module: pySim-shell
149 :func: Iso7816Commands.change_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200150
151
152disable_chv
153~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200154.. argparse::
155 :module: pySim-shell
156 :func: Iso7816Commands.disable_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200157
Harald Weltebe9516f2021-04-03 11:30:10 +0200158
159enable_chv
160~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200161.. argparse::
162 :module: pySim-shell
163 :func: Iso7816Commands.enable_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200164
165
166unblock_chv
167~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200168.. argparse::
169 :module: pySim-shell
170 :func: Iso7816Commands.unblock_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200171
Harald Weltebe9516f2021-04-03 11:30:10 +0200172
173verify_chv
174~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200175.. argparse::
176 :module: pySim-shell
177 :func: Iso7816Commands.verify_chv_parser
178
Harald Weltea4631612021-04-10 18:17:55 +0200179deactivate_file
180~~~~~~~~~~~~~~~
181Deactivate the currently selected file. This used to be called INVALIDATE in TS 11.11.
182
183
184activate_file
185~~~~~~~~~~~~~
Harald Welte799c3542022-02-15 15:56:28 +0100186.. argparse::
187 :module: pySim-shell
188 :func: Iso7816Commands.activate_file_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200189
Harald Welte703f9332021-04-10 18:39:32 +0200190open_channel
191~~~~~~~~~~~~
192.. argparse::
193 :module: pySim-shell
194 :func: Iso7816Commands.open_chan_parser
195
196close_channel
197~~~~~~~~~~~~~
198.. argparse::
199 :module: pySim-shell
200 :func: Iso7816Commands.close_chan_parser
201
Harald Welte20650992023-10-21 23:47:02 +0200202switch_channel
203~~~~~~~~~~~~~~
204.. argparse::
205 :module: pySim-shell
206 :func: Iso7816Commands.switch_chan_parser
207
Harald Weltebe9516f2021-04-03 11:30:10 +0200208
Harald Welte659781c2023-06-06 17:00:51 +0200209TS 102 221 commands
210-------------------
211
212These are commands as specified in ETSI TS 102 221, the core UICC specification.
213
Harald Welteec950532021-10-20 13:09:00 +0200214suspend_uicc
215~~~~~~~~~~~~
216This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
217recent power-saving addition to the UICC specifications, allowing for suspend/resume while maintaining
218state, as opposed to a full power-off (deactivate) and power-on (activate) of the card.
219
220The pySim command just sends that SUSPEND UICC command and doesn't perform the full related sequence
221including the electrical power down.
222
223.. argparse::
Harald Welte659781c2023-06-06 17:00:51 +0200224 :module: pySim.ts_102_221
225 :func: CardProfileUICC.AddlShellCommands.suspend_uicc_parser
Harald Welteec950532021-10-20 13:09:00 +0200226
Harald Welteb0e0dce2023-06-06 17:21:13 +0200227resume_uicc
228~~~~~~~~~~~
229This command allows you to perform the SUSPEND UICC command for the RESUME operation on the card.
230
231Suspend/Resume is a relatively recent power-saving addition to the UICC specifications, allowing for
232suspend/resume while maintaining state, as opposed to a full power-off (deactivate) and power-on
233(activate) of the card.
234
235The pySim command just sends that SUSPEND UICC (RESUME) command and doesn't perform the full related
236sequence including the electrical power down.
237
238.. argparse::
239 :module: pySim.ts_102_221
240 :func: CardProfileUICC.AddlShellCommands.resume_uicc_parser
Harald Welteec950532021-10-20 13:09:00 +0200241
Harald Welte12af7932022-02-15 16:39:08 +0100242
Harald Weltebe9516f2021-04-03 11:30:10 +0200243pySim commands
244--------------
245
246Commands in this category are pySim specific; they do not have a 1:1 correspondence to ISO 7816
247or 3GPP commands. Mostly they will operate either only on local (in-memory) state, or execute
248a complex sequence of card-commands.
249
250desc
251~~~~
Harald Weltebe9516f2021-04-03 11:30:10 +0200252Display human readable file description for the currently selected file.
253
254
255dir
256~~~
Harald Welted36f6942021-04-04 14:37:55 +0200257.. argparse::
258 :module: pySim-shell
259 :func: PySimCommands.dir_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200260
Harald Welte12af7932022-02-15 16:39:08 +0100261Example:
262::
263
Harald Welte237ddb52023-10-22 10:36:58 +0200264 pySIM-shell (00:MF)> dir
Harald Welte12af7932022-02-15 16:39:08 +0100265 MF
266 3f00
267 .. ADF.USIM DF.SYSTEM EF.DIR EF.UMPC
268 ADF.ARA-M DF.EIRENE DF.TELECOM EF.ICCID MF
269 ADF.ISIM DF.GSM EF.ARR EF.PL
270 14 files
271
Harald Weltebe9516f2021-04-03 11:30:10 +0200272
273export
274~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200275.. argparse::
276 :module: pySim-shell
277 :func: PySimCommands.export_parser
278
Harald Weltebd02f842021-10-21 14:40:39 +0200279Please note that `export` works relative to the current working
280directory, so if you are in `MF`, then the export will contain all known
281files on the card. However, if you are in `ADF.ISIM`, only files below
282that ADF will be part of the export.
283
284Furthermore, it is strongly advised to first enter the ADM1 pin
285(`verify_adm`) to maximize the chance of having permission to read
286all/most files.
287
Harald Weltebe9516f2021-04-03 11:30:10 +0200288
289tree
290~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200291Display a tree of the card filesystem. It is important to note that this displays a tree
292of files that might potentially exist (based on the card profile). In order to determine if
293a given file really exists on a given card, you have to try to select that file.
Harald Welted36f6942021-04-04 14:37:55 +0200294
Harald Welte12af7932022-02-15 16:39:08 +0100295Example:
296::
297
Harald Welte237ddb52023-10-22 10:36:58 +0200298 pySIM-shell (00:MF)> tree --help
Harald Welte12af7932022-02-15 16:39:08 +0100299 EF.DIR 2f00 Application Directory
300 EF.ICCID 2fe2 ICC Identification
301 EF.PL 2f05 Preferred Languages
302 EF.ARR 2f06 Access Rule Reference
303 EF.UMPC 2f08 UICC Maximum Power Consumption
304 DF.TELECOM 7f10 None
305 EF.ADN 6f3a Abbreviated Dialing Numbers
306 ...
307
308
Harald Weltebe9516f2021-04-03 11:30:10 +0200309
310verify_adm
311~~~~~~~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200312Verify the ADM (Administrator) PIN specified as argument. This is typically needed in order
313to get write/update permissions to most of the files on SIM cards.
314
315Currently only ADM1 is supported.
Harald Weltebe9516f2021-04-03 11:30:10 +0200316
317
Harald Weltedaf2b392021-05-03 23:17:29 +0200318reset
319~~~~~
Harald Weltedaf2b392021-05-03 23:17:29 +0200320Perform card reset and display the card ATR.
321
Harald Weltebd02f842021-10-21 14:40:39 +0200322intro
323~~~~~
324[Re-]Display the introductory banner
325
326
327equip
328~~~~~
329Equip pySim-shell with a card; particularly useful if the program was
330started before a card was present, or after a card has been replaced by
331the user while pySim-shell was kept running.
332
333bulk_script
334~~~~~~~~~~~
335.. argparse::
336 :module: pySim-shell
337 :func: PysimApp.bulk_script_parser
338
Harald Weltebd02f842021-10-21 14:40:39 +0200339
340echo
341~~~~
342.. argparse::
343 :module: pySim-shell
344 :func: PysimApp.echo_parser
345
346
Harald Welte12af7932022-02-15 16:39:08 +0100347apdu
348~~~~
349.. argparse::
350 :module: pySim-shell
Harald Welte91eeecf2023-10-23 22:26:06 +0200351 :func: PysimApp.apdu_cmd_parser
Harald Welte12af7932022-02-15 16:39:08 +0100352
353
Harald Weltedaf2b392021-05-03 23:17:29 +0200354
Harald Weltebe9516f2021-04-03 11:30:10 +0200355Linear Fixed EF commands
356------------------------
357
358These commands become enabled only when your currently selected file is of *Linear Fixed EF* type.
359
360read_record
361~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200362.. argparse::
363 :module: pySim.filesystem
364 :func: LinFixedEF.ShellCommands.read_rec_parser
365
Harald Weltebe9516f2021-04-03 11:30:10 +0200366
367read_record_decoded
368~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200369.. argparse::
370 :module: pySim.filesystem
371 :func: LinFixedEF.ShellCommands.read_rec_dec_parser
372
Harald Weltebe9516f2021-04-03 11:30:10 +0200373
Harald Welte850b72a2021-04-07 09:33:03 +0200374read_records
375~~~~~~~~~~~~
376.. argparse::
377 :module: pySim.filesystem
378 :func: LinFixedEF.ShellCommands.read_recs_parser
379
380
381read_records_decoded
382~~~~~~~~~~~~~~~~~~~~
383.. argparse::
384 :module: pySim.filesystem
385 :func: LinFixedEF.ShellCommands.read_recs_dec_parser
386
387
Harald Weltebe9516f2021-04-03 11:30:10 +0200388update_record
389~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200390.. argparse::
391 :module: pySim.filesystem
392 :func: LinFixedEF.ShellCommands.upd_rec_parser
393
Harald Weltebe9516f2021-04-03 11:30:10 +0200394
395update_record_decoded
396~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200397.. argparse::
398 :module: pySim.filesystem
399 :func: LinFixedEF.ShellCommands.upd_rec_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200400
401
Harald Welte4145d3c2021-04-08 20:34:13 +0200402edit_record_decoded
403~~~~~~~~~~~~~~~~~~~
404.. argparse::
405 :module: pySim.filesystem
406 :func: LinFixedEF.ShellCommands.edit_rec_dec_parser
407
408This command will read the selected record, decode it to its JSON representation, save
409that JSON to a temporary file on your computer, and launch your configured text editor.
410
411You may then perform whatever modifications to the JSON representation, save + leave your
412text editor.
413
414Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
415back to the record on the SIM card.
416
417This allows for easy interactive modification of records.
418
419
Harald Welteaefd0642022-02-25 15:26:37 +0100420decode_hex
421~~~~~~~~~~
422.. argparse::
423 :module: pySim.filesystem
424 :func: LinFixedEF.ShellCommands.dec_hex_parser
425
426
Harald Weltebe9516f2021-04-03 11:30:10 +0200427
428Transparent EF commands
429-----------------------
430
431These commands become enabled only when your currently selected file is of *Transparent EF* type.
432
433
434read_binary
435~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200436.. argparse::
437 :module: pySim.filesystem
438 :func: TransparentEF.ShellCommands.read_bin_parser
439
Harald Weltebe9516f2021-04-03 11:30:10 +0200440
441read_binary_decoded
442~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200443.. argparse::
444 :module: pySim.filesystem
445 :func: TransparentEF.ShellCommands.read_bin_dec_parser
446
Harald Weltebe9516f2021-04-03 11:30:10 +0200447
448update_binary
449~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200450.. argparse::
451 :module: pySim.filesystem
452 :func: TransparentEF.ShellCommands.upd_bin_parser
453
Harald Weltebe9516f2021-04-03 11:30:10 +0200454
455update_binary_decoded
456~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200457.. argparse::
458 :module: pySim.filesystem
459 :func: TransparentEF.ShellCommands.upd_bin_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200460
Harald Welte0d4e98a2021-04-07 00:14:40 +0200461In normal operation, update_binary_decoded needs a JSON document representing the entire file contents as
462input. This can be inconvenient if you want to keep 99% of the content but just toggle one specific
463parameter. That's where the JSONpath support comes in handy: You can specify a JSONpath to an element
464inside the document as well as a new value for tat field:
465
466Th below example demonstrates this by modifying the ofm field within EF.AD:
467
468::
469
Harald Welte237ddb52023-10-22 10:36:58 +0200470 pySIM-shell (00:MF/ADF.USIM/EF.AD)> read_binary_decoded
Harald Welte0d4e98a2021-04-07 00:14:40 +0200471 {
472 "ms_operation_mode": "normal",
473 "specific_facilities": {
474 "ofm": true
475 },
476 "len_of_mnc_in_imsi": 2
477 }
Harald Welte237ddb52023-10-22 10:36:58 +0200478 pySIM-shell (00:MF/ADF.USIM/EF.AD)> update_binary_decoded --json-path specific_facilities.ofm false
479 pySIM-shell (00:MF/ADF.USIM/EF.AD)> read_binary_decoded
Harald Welte0d4e98a2021-04-07 00:14:40 +0200480 {
481 "ms_operation_mode": "normal",
482 "specific_facilities": {
483 "ofm": false
484 },
485 "len_of_mnc_in_imsi": 2
486 }
487
Harald Weltebe9516f2021-04-03 11:30:10 +0200488
Harald Welte4145d3c2021-04-08 20:34:13 +0200489edit_binary_decoded
490~~~~~~~~~~~~~~~~~~~
491This command will read the selected binary EF, decode it to its JSON representation, save
492that JSON to a temporary file on your computer, and launch your configured text editor.
493
494You may then perform whatever modifications to the JSON representation, save + leave your
495text editor.
496
497Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
498to the SIM card.
499
500This allows for easy interactive modification of file contents.
501
Harald Weltebe9516f2021-04-03 11:30:10 +0200502
Harald Welteaefd0642022-02-25 15:26:37 +0100503decode_hex
504~~~~~~~~~~
505.. argparse::
506 :module: pySim.filesystem
507 :func: TransparentEF.ShellCommands.dec_hex_parser
508
509
Harald Welte917d98c2021-04-21 11:51:25 +0200510
511BER-TLV EF commands
512-------------------
513
514BER-TLV EFs are files that contain BER-TLV structured data. Every file can contain any number
515of variable-length IEs (DOs). The tag within a BER-TLV EF must be unique within the file.
516
517The commands below become enabled only when your currently selected file is of *BER-TLV EF* type.
518
519retrieve_tags
520~~~~~~~~~~~~~
521
522Retrieve a list of all tags present in the currently selected file.
523
524
525retrieve_data
526~~~~~~~~~~~~~
527.. argparse::
528 :module: pySim.filesystem
529 :func: BerTlvEF.ShellCommands.retrieve_data_parser
530
531
532set_data
533~~~~~~~~
534.. argparse::
535 :module: pySim.filesystem
536 :func: BerTlvEF.ShellCommands.set_data_parser
537
538
539del_data
540~~~~~~~~
541.. argparse::
542 :module: pySim.filesystem
543 :func: BerTlvEF.ShellCommands.del_data_parser
544
545
546
Harald Welte15fae982021-04-10 10:22:27 +0200547USIM commands
548-------------
549
Harald Welte577312a2023-02-23 09:51:30 +0100550These commands are available only while ADF.USIM (or ADF.ISIM, respectively) is selected.
551
Harald Welte15fae982021-04-10 10:22:27 +0200552authenticate
553~~~~~~~~~~~~
554.. argparse::
555 :module: pySim.ts_31_102
556 :func: ADF_USIM.AddlShellCommands.authenticate_parser
557
Harald Welte12af7932022-02-15 16:39:08 +0100558terminal_profile
559~~~~~~~~~~~~~~~~
560.. argparse::
561 :module: pySim.ts_31_102
562 :func: ADF_USIM.AddlShellCommands.term_prof_parser
563
564envelope
565~~~~~~~~
566.. argparse::
567 :module: pySim.ts_31_102
568 :func: ADF_USIM.AddlShellCommands.envelope_parser
569
570envelope_sms
571~~~~~~~~~~~~
572.. argparse::
573 :module: pySim.ts_31_102
574 :func: ADF_USIM.AddlShellCommands.envelope_sms_parser
575
Harald Welte7ec82232023-06-06 18:15:52 +0200576get_identity
577~~~~~~~~~~~~
578.. argparse::
579 :module: pySim.ts_31_102
580 :func: ADF_USIM.AddlShellCommands.get_id_parser
581
Harald Welte12af7932022-02-15 16:39:08 +0100582
Harald Welte577312a2023-02-23 09:51:30 +0100583File-specific commands
584----------------------
585
586These commands are valid only if the respective file is currently selected. They perform some
587operation that's specific to this file only.
588
589EF.ARR: read_arr_record
590~~~~~~~~~~~~~~~~~~~~~~~
591Read one EF.ARR record in flattened, human-friendly form.
592
593EF.ARR: read_arr_records
594~~~~~~~~~~~~~~~~~~~~~~~~
595Read + decode all EF.ARR records in flattened, human-friendly form.
596
Harald Weltec224b3b2023-05-23 18:44:44 +0200597DF.GSM/EF.SST: sst_service_allocate
598~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
599Mark a given single service as allocated in EF.SST. Requires service number as argument.
600
601DF.GSM/EF.SST: sst_service_activate
602~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
603Mark a given single service as activated in EF.SST. Requires service number as argument.
604
605DF.GSM/EF.SST: sst_service_deallocate
606~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
607Mark a given single service as deallocated in EF.SST. Requires service number as argument.
608
609DF.GSM/EF.SST: sst_service_deactivate
610~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
611Mark a given single service as deactivated in EF.SST. Requires service number as argument.
612
Harald Weltea07d5092023-02-23 10:02:49 +0100613ADF.USIM/EF.EST: est_service_enable
614~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
615Enables a single service in EF.EST. Requires service number as argument.
616
617ADF.USIM/EF.EST: est_service_disable
618~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
619Disables a single service in EF.EST. Requires service number as argument.
620
Harald Welte577312a2023-02-23 09:51:30 +0100621EF.IMSI: update_imsi_plmn
622~~~~~~~~~~~~~~~~~~~~~~~~~
623Change the PLMN part (MCC+MNC) of the IMSI. Requires a single argument consisting of 5/6 digits of
624concatenated MCC+MNC.
625
626ADF.USIM/EF.UST: ust_service_activate
627~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
628Activates a single service in EF.UST. Requires service number as argument.
629
630ADF.USIM/EF.UST: ust_service_deactivate
631~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
632Deactivates a single service in EF.UST. Requires service number as argument.
633
634ADF.USIM/EF.UST: ust_service_check
635~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
636Check consistency between services of this file and files present/activated.
637Many services determine if one or multiple files shall be present/activated or if they shall be
638absent/deactivated. This performs a consistency check to ensure that no services are activated
639for files that are not - and vice-versa, no files are activated for services that are not. Error
640messages are printed for every inconsistency found.
641
642ADF.ISIM/EF.IST: ist_service_activate
643~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
644Activates a single service in EF.IST. Requires service number as argument.
645
646ADF.ISIM/EF.IST: ist_service_deactivate
647~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
648Deactivates a single service in EF.UST. Requires service number as argument.
649
650ADF.ISIM/EF.IST: ist_service_check
651~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
652Check consistency between services of this file and files present/activated.
653Many services determine if one or multiple files shall be present/activated or if they shall be
654absent/deactivated. This performs a consistency check to ensure that no services are activated
655for files that are not - and vice-versa, no files are activated for services that are not. Error
656messages are printed for every inconsistency found.
657
658
659UICC Administrative commands
660----------------------------
661
662ETSI TS 102 222 specifies a set of *Administrative Commands*, which can
663be used by the card issuer / operator to modify the file system structure
664(delete files, create files) or even to terminate individual files or the
665entire card.
666
667pySim-shell supports those commands, but **use extreme caution**.
668Unless you know exactly what you're doing, it's very easy to render your
669card unusable. You've been warned!
670
671delete_file
672~~~~~~~~~~~
673.. argparse::
674 :module: pySim.ts_102_222
675 :func: Ts102222Commands.delfile_parser
676
677
678terminate_df
679~~~~~~~~~~~~
680.. argparse::
681 :module: pySim.ts_102_222
682 :func: Ts102222Commands.termdf_parser
683
684terminate_ef
685~~~~~~~~~~~~
686.. argparse::
687 :module: pySim.ts_102_222
688 :func: Ts102222Commands.termdf_parser
689
690terminate_card
691~~~~~~~~~~~~~~
692.. argparse::
693 :module: pySim.ts_102_222
694 :func: Ts102222Commands.tcard_parser
695
696create_ef
697~~~~~~~~~
698.. argparse::
699 :module: pySim.ts_102_222
700 :func: Ts102222Commands.create_parser
701
702create_df
703~~~~~~~~~
704.. argparse::
705 :module: pySim.ts_102_222
706 :func: Ts102222Commands.createdf_parser
Harald Welte12af7932022-02-15 16:39:08 +0100707
Harald Welte0707b802023-03-07 11:43:37 +0100708resize_ef
709~~~~~~~~~
710.. argparse::
711 :module: pySim.ts_102_222
712 :func: Ts102222Commands.resize_ef_parser
713
Harald Welte15fae982021-04-10 10:22:27 +0200714
Harald Welte95ce6b12021-10-20 18:40:54 +0200715ARA-M commands
716--------------
717
718The ARA-M commands exist to manage the access rules stored in an ARA-M applet on the card.
719
720ARA-M in the context of SIM cards is primarily used to enable Android UICC Carrier Privileges,
721please see https://source.android.com/devices/tech/config/uicc for more details on the background.
722
723
724aram_get_all
725~~~~~~~~~~~~
726
727Obtain and decode all access rules from the ARA-M applet on the card.
728
729NOTE: if the total size of the access rules exceeds 255 bytes, this command will fail, as
730it doesn't yet implement fragmentation/reassembly on rule retrieval. YMMV
731
732::
733
Harald Welte237ddb52023-10-22 10:36:58 +0200734 pySIM-shell (00:MF/ADF.ARA-M)> aram_get_all
Harald Welte95ce6b12021-10-20 18:40:54 +0200735 [
736 {
737 "ResponseAllRefArDO": [
738 {
739 "RefArDO": [
740 {
741 "RefDO": [
742 {
743 "AidRefDO": "ffffffffffff"
744 },
745 {
746 "DevAppIdRefDO": "e46872f28b350b7e1f140de535c2a8d5804f0be3"
747 }
748 ]
749 },
750 {
751 "ArDO": [
752 {
753 "ApduArDO": {
754 "generic_access_rule": "always"
755 }
756 },
757 {
758 "PermArDO": {
759 "permissions": "0000000000000001"
760 }
761 }
762 ]
763 }
764 ]
765 }
766 ]
767 }
768 ]
769
770aram_get_config
771~~~~~~~~~~~~~~~
772Perform Config handshake with ARA-M applet: Tell it our version and retrieve its version.
773
774NOTE: Not supported in all ARA-M implementations.
775
Harald Welte95ce6b12021-10-20 18:40:54 +0200776
777aram_store_ref_ar_do
778~~~~~~~~~~~~~~~~~~~~
Harald Welte95ce6b12021-10-20 18:40:54 +0200779.. argparse::
780 :module: pySim.ara_m
781 :func: ADF_ARAM.AddlShellCommands.store_ref_ar_do_parse
782
783For example, to store an Android UICC carrier privilege rule for the SHA1 hash of the certificate used to sign the CoIMS android app of Supreeth Herle (https://github.com/herlesupreeth/CoIMS_Wiki) you can use the following command:
Harald Welte95ce6b12021-10-20 18:40:54 +0200784::
785
Harald Welte237ddb52023-10-22 10:36:58 +0200786 pySIM-shell (00:MF/ADF.ARA-M)> aram_store_ref_ar_do --aid FFFFFFFFFFFF --device-app-id E46872F28B350B7E1F140DE535C2A8D5804F0BE3 --android-permissions 0000000000000001 --apdu-always
Harald Welte95ce6b12021-10-20 18:40:54 +0200787
788
789aram_delete_all
790~~~~~~~~~~~~~~~
791This command will request deletion of all access rules stored within the
792ARA-M applet. Use it with caution, there is no undo. Any rules later
793intended must be manually inserted again using `aram_store_ref_ar_do`
794
795
Harald Welte577312a2023-02-23 09:51:30 +0100796GlobalPlatform commands
797-----------------------
798
799pySim-shell has only the mots rudimentary support for GlobalPlatform at this point. Please use dedicated
800projects like GlobalPlatformPro meanwhile.
801
802get_data
803~~~~~~~~
Harald Weltefdcf3c52023-07-11 08:52:39 +0200804.. argparse::
805 :module: pySim.global_platform
806 :func: ADF_SD.AddlShellCommands.get_data_parser
Harald Welte15fae982021-04-10 10:22:27 +0200807
Harald Weltebe9516f2021-04-03 11:30:10 +0200808cmd2 settable parameters
809------------------------
810
811``cmd2`` has the concept of *settable parameters* which act a bit like environment variables in an OS-level
812shell: They can be read and set, and they will influence the behavior somehow.
813
814conserve_write
815~~~~~~~~~~~~~~
816
817If enabled, pySim will (when asked to write to a card) always first read the respective file/record and
818verify if the to-be-written value differs from the current on-card value. If not, the write will be skipped.
819Writes will only be performed if the new value is different from the current on-card value.
820
821If disabled, pySim will always write irrespective of the current/new value.
822
Harald Welte1748b932021-04-06 21:12:25 +0200823json_pretty_print
824~~~~~~~~~~~~~~~~~
825
826This parameter determines if generated JSON output should (by default) be pretty-printed (multi-line
827output with indent level of 4 spaces) or not.
828
829The default value of this parameter is 'true'.
830
Harald Weltebe9516f2021-04-03 11:30:10 +0200831debug
832~~~~~
833
834If enabled, full python back-traces will be displayed in case of exceptions
835
Harald Welte7829d8a2021-04-10 11:28:53 +0200836apdu_trace
837~~~~~~~~~~
838
839Boolean variable that determines if a hex-dump of the command + response APDU shall be printed.
840
Harald Weltebe9516f2021-04-03 11:30:10 +0200841numeric_path
842~~~~~~~~~~~~
843
844Boolean variable that determines if path (e.g. in prompt) is displayed with numeric FIDs or string names.
845
846::
847
Harald Welte237ddb52023-10-22 10:36:58 +0200848 pySIM-shell (00:MF/EF.ICCID)> set numeric_path True
Harald Weltebe9516f2021-04-03 11:30:10 +0200849 numeric_path - was: False
850 now: True
Harald Welte237ddb52023-10-22 10:36:58 +0200851 pySIM-shell (00:3f00/2fe2)> set numeric_path False
Harald Weltebe9516f2021-04-03 11:30:10 +0200852 numeric_path - was: True
853 now: False
Harald Welte237ddb52023-10-22 10:36:58 +0200854 pySIM-shell (00:MF/EF.ICCID)> help set