blob: ef08fcf17b224703628ebeddfe19924f213c83e9 [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
71 pySIM-shell (MF)> select
72 .. 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
88 pySIM-shell (MF)> select ADF.USIM
89 {
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 }
106 pySIM-shell (MF/ADF.USIM)>
107
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
119 pySIM-shell (MF/ADF.ISIM)> status
120 {
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 Weltebe9516f2021-04-03 11:30:10 +0200202
Harald Welte659781c2023-06-06 17:00:51 +0200203TS 102 221 commands
204-------------------
205
206These are commands as specified in ETSI TS 102 221, the core UICC specification.
207
Harald Welteec950532021-10-20 13:09:00 +0200208suspend_uicc
209~~~~~~~~~~~~
210This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
211recent power-saving addition to the UICC specifications, allowing for suspend/resume while maintaining
212state, as opposed to a full power-off (deactivate) and power-on (activate) of the card.
213
214The pySim command just sends that SUSPEND UICC command and doesn't perform the full related sequence
215including the electrical power down.
216
217.. argparse::
Harald Welte659781c2023-06-06 17:00:51 +0200218 :module: pySim.ts_102_221
219 :func: CardProfileUICC.AddlShellCommands.suspend_uicc_parser
Harald Welteec950532021-10-20 13:09:00 +0200220
Harald Welteb0e0dce2023-06-06 17:21:13 +0200221resume_uicc
222~~~~~~~~~~~
223This command allows you to perform the SUSPEND UICC command for the RESUME operation on the card.
224
225Suspend/Resume is a relatively recent power-saving addition to the UICC specifications, allowing for
226suspend/resume while maintaining state, as opposed to a full power-off (deactivate) and power-on
227(activate) of the card.
228
229The pySim command just sends that SUSPEND UICC (RESUME) command and doesn't perform the full related
230sequence including the electrical power down.
231
232.. argparse::
233 :module: pySim.ts_102_221
234 :func: CardProfileUICC.AddlShellCommands.resume_uicc_parser
Harald Welteec950532021-10-20 13:09:00 +0200235
Harald Welte12af7932022-02-15 16:39:08 +0100236
Harald Weltebe9516f2021-04-03 11:30:10 +0200237pySim commands
238--------------
239
240Commands in this category are pySim specific; they do not have a 1:1 correspondence to ISO 7816
241or 3GPP commands. Mostly they will operate either only on local (in-memory) state, or execute
242a complex sequence of card-commands.
243
244desc
245~~~~
Harald Weltebe9516f2021-04-03 11:30:10 +0200246Display human readable file description for the currently selected file.
247
248
249dir
250~~~
Harald Welted36f6942021-04-04 14:37:55 +0200251.. argparse::
252 :module: pySim-shell
253 :func: PySimCommands.dir_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200254
Harald Welte12af7932022-02-15 16:39:08 +0100255Example:
256::
257
258 pySIM-shell (MF)> dir
259 MF
260 3f00
261 .. ADF.USIM DF.SYSTEM EF.DIR EF.UMPC
262 ADF.ARA-M DF.EIRENE DF.TELECOM EF.ICCID MF
263 ADF.ISIM DF.GSM EF.ARR EF.PL
264 14 files
265
Harald Weltebe9516f2021-04-03 11:30:10 +0200266
267export
268~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200269.. argparse::
270 :module: pySim-shell
271 :func: PySimCommands.export_parser
272
Harald Weltebd02f842021-10-21 14:40:39 +0200273Please note that `export` works relative to the current working
274directory, so if you are in `MF`, then the export will contain all known
275files on the card. However, if you are in `ADF.ISIM`, only files below
276that ADF will be part of the export.
277
278Furthermore, it is strongly advised to first enter the ADM1 pin
279(`verify_adm`) to maximize the chance of having permission to read
280all/most files.
281
Harald Weltebe9516f2021-04-03 11:30:10 +0200282
283tree
284~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200285Display a tree of the card filesystem. It is important to note that this displays a tree
286of files that might potentially exist (based on the card profile). In order to determine if
287a given file really exists on a given card, you have to try to select that file.
Harald Welted36f6942021-04-04 14:37:55 +0200288
Harald Welte12af7932022-02-15 16:39:08 +0100289Example:
290::
291
292 pySIM-shell (MF)> tree --help
293 EF.DIR 2f00 Application Directory
294 EF.ICCID 2fe2 ICC Identification
295 EF.PL 2f05 Preferred Languages
296 EF.ARR 2f06 Access Rule Reference
297 EF.UMPC 2f08 UICC Maximum Power Consumption
298 DF.TELECOM 7f10 None
299 EF.ADN 6f3a Abbreviated Dialing Numbers
300 ...
301
302
Harald Weltebe9516f2021-04-03 11:30:10 +0200303
304verify_adm
305~~~~~~~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200306Verify the ADM (Administrator) PIN specified as argument. This is typically needed in order
307to get write/update permissions to most of the files on SIM cards.
308
309Currently only ADM1 is supported.
Harald Weltebe9516f2021-04-03 11:30:10 +0200310
311
Harald Weltedaf2b392021-05-03 23:17:29 +0200312reset
313~~~~~
Harald Weltedaf2b392021-05-03 23:17:29 +0200314Perform card reset and display the card ATR.
315
Harald Weltebd02f842021-10-21 14:40:39 +0200316intro
317~~~~~
318[Re-]Display the introductory banner
319
320
321equip
322~~~~~
323Equip pySim-shell with a card; particularly useful if the program was
324started before a card was present, or after a card has been replaced by
325the user while pySim-shell was kept running.
326
327bulk_script
328~~~~~~~~~~~
329.. argparse::
330 :module: pySim-shell
331 :func: PysimApp.bulk_script_parser
332
Harald Weltebd02f842021-10-21 14:40:39 +0200333
334echo
335~~~~
336.. argparse::
337 :module: pySim-shell
338 :func: PysimApp.echo_parser
339
340
Harald Welte12af7932022-02-15 16:39:08 +0100341apdu
342~~~~
343.. argparse::
344 :module: pySim-shell
345 :func: PySimCommands.apdu_cmd_parser
346
347
Harald Weltedaf2b392021-05-03 23:17:29 +0200348
Harald Weltebe9516f2021-04-03 11:30:10 +0200349Linear Fixed EF commands
350------------------------
351
352These commands become enabled only when your currently selected file is of *Linear Fixed EF* type.
353
354read_record
355~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200356.. argparse::
357 :module: pySim.filesystem
358 :func: LinFixedEF.ShellCommands.read_rec_parser
359
Harald Weltebe9516f2021-04-03 11:30:10 +0200360
361read_record_decoded
362~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200363.. argparse::
364 :module: pySim.filesystem
365 :func: LinFixedEF.ShellCommands.read_rec_dec_parser
366
Harald Weltebe9516f2021-04-03 11:30:10 +0200367
Harald Welte850b72a2021-04-07 09:33:03 +0200368read_records
369~~~~~~~~~~~~
370.. argparse::
371 :module: pySim.filesystem
372 :func: LinFixedEF.ShellCommands.read_recs_parser
373
374
375read_records_decoded
376~~~~~~~~~~~~~~~~~~~~
377.. argparse::
378 :module: pySim.filesystem
379 :func: LinFixedEF.ShellCommands.read_recs_dec_parser
380
381
Harald Weltebe9516f2021-04-03 11:30:10 +0200382update_record
383~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200384.. argparse::
385 :module: pySim.filesystem
386 :func: LinFixedEF.ShellCommands.upd_rec_parser
387
Harald Weltebe9516f2021-04-03 11:30:10 +0200388
389update_record_decoded
390~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200391.. argparse::
392 :module: pySim.filesystem
393 :func: LinFixedEF.ShellCommands.upd_rec_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200394
395
Harald Welte4145d3c2021-04-08 20:34:13 +0200396edit_record_decoded
397~~~~~~~~~~~~~~~~~~~
398.. argparse::
399 :module: pySim.filesystem
400 :func: LinFixedEF.ShellCommands.edit_rec_dec_parser
401
402This command will read the selected record, decode it to its JSON representation, save
403that JSON to a temporary file on your computer, and launch your configured text editor.
404
405You may then perform whatever modifications to the JSON representation, save + leave your
406text editor.
407
408Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
409back to the record on the SIM card.
410
411This allows for easy interactive modification of records.
412
413
Harald Welteaefd0642022-02-25 15:26:37 +0100414decode_hex
415~~~~~~~~~~
416.. argparse::
417 :module: pySim.filesystem
418 :func: LinFixedEF.ShellCommands.dec_hex_parser
419
420
Harald Weltebe9516f2021-04-03 11:30:10 +0200421
422Transparent EF commands
423-----------------------
424
425These commands become enabled only when your currently selected file is of *Transparent EF* type.
426
427
428read_binary
429~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200430.. argparse::
431 :module: pySim.filesystem
432 :func: TransparentEF.ShellCommands.read_bin_parser
433
Harald Weltebe9516f2021-04-03 11:30:10 +0200434
435read_binary_decoded
436~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200437.. argparse::
438 :module: pySim.filesystem
439 :func: TransparentEF.ShellCommands.read_bin_dec_parser
440
Harald Weltebe9516f2021-04-03 11:30:10 +0200441
442update_binary
443~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200444.. argparse::
445 :module: pySim.filesystem
446 :func: TransparentEF.ShellCommands.upd_bin_parser
447
Harald Weltebe9516f2021-04-03 11:30:10 +0200448
449update_binary_decoded
450~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200451.. argparse::
452 :module: pySim.filesystem
453 :func: TransparentEF.ShellCommands.upd_bin_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200454
Harald Welte0d4e98a2021-04-07 00:14:40 +0200455In normal operation, update_binary_decoded needs a JSON document representing the entire file contents as
456input. This can be inconvenient if you want to keep 99% of the content but just toggle one specific
457parameter. That's where the JSONpath support comes in handy: You can specify a JSONpath to an element
458inside the document as well as a new value for tat field:
459
460Th below example demonstrates this by modifying the ofm field within EF.AD:
461
462::
463
464 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
465 {
466 "ms_operation_mode": "normal",
467 "specific_facilities": {
468 "ofm": true
469 },
470 "len_of_mnc_in_imsi": 2
471 }
472 pySIM-shell (MF/ADF.USIM/EF.AD)> update_binary_decoded --json-path specific_facilities.ofm false
473 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
474 {
475 "ms_operation_mode": "normal",
476 "specific_facilities": {
477 "ofm": false
478 },
479 "len_of_mnc_in_imsi": 2
480 }
481
Harald Weltebe9516f2021-04-03 11:30:10 +0200482
Harald Welte4145d3c2021-04-08 20:34:13 +0200483edit_binary_decoded
484~~~~~~~~~~~~~~~~~~~
485This command will read the selected binary EF, decode it to its JSON representation, save
486that JSON to a temporary file on your computer, and launch your configured text editor.
487
488You may then perform whatever modifications to the JSON representation, save + leave your
489text editor.
490
491Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
492to the SIM card.
493
494This allows for easy interactive modification of file contents.
495
Harald Weltebe9516f2021-04-03 11:30:10 +0200496
Harald Welteaefd0642022-02-25 15:26:37 +0100497decode_hex
498~~~~~~~~~~
499.. argparse::
500 :module: pySim.filesystem
501 :func: TransparentEF.ShellCommands.dec_hex_parser
502
503
Harald Welte917d98c2021-04-21 11:51:25 +0200504
505BER-TLV EF commands
506-------------------
507
508BER-TLV EFs are files that contain BER-TLV structured data. Every file can contain any number
509of variable-length IEs (DOs). The tag within a BER-TLV EF must be unique within the file.
510
511The commands below become enabled only when your currently selected file is of *BER-TLV EF* type.
512
513retrieve_tags
514~~~~~~~~~~~~~
515
516Retrieve a list of all tags present in the currently selected file.
517
518
519retrieve_data
520~~~~~~~~~~~~~
521.. argparse::
522 :module: pySim.filesystem
523 :func: BerTlvEF.ShellCommands.retrieve_data_parser
524
525
526set_data
527~~~~~~~~
528.. argparse::
529 :module: pySim.filesystem
530 :func: BerTlvEF.ShellCommands.set_data_parser
531
532
533del_data
534~~~~~~~~
535.. argparse::
536 :module: pySim.filesystem
537 :func: BerTlvEF.ShellCommands.del_data_parser
538
539
540
Harald Welte15fae982021-04-10 10:22:27 +0200541USIM commands
542-------------
543
Harald Welte577312a2023-02-23 09:51:30 +0100544These commands are available only while ADF.USIM (or ADF.ISIM, respectively) is selected.
545
Harald Welte15fae982021-04-10 10:22:27 +0200546authenticate
547~~~~~~~~~~~~
548.. argparse::
549 :module: pySim.ts_31_102
550 :func: ADF_USIM.AddlShellCommands.authenticate_parser
551
Harald Welte12af7932022-02-15 16:39:08 +0100552terminal_profile
553~~~~~~~~~~~~~~~~
554.. argparse::
555 :module: pySim.ts_31_102
556 :func: ADF_USIM.AddlShellCommands.term_prof_parser
557
558envelope
559~~~~~~~~
560.. argparse::
561 :module: pySim.ts_31_102
562 :func: ADF_USIM.AddlShellCommands.envelope_parser
563
564envelope_sms
565~~~~~~~~~~~~
566.. argparse::
567 :module: pySim.ts_31_102
568 :func: ADF_USIM.AddlShellCommands.envelope_sms_parser
569
Harald Welte7ec82232023-06-06 18:15:52 +0200570get_identity
571~~~~~~~~~~~~
572.. argparse::
573 :module: pySim.ts_31_102
574 :func: ADF_USIM.AddlShellCommands.get_id_parser
575
Harald Welte12af7932022-02-15 16:39:08 +0100576
Harald Welte577312a2023-02-23 09:51:30 +0100577File-specific commands
578----------------------
579
580These commands are valid only if the respective file is currently selected. They perform some
581operation that's specific to this file only.
582
583EF.ARR: read_arr_record
584~~~~~~~~~~~~~~~~~~~~~~~
585Read one EF.ARR record in flattened, human-friendly form.
586
587EF.ARR: read_arr_records
588~~~~~~~~~~~~~~~~~~~~~~~~
589Read + decode all EF.ARR records in flattened, human-friendly form.
590
Harald Weltec224b3b2023-05-23 18:44:44 +0200591DF.GSM/EF.SST: sst_service_allocate
592~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
593Mark a given single service as allocated in EF.SST. Requires service number as argument.
594
595DF.GSM/EF.SST: sst_service_activate
596~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
597Mark a given single service as activated in EF.SST. Requires service number as argument.
598
599DF.GSM/EF.SST: sst_service_deallocate
600~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601Mark a given single service as deallocated in EF.SST. Requires service number as argument.
602
603DF.GSM/EF.SST: sst_service_deactivate
604~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
605Mark a given single service as deactivated in EF.SST. Requires service number as argument.
606
Harald Weltea07d5092023-02-23 10:02:49 +0100607ADF.USIM/EF.EST: est_service_enable
608~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
609Enables a single service in EF.EST. Requires service number as argument.
610
611ADF.USIM/EF.EST: est_service_disable
612~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
613Disables a single service in EF.EST. Requires service number as argument.
614
Harald Welte577312a2023-02-23 09:51:30 +0100615EF.IMSI: update_imsi_plmn
616~~~~~~~~~~~~~~~~~~~~~~~~~
617Change the PLMN part (MCC+MNC) of the IMSI. Requires a single argument consisting of 5/6 digits of
618concatenated MCC+MNC.
619
620ADF.USIM/EF.UST: ust_service_activate
621~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
622Activates a single service in EF.UST. Requires service number as argument.
623
624ADF.USIM/EF.UST: ust_service_deactivate
625~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
626Deactivates a single service in EF.UST. Requires service number as argument.
627
628ADF.USIM/EF.UST: ust_service_check
629~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
630Check consistency between services of this file and files present/activated.
631Many services determine if one or multiple files shall be present/activated or if they shall be
632absent/deactivated. This performs a consistency check to ensure that no services are activated
633for files that are not - and vice-versa, no files are activated for services that are not. Error
634messages are printed for every inconsistency found.
635
636ADF.ISIM/EF.IST: ist_service_activate
637~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
638Activates a single service in EF.IST. Requires service number as argument.
639
640ADF.ISIM/EF.IST: ist_service_deactivate
641~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
642Deactivates a single service in EF.UST. Requires service number as argument.
643
644ADF.ISIM/EF.IST: ist_service_check
645~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646Check consistency between services of this file and files present/activated.
647Many services determine if one or multiple files shall be present/activated or if they shall be
648absent/deactivated. This performs a consistency check to ensure that no services are activated
649for files that are not - and vice-versa, no files are activated for services that are not. Error
650messages are printed for every inconsistency found.
651
652
653UICC Administrative commands
654----------------------------
655
656ETSI TS 102 222 specifies a set of *Administrative Commands*, which can
657be used by the card issuer / operator to modify the file system structure
658(delete files, create files) or even to terminate individual files or the
659entire card.
660
661pySim-shell supports those commands, but **use extreme caution**.
662Unless you know exactly what you're doing, it's very easy to render your
663card unusable. You've been warned!
664
665delete_file
666~~~~~~~~~~~
667.. argparse::
668 :module: pySim.ts_102_222
669 :func: Ts102222Commands.delfile_parser
670
671
672terminate_df
673~~~~~~~~~~~~
674.. argparse::
675 :module: pySim.ts_102_222
676 :func: Ts102222Commands.termdf_parser
677
678terminate_ef
679~~~~~~~~~~~~
680.. argparse::
681 :module: pySim.ts_102_222
682 :func: Ts102222Commands.termdf_parser
683
684terminate_card
685~~~~~~~~~~~~~~
686.. argparse::
687 :module: pySim.ts_102_222
688 :func: Ts102222Commands.tcard_parser
689
690create_ef
691~~~~~~~~~
692.. argparse::
693 :module: pySim.ts_102_222
694 :func: Ts102222Commands.create_parser
695
696create_df
697~~~~~~~~~
698.. argparse::
699 :module: pySim.ts_102_222
700 :func: Ts102222Commands.createdf_parser
Harald Welte12af7932022-02-15 16:39:08 +0100701
Harald Welte0707b802023-03-07 11:43:37 +0100702resize_ef
703~~~~~~~~~
704.. argparse::
705 :module: pySim.ts_102_222
706 :func: Ts102222Commands.resize_ef_parser
707
Harald Welte15fae982021-04-10 10:22:27 +0200708
Harald Welte95ce6b12021-10-20 18:40:54 +0200709ARA-M commands
710--------------
711
712The ARA-M commands exist to manage the access rules stored in an ARA-M applet on the card.
713
714ARA-M in the context of SIM cards is primarily used to enable Android UICC Carrier Privileges,
715please see https://source.android.com/devices/tech/config/uicc for more details on the background.
716
717
718aram_get_all
719~~~~~~~~~~~~
720
721Obtain and decode all access rules from the ARA-M applet on the card.
722
723NOTE: if the total size of the access rules exceeds 255 bytes, this command will fail, as
724it doesn't yet implement fragmentation/reassembly on rule retrieval. YMMV
725
726::
727
728 pySIM-shell (MF/ADF.ARA-M)> aram_get_all
729 [
730 {
731 "ResponseAllRefArDO": [
732 {
733 "RefArDO": [
734 {
735 "RefDO": [
736 {
737 "AidRefDO": "ffffffffffff"
738 },
739 {
740 "DevAppIdRefDO": "e46872f28b350b7e1f140de535c2a8d5804f0be3"
741 }
742 ]
743 },
744 {
745 "ArDO": [
746 {
747 "ApduArDO": {
748 "generic_access_rule": "always"
749 }
750 },
751 {
752 "PermArDO": {
753 "permissions": "0000000000000001"
754 }
755 }
756 ]
757 }
758 ]
759 }
760 ]
761 }
762 ]
763
764aram_get_config
765~~~~~~~~~~~~~~~
766Perform Config handshake with ARA-M applet: Tell it our version and retrieve its version.
767
768NOTE: Not supported in all ARA-M implementations.
769
Harald Welte95ce6b12021-10-20 18:40:54 +0200770
771aram_store_ref_ar_do
772~~~~~~~~~~~~~~~~~~~~
Harald Welte95ce6b12021-10-20 18:40:54 +0200773.. argparse::
774 :module: pySim.ara_m
775 :func: ADF_ARAM.AddlShellCommands.store_ref_ar_do_parse
776
777For 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 +0200778::
779
780 pySIM-shell (MF/ADF.ARA-M)> aram_store_ref_ar_do --aid FFFFFFFFFFFF --device-app-id E46872F28B350B7E1F140DE535C2A8D5804F0BE3 --android-permissions 0000000000000001 --apdu-always
781
782
783aram_delete_all
784~~~~~~~~~~~~~~~
785This command will request deletion of all access rules stored within the
786ARA-M applet. Use it with caution, there is no undo. Any rules later
787intended must be manually inserted again using `aram_store_ref_ar_do`
788
789
Harald Welte577312a2023-02-23 09:51:30 +0100790GlobalPlatform commands
791-----------------------
792
793pySim-shell has only the mots rudimentary support for GlobalPlatform at this point. Please use dedicated
794projects like GlobalPlatformPro meanwhile.
795
796get_data
797~~~~~~~~
798Performs the GET DATA command as specified by GlobalPlatform.
799
Harald Welte15fae982021-04-10 10:22:27 +0200800
Harald Weltebe9516f2021-04-03 11:30:10 +0200801cmd2 settable parameters
802------------------------
803
804``cmd2`` has the concept of *settable parameters* which act a bit like environment variables in an OS-level
805shell: They can be read and set, and they will influence the behavior somehow.
806
807conserve_write
808~~~~~~~~~~~~~~
809
810If enabled, pySim will (when asked to write to a card) always first read the respective file/record and
811verify if the to-be-written value differs from the current on-card value. If not, the write will be skipped.
812Writes will only be performed if the new value is different from the current on-card value.
813
814If disabled, pySim will always write irrespective of the current/new value.
815
Harald Welte1748b932021-04-06 21:12:25 +0200816json_pretty_print
817~~~~~~~~~~~~~~~~~
818
819This parameter determines if generated JSON output should (by default) be pretty-printed (multi-line
820output with indent level of 4 spaces) or not.
821
822The default value of this parameter is 'true'.
823
Harald Weltebe9516f2021-04-03 11:30:10 +0200824debug
825~~~~~
826
827If enabled, full python back-traces will be displayed in case of exceptions
828
Harald Welte7829d8a2021-04-10 11:28:53 +0200829apdu_trace
830~~~~~~~~~~
831
832Boolean variable that determines if a hex-dump of the command + response APDU shall be printed.
833
Harald Weltebe9516f2021-04-03 11:30:10 +0200834numeric_path
835~~~~~~~~~~~~
836
837Boolean variable that determines if path (e.g. in prompt) is displayed with numeric FIDs or string names.
838
839::
840
841 pySIM-shell (MF/EF.ICCID)> set numeric_path True
842 numeric_path - was: False
843 now: True
844 pySIM-shell (3f00/2fe2)> set numeric_path False
845 numeric_path - was: True
846 now: False
847 pySIM-shell (MF/EF.ICCID)> help set