blob: cce790a2398c5c50e59845ffdec4cc0de85386e3 [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
38
Merlin Chlosta69b69d42023-05-11 12:59:01 +020039Usage Examples
40--------------
41.. toctree::
42 :maxdepth: 1
43 :caption: Tutorials for pySIM-shell:
44
45 suci-tutorial
Harald Weltef2e761c2021-04-11 11:56:44 +020046
Harald Weltebe9516f2021-04-03 11:30:10 +020047
48cmd2 basics
49-----------
50
51FIXME
52
53
54
55ISO7816 commands
56----------------
57
58This category of commands relates to commands that originate in the ISO 7861-4 specifications,
59most of them have a 1:1 resemblance in the specification.
60
61select
62~~~~~~
63
64The ``select`` command is used to select a file, either by its FID, AID or by its symbolic name.
65
66Try ``select`` with tab-completion to get a list of all current selectable items:
67
68::
69
70 pySIM-shell (MF)> select
71 .. 2fe2 a0000000871004 EF.ARR MF
72 2f00 3f00 ADF.ISIM EF.DIR
73 2f05 7f10 ADF.USIM EF.ICCID
74 2f06 7f20 DF.GSM EF.PL
75 2f08 a0000000871002 DF.TELECOM EF.UMPC
76
77Use ``select`` with a specific FID or name to select the new file.
78
79This will
80
81* output the [JSON decoded, if possible] select response
82* change the prompt to the newly selected file
83* enable any commands specific to the newly-selected file
84
85::
86
87 pySIM-shell (MF)> select ADF.USIM
88 {
89 "file_descriptor": {
Harald Welte747a9782022-02-13 17:52:28 +010090 "file_descriptor_byte": {
91 "shareable": true,
92 "file_type": "df",
93 "structure": "no_info_given"
94 }
Harald Weltebe9516f2021-04-03 11:30:10 +020095 },
96 "df_name": "A0000000871002FFFFFFFF8907090000",
97 "proprietary_info": {
98 "uicc_characteristics": "71",
99 "available_memory": 101640
100 },
101 "life_cycle_status_int": "operational_activated",
102 "security_attrib_compact": "00",
103 "pin_status_template_do": "90017083010183018183010A83010B"
104 }
105 pySIM-shell (MF/ADF.USIM)>
106
107
Harald Welted01bd362022-02-15 15:56:48 +0100108status
109~~~~~~
110
111The ``status`` command [re-]obtains the File Control Template of the
112currently-selected file and print its decoded output.
113
114Example:
115
116::
117
118 pySIM-shell (MF/ADF.ISIM)> status
119 {
120 "file_descriptor": {
121 "file_descriptor_byte": {
122 "shareable": true,
123 "file_type": "df",
124 "structure": "no_info_given"
125 },
126 "record_len": null,
127 "num_of_rec": null
128 },
129 "file_identifier": "ff01",
130 "df_name": "a0000000871004ffffffff8907090000",
131 "proprietary_information": {
132 "uicc_characteristics": "71",
133 "available_memory": 101640
134 },
135 "life_cycle_status_integer": "operational_activated",
136 "security_attrib_compact": "00",
137 "pin_status_template_do": {
138 "ps_do": "70",
139 "key_reference": 11
140 }
141 }
142
Harald Weltebe9516f2021-04-03 11:30:10 +0200143
144change_chv
145~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200146.. argparse::
147 :module: pySim-shell
148 :func: Iso7816Commands.change_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200149
150
151disable_chv
152~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200153.. argparse::
154 :module: pySim-shell
155 :func: Iso7816Commands.disable_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200156
Harald Weltebe9516f2021-04-03 11:30:10 +0200157
158enable_chv
159~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200160.. argparse::
161 :module: pySim-shell
162 :func: Iso7816Commands.enable_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200163
164
165unblock_chv
166~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200167.. argparse::
168 :module: pySim-shell
169 :func: Iso7816Commands.unblock_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200170
Harald Weltebe9516f2021-04-03 11:30:10 +0200171
172verify_chv
173~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200174.. argparse::
175 :module: pySim-shell
176 :func: Iso7816Commands.verify_chv_parser
177
Harald Weltea4631612021-04-10 18:17:55 +0200178deactivate_file
179~~~~~~~~~~~~~~~
180Deactivate the currently selected file. This used to be called INVALIDATE in TS 11.11.
181
182
183activate_file
184~~~~~~~~~~~~~
Harald Welte799c3542022-02-15 15:56:28 +0100185.. argparse::
186 :module: pySim-shell
187 :func: Iso7816Commands.activate_file_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200188
Harald Welte703f9332021-04-10 18:39:32 +0200189open_channel
190~~~~~~~~~~~~
191.. argparse::
192 :module: pySim-shell
193 :func: Iso7816Commands.open_chan_parser
194
195close_channel
196~~~~~~~~~~~~~
197.. argparse::
198 :module: pySim-shell
199 :func: Iso7816Commands.close_chan_parser
200
Harald Weltebe9516f2021-04-03 11:30:10 +0200201
Harald Welte659781c2023-06-06 17:00:51 +0200202TS 102 221 commands
203-------------------
204
205These are commands as specified in ETSI TS 102 221, the core UICC specification.
206
Harald Welteec950532021-10-20 13:09:00 +0200207suspend_uicc
208~~~~~~~~~~~~
209This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
210recent power-saving addition to the UICC specifications, allowing for suspend/resume while maintaining
211state, as opposed to a full power-off (deactivate) and power-on (activate) of the card.
212
213The pySim command just sends that SUSPEND UICC command and doesn't perform the full related sequence
214including the electrical power down.
215
216.. argparse::
Harald Welte659781c2023-06-06 17:00:51 +0200217 :module: pySim.ts_102_221
218 :func: CardProfileUICC.AddlShellCommands.suspend_uicc_parser
Harald Welteec950532021-10-20 13:09:00 +0200219
Harald Welteb0e0dce2023-06-06 17:21:13 +0200220resume_uicc
221~~~~~~~~~~~
222This command allows you to perform the SUSPEND UICC command for the RESUME operation on the card.
223
224Suspend/Resume is a relatively recent power-saving addition to the UICC specifications, allowing for
225suspend/resume while maintaining state, as opposed to a full power-off (deactivate) and power-on
226(activate) of the card.
227
228The pySim command just sends that SUSPEND UICC (RESUME) command and doesn't perform the full related
229sequence including the electrical power down.
230
231.. argparse::
232 :module: pySim.ts_102_221
233 :func: CardProfileUICC.AddlShellCommands.resume_uicc_parser
Harald Welteec950532021-10-20 13:09:00 +0200234
Harald Welte12af7932022-02-15 16:39:08 +0100235
Harald Weltebe9516f2021-04-03 11:30:10 +0200236pySim commands
237--------------
238
239Commands in this category are pySim specific; they do not have a 1:1 correspondence to ISO 7816
240or 3GPP commands. Mostly they will operate either only on local (in-memory) state, or execute
241a complex sequence of card-commands.
242
243desc
244~~~~
Harald Weltebe9516f2021-04-03 11:30:10 +0200245Display human readable file description for the currently selected file.
246
247
248dir
249~~~
Harald Welted36f6942021-04-04 14:37:55 +0200250.. argparse::
251 :module: pySim-shell
252 :func: PySimCommands.dir_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200253
Harald Welte12af7932022-02-15 16:39:08 +0100254Example:
255::
256
257 pySIM-shell (MF)> dir
258 MF
259 3f00
260 .. ADF.USIM DF.SYSTEM EF.DIR EF.UMPC
261 ADF.ARA-M DF.EIRENE DF.TELECOM EF.ICCID MF
262 ADF.ISIM DF.GSM EF.ARR EF.PL
263 14 files
264
Harald Weltebe9516f2021-04-03 11:30:10 +0200265
266export
267~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200268.. argparse::
269 :module: pySim-shell
270 :func: PySimCommands.export_parser
271
Harald Weltebd02f842021-10-21 14:40:39 +0200272Please note that `export` works relative to the current working
273directory, so if you are in `MF`, then the export will contain all known
274files on the card. However, if you are in `ADF.ISIM`, only files below
275that ADF will be part of the export.
276
277Furthermore, it is strongly advised to first enter the ADM1 pin
278(`verify_adm`) to maximize the chance of having permission to read
279all/most files.
280
Harald Weltebe9516f2021-04-03 11:30:10 +0200281
282tree
283~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200284Display a tree of the card filesystem. It is important to note that this displays a tree
285of files that might potentially exist (based on the card profile). In order to determine if
286a given file really exists on a given card, you have to try to select that file.
Harald Welted36f6942021-04-04 14:37:55 +0200287
Harald Welte12af7932022-02-15 16:39:08 +0100288Example:
289::
290
291 pySIM-shell (MF)> tree --help
292 EF.DIR 2f00 Application Directory
293 EF.ICCID 2fe2 ICC Identification
294 EF.PL 2f05 Preferred Languages
295 EF.ARR 2f06 Access Rule Reference
296 EF.UMPC 2f08 UICC Maximum Power Consumption
297 DF.TELECOM 7f10 None
298 EF.ADN 6f3a Abbreviated Dialing Numbers
299 ...
300
301
Harald Weltebe9516f2021-04-03 11:30:10 +0200302
303verify_adm
304~~~~~~~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200305Verify the ADM (Administrator) PIN specified as argument. This is typically needed in order
306to get write/update permissions to most of the files on SIM cards.
307
308Currently only ADM1 is supported.
Harald Weltebe9516f2021-04-03 11:30:10 +0200309
310
Harald Weltedaf2b392021-05-03 23:17:29 +0200311reset
312~~~~~
Harald Weltedaf2b392021-05-03 23:17:29 +0200313Perform card reset and display the card ATR.
314
Harald Weltebd02f842021-10-21 14:40:39 +0200315intro
316~~~~~
317[Re-]Display the introductory banner
318
319
320equip
321~~~~~
322Equip pySim-shell with a card; particularly useful if the program was
323started before a card was present, or after a card has been replaced by
324the user while pySim-shell was kept running.
325
326bulk_script
327~~~~~~~~~~~
328.. argparse::
329 :module: pySim-shell
330 :func: PysimApp.bulk_script_parser
331
Harald Weltebd02f842021-10-21 14:40:39 +0200332
333echo
334~~~~
335.. argparse::
336 :module: pySim-shell
337 :func: PysimApp.echo_parser
338
339
Harald Welte12af7932022-02-15 16:39:08 +0100340apdu
341~~~~
342.. argparse::
343 :module: pySim-shell
344 :func: PySimCommands.apdu_cmd_parser
345
346
Harald Weltedaf2b392021-05-03 23:17:29 +0200347
Harald Weltebe9516f2021-04-03 11:30:10 +0200348Linear Fixed EF commands
349------------------------
350
351These commands become enabled only when your currently selected file is of *Linear Fixed EF* type.
352
353read_record
354~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200355.. argparse::
356 :module: pySim.filesystem
357 :func: LinFixedEF.ShellCommands.read_rec_parser
358
Harald Weltebe9516f2021-04-03 11:30:10 +0200359
360read_record_decoded
361~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200362.. argparse::
363 :module: pySim.filesystem
364 :func: LinFixedEF.ShellCommands.read_rec_dec_parser
365
Harald Weltebe9516f2021-04-03 11:30:10 +0200366
Harald Welte850b72a2021-04-07 09:33:03 +0200367read_records
368~~~~~~~~~~~~
369.. argparse::
370 :module: pySim.filesystem
371 :func: LinFixedEF.ShellCommands.read_recs_parser
372
373
374read_records_decoded
375~~~~~~~~~~~~~~~~~~~~
376.. argparse::
377 :module: pySim.filesystem
378 :func: LinFixedEF.ShellCommands.read_recs_dec_parser
379
380
Harald Weltebe9516f2021-04-03 11:30:10 +0200381update_record
382~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200383.. argparse::
384 :module: pySim.filesystem
385 :func: LinFixedEF.ShellCommands.upd_rec_parser
386
Harald Weltebe9516f2021-04-03 11:30:10 +0200387
388update_record_decoded
389~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200390.. argparse::
391 :module: pySim.filesystem
392 :func: LinFixedEF.ShellCommands.upd_rec_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200393
394
Harald Welte4145d3c2021-04-08 20:34:13 +0200395edit_record_decoded
396~~~~~~~~~~~~~~~~~~~
397.. argparse::
398 :module: pySim.filesystem
399 :func: LinFixedEF.ShellCommands.edit_rec_dec_parser
400
401This command will read the selected record, decode it to its JSON representation, save
402that JSON to a temporary file on your computer, and launch your configured text editor.
403
404You may then perform whatever modifications to the JSON representation, save + leave your
405text editor.
406
407Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
408back to the record on the SIM card.
409
410This allows for easy interactive modification of records.
411
412
Harald Welteaefd0642022-02-25 15:26:37 +0100413decode_hex
414~~~~~~~~~~
415.. argparse::
416 :module: pySim.filesystem
417 :func: LinFixedEF.ShellCommands.dec_hex_parser
418
419
Harald Weltebe9516f2021-04-03 11:30:10 +0200420
421Transparent EF commands
422-----------------------
423
424These commands become enabled only when your currently selected file is of *Transparent EF* type.
425
426
427read_binary
428~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200429.. argparse::
430 :module: pySim.filesystem
431 :func: TransparentEF.ShellCommands.read_bin_parser
432
Harald Weltebe9516f2021-04-03 11:30:10 +0200433
434read_binary_decoded
435~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200436.. argparse::
437 :module: pySim.filesystem
438 :func: TransparentEF.ShellCommands.read_bin_dec_parser
439
Harald Weltebe9516f2021-04-03 11:30:10 +0200440
441update_binary
442~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200443.. argparse::
444 :module: pySim.filesystem
445 :func: TransparentEF.ShellCommands.upd_bin_parser
446
Harald Weltebe9516f2021-04-03 11:30:10 +0200447
448update_binary_decoded
449~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200450.. argparse::
451 :module: pySim.filesystem
452 :func: TransparentEF.ShellCommands.upd_bin_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200453
Harald Welte0d4e98a2021-04-07 00:14:40 +0200454In normal operation, update_binary_decoded needs a JSON document representing the entire file contents as
455input. This can be inconvenient if you want to keep 99% of the content but just toggle one specific
456parameter. That's where the JSONpath support comes in handy: You can specify a JSONpath to an element
457inside the document as well as a new value for tat field:
458
459Th below example demonstrates this by modifying the ofm field within EF.AD:
460
461::
462
463 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
464 {
465 "ms_operation_mode": "normal",
466 "specific_facilities": {
467 "ofm": true
468 },
469 "len_of_mnc_in_imsi": 2
470 }
471 pySIM-shell (MF/ADF.USIM/EF.AD)> update_binary_decoded --json-path specific_facilities.ofm false
472 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
473 {
474 "ms_operation_mode": "normal",
475 "specific_facilities": {
476 "ofm": false
477 },
478 "len_of_mnc_in_imsi": 2
479 }
480
Harald Weltebe9516f2021-04-03 11:30:10 +0200481
Harald Welte4145d3c2021-04-08 20:34:13 +0200482edit_binary_decoded
483~~~~~~~~~~~~~~~~~~~
484This command will read the selected binary EF, decode it to its JSON representation, save
485that JSON to a temporary file on your computer, and launch your configured text editor.
486
487You may then perform whatever modifications to the JSON representation, save + leave your
488text editor.
489
490Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
491to the SIM card.
492
493This allows for easy interactive modification of file contents.
494
Harald Weltebe9516f2021-04-03 11:30:10 +0200495
Harald Welteaefd0642022-02-25 15:26:37 +0100496decode_hex
497~~~~~~~~~~
498.. argparse::
499 :module: pySim.filesystem
500 :func: TransparentEF.ShellCommands.dec_hex_parser
501
502
Harald Welte917d98c2021-04-21 11:51:25 +0200503
504BER-TLV EF commands
505-------------------
506
507BER-TLV EFs are files that contain BER-TLV structured data. Every file can contain any number
508of variable-length IEs (DOs). The tag within a BER-TLV EF must be unique within the file.
509
510The commands below become enabled only when your currently selected file is of *BER-TLV EF* type.
511
512retrieve_tags
513~~~~~~~~~~~~~
514
515Retrieve a list of all tags present in the currently selected file.
516
517
518retrieve_data
519~~~~~~~~~~~~~
520.. argparse::
521 :module: pySim.filesystem
522 :func: BerTlvEF.ShellCommands.retrieve_data_parser
523
524
525set_data
526~~~~~~~~
527.. argparse::
528 :module: pySim.filesystem
529 :func: BerTlvEF.ShellCommands.set_data_parser
530
531
532del_data
533~~~~~~~~
534.. argparse::
535 :module: pySim.filesystem
536 :func: BerTlvEF.ShellCommands.del_data_parser
537
538
539
Harald Welte15fae982021-04-10 10:22:27 +0200540USIM commands
541-------------
542
Harald Welte577312a2023-02-23 09:51:30 +0100543These commands are available only while ADF.USIM (or ADF.ISIM, respectively) is selected.
544
Harald Welte15fae982021-04-10 10:22:27 +0200545authenticate
546~~~~~~~~~~~~
547.. argparse::
548 :module: pySim.ts_31_102
549 :func: ADF_USIM.AddlShellCommands.authenticate_parser
550
Harald Welte12af7932022-02-15 16:39:08 +0100551terminal_profile
552~~~~~~~~~~~~~~~~
553.. argparse::
554 :module: pySim.ts_31_102
555 :func: ADF_USIM.AddlShellCommands.term_prof_parser
556
557envelope
558~~~~~~~~
559.. argparse::
560 :module: pySim.ts_31_102
561 :func: ADF_USIM.AddlShellCommands.envelope_parser
562
563envelope_sms
564~~~~~~~~~~~~
565.. argparse::
566 :module: pySim.ts_31_102
567 :func: ADF_USIM.AddlShellCommands.envelope_sms_parser
568
569
Harald Welte577312a2023-02-23 09:51:30 +0100570File-specific commands
571----------------------
572
573These commands are valid only if the respective file is currently selected. They perform some
574operation that's specific to this file only.
575
576EF.ARR: read_arr_record
577~~~~~~~~~~~~~~~~~~~~~~~
578Read one EF.ARR record in flattened, human-friendly form.
579
580EF.ARR: read_arr_records
581~~~~~~~~~~~~~~~~~~~~~~~~
582Read + decode all EF.ARR records in flattened, human-friendly form.
583
Harald Weltec224b3b2023-05-23 18:44:44 +0200584DF.GSM/EF.SST: sst_service_allocate
585~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
586Mark a given single service as allocated in EF.SST. Requires service number as argument.
587
588DF.GSM/EF.SST: sst_service_activate
589~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
590Mark a given single service as activated in EF.SST. Requires service number as argument.
591
592DF.GSM/EF.SST: sst_service_deallocate
593~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
594Mark a given single service as deallocated in EF.SST. Requires service number as argument.
595
596DF.GSM/EF.SST: sst_service_deactivate
597~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
598Mark a given single service as deactivated in EF.SST. Requires service number as argument.
599
Harald Weltea07d5092023-02-23 10:02:49 +0100600ADF.USIM/EF.EST: est_service_enable
601~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
602Enables a single service in EF.EST. Requires service number as argument.
603
604ADF.USIM/EF.EST: est_service_disable
605~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
606Disables a single service in EF.EST. Requires service number as argument.
607
Harald Welte577312a2023-02-23 09:51:30 +0100608EF.IMSI: update_imsi_plmn
609~~~~~~~~~~~~~~~~~~~~~~~~~
610Change the PLMN part (MCC+MNC) of the IMSI. Requires a single argument consisting of 5/6 digits of
611concatenated MCC+MNC.
612
613ADF.USIM/EF.UST: ust_service_activate
614~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
615Activates a single service in EF.UST. Requires service number as argument.
616
617ADF.USIM/EF.UST: ust_service_deactivate
618~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
619Deactivates a single service in EF.UST. Requires service number as argument.
620
621ADF.USIM/EF.UST: ust_service_check
622~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
623Check consistency between services of this file and files present/activated.
624Many services determine if one or multiple files shall be present/activated or if they shall be
625absent/deactivated. This performs a consistency check to ensure that no services are activated
626for files that are not - and vice-versa, no files are activated for services that are not. Error
627messages are printed for every inconsistency found.
628
629ADF.ISIM/EF.IST: ist_service_activate
630~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
631Activates a single service in EF.IST. Requires service number as argument.
632
633ADF.ISIM/EF.IST: ist_service_deactivate
634~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
635Deactivates a single service in EF.UST. Requires service number as argument.
636
637ADF.ISIM/EF.IST: ist_service_check
638~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
639Check consistency between services of this file and files present/activated.
640Many services determine if one or multiple files shall be present/activated or if they shall be
641absent/deactivated. This performs a consistency check to ensure that no services are activated
642for files that are not - and vice-versa, no files are activated for services that are not. Error
643messages are printed for every inconsistency found.
644
645
646UICC Administrative commands
647----------------------------
648
649ETSI TS 102 222 specifies a set of *Administrative Commands*, which can
650be used by the card issuer / operator to modify the file system structure
651(delete files, create files) or even to terminate individual files or the
652entire card.
653
654pySim-shell supports those commands, but **use extreme caution**.
655Unless you know exactly what you're doing, it's very easy to render your
656card unusable. You've been warned!
657
658delete_file
659~~~~~~~~~~~
660.. argparse::
661 :module: pySim.ts_102_222
662 :func: Ts102222Commands.delfile_parser
663
664
665terminate_df
666~~~~~~~~~~~~
667.. argparse::
668 :module: pySim.ts_102_222
669 :func: Ts102222Commands.termdf_parser
670
671terminate_ef
672~~~~~~~~~~~~
673.. argparse::
674 :module: pySim.ts_102_222
675 :func: Ts102222Commands.termdf_parser
676
677terminate_card
678~~~~~~~~~~~~~~
679.. argparse::
680 :module: pySim.ts_102_222
681 :func: Ts102222Commands.tcard_parser
682
683create_ef
684~~~~~~~~~
685.. argparse::
686 :module: pySim.ts_102_222
687 :func: Ts102222Commands.create_parser
688
689create_df
690~~~~~~~~~
691.. argparse::
692 :module: pySim.ts_102_222
693 :func: Ts102222Commands.createdf_parser
Harald Welte12af7932022-02-15 16:39:08 +0100694
Harald Welte0707b802023-03-07 11:43:37 +0100695resize_ef
696~~~~~~~~~
697.. argparse::
698 :module: pySim.ts_102_222
699 :func: Ts102222Commands.resize_ef_parser
700
Harald Welte15fae982021-04-10 10:22:27 +0200701
Harald Welte95ce6b12021-10-20 18:40:54 +0200702ARA-M commands
703--------------
704
705The ARA-M commands exist to manage the access rules stored in an ARA-M applet on the card.
706
707ARA-M in the context of SIM cards is primarily used to enable Android UICC Carrier Privileges,
708please see https://source.android.com/devices/tech/config/uicc for more details on the background.
709
710
711aram_get_all
712~~~~~~~~~~~~
713
714Obtain and decode all access rules from the ARA-M applet on the card.
715
716NOTE: if the total size of the access rules exceeds 255 bytes, this command will fail, as
717it doesn't yet implement fragmentation/reassembly on rule retrieval. YMMV
718
719::
720
721 pySIM-shell (MF/ADF.ARA-M)> aram_get_all
722 [
723 {
724 "ResponseAllRefArDO": [
725 {
726 "RefArDO": [
727 {
728 "RefDO": [
729 {
730 "AidRefDO": "ffffffffffff"
731 },
732 {
733 "DevAppIdRefDO": "e46872f28b350b7e1f140de535c2a8d5804f0be3"
734 }
735 ]
736 },
737 {
738 "ArDO": [
739 {
740 "ApduArDO": {
741 "generic_access_rule": "always"
742 }
743 },
744 {
745 "PermArDO": {
746 "permissions": "0000000000000001"
747 }
748 }
749 ]
750 }
751 ]
752 }
753 ]
754 }
755 ]
756
757aram_get_config
758~~~~~~~~~~~~~~~
759Perform Config handshake with ARA-M applet: Tell it our version and retrieve its version.
760
761NOTE: Not supported in all ARA-M implementations.
762
Harald Welte95ce6b12021-10-20 18:40:54 +0200763
764aram_store_ref_ar_do
765~~~~~~~~~~~~~~~~~~~~
Harald Welte95ce6b12021-10-20 18:40:54 +0200766.. argparse::
767 :module: pySim.ara_m
768 :func: ADF_ARAM.AddlShellCommands.store_ref_ar_do_parse
769
770For 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 +0200771::
772
773 pySIM-shell (MF/ADF.ARA-M)> aram_store_ref_ar_do --aid FFFFFFFFFFFF --device-app-id E46872F28B350B7E1F140DE535C2A8D5804F0BE3 --android-permissions 0000000000000001 --apdu-always
774
775
776aram_delete_all
777~~~~~~~~~~~~~~~
778This command will request deletion of all access rules stored within the
779ARA-M applet. Use it with caution, there is no undo. Any rules later
780intended must be manually inserted again using `aram_store_ref_ar_do`
781
782
Harald Welte577312a2023-02-23 09:51:30 +0100783GlobalPlatform commands
784-----------------------
785
786pySim-shell has only the mots rudimentary support for GlobalPlatform at this point. Please use dedicated
787projects like GlobalPlatformPro meanwhile.
788
789get_data
790~~~~~~~~
791Performs the GET DATA command as specified by GlobalPlatform.
792
Harald Welte15fae982021-04-10 10:22:27 +0200793
Harald Weltebe9516f2021-04-03 11:30:10 +0200794cmd2 settable parameters
795------------------------
796
797``cmd2`` has the concept of *settable parameters* which act a bit like environment variables in an OS-level
798shell: They can be read and set, and they will influence the behavior somehow.
799
800conserve_write
801~~~~~~~~~~~~~~
802
803If enabled, pySim will (when asked to write to a card) always first read the respective file/record and
804verify if the to-be-written value differs from the current on-card value. If not, the write will be skipped.
805Writes will only be performed if the new value is different from the current on-card value.
806
807If disabled, pySim will always write irrespective of the current/new value.
808
Harald Welte1748b932021-04-06 21:12:25 +0200809json_pretty_print
810~~~~~~~~~~~~~~~~~
811
812This parameter determines if generated JSON output should (by default) be pretty-printed (multi-line
813output with indent level of 4 spaces) or not.
814
815The default value of this parameter is 'true'.
816
Harald Weltebe9516f2021-04-03 11:30:10 +0200817debug
818~~~~~
819
820If enabled, full python back-traces will be displayed in case of exceptions
821
Harald Welte7829d8a2021-04-10 11:28:53 +0200822apdu_trace
823~~~~~~~~~~
824
825Boolean variable that determines if a hex-dump of the command + response APDU shall be printed.
826
Harald Weltebe9516f2021-04-03 11:30:10 +0200827numeric_path
828~~~~~~~~~~~~
829
830Boolean variable that determines if path (e.g. in prompt) is displayed with numeric FIDs or string names.
831
832::
833
834 pySIM-shell (MF/EF.ICCID)> set numeric_path True
835 numeric_path - was: False
836 now: True
837 pySIM-shell (3f00/2fe2)> set numeric_path False
838 numeric_path - was: True
839 now: False
840 pySIM-shell (MF/EF.ICCID)> help set