blob: 510f4c6cb50f5c08801566bd184a308cbfe5bcea [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 Welteec950532021-10-20 13:09:00 +0200202suspend_uicc
203~~~~~~~~~~~~
204This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
205recent power-saving addition to the UICC specifications, allowing for suspend/resume while maintaining
206state, as opposed to a full power-off (deactivate) and power-on (activate) of the card.
207
208The pySim command just sends that SUSPEND UICC command and doesn't perform the full related sequence
209including the electrical power down.
210
211.. argparse::
212 :module: pySim-shell
213 :func: Iso7816Commands.suspend_uicc_parser
214
215
Harald Welte12af7932022-02-15 16:39:08 +0100216
Harald Weltebe9516f2021-04-03 11:30:10 +0200217pySim commands
218--------------
219
220Commands in this category are pySim specific; they do not have a 1:1 correspondence to ISO 7816
221or 3GPP commands. Mostly they will operate either only on local (in-memory) state, or execute
222a complex sequence of card-commands.
223
224desc
225~~~~
Harald Weltebe9516f2021-04-03 11:30:10 +0200226Display human readable file description for the currently selected file.
227
228
229dir
230~~~
Harald Welted36f6942021-04-04 14:37:55 +0200231.. argparse::
232 :module: pySim-shell
233 :func: PySimCommands.dir_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200234
Harald Welte12af7932022-02-15 16:39:08 +0100235Example:
236::
237
238 pySIM-shell (MF)> dir
239 MF
240 3f00
241 .. ADF.USIM DF.SYSTEM EF.DIR EF.UMPC
242 ADF.ARA-M DF.EIRENE DF.TELECOM EF.ICCID MF
243 ADF.ISIM DF.GSM EF.ARR EF.PL
244 14 files
245
Harald Weltebe9516f2021-04-03 11:30:10 +0200246
247export
248~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200249.. argparse::
250 :module: pySim-shell
251 :func: PySimCommands.export_parser
252
Harald Weltebd02f842021-10-21 14:40:39 +0200253Please note that `export` works relative to the current working
254directory, so if you are in `MF`, then the export will contain all known
255files on the card. However, if you are in `ADF.ISIM`, only files below
256that ADF will be part of the export.
257
258Furthermore, it is strongly advised to first enter the ADM1 pin
259(`verify_adm`) to maximize the chance of having permission to read
260all/most files.
261
Harald Weltebe9516f2021-04-03 11:30:10 +0200262
263tree
264~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200265Display a tree of the card filesystem. It is important to note that this displays a tree
266of files that might potentially exist (based on the card profile). In order to determine if
267a given file really exists on a given card, you have to try to select that file.
Harald Welted36f6942021-04-04 14:37:55 +0200268
Harald Welte12af7932022-02-15 16:39:08 +0100269Example:
270::
271
272 pySIM-shell (MF)> tree --help
273 EF.DIR 2f00 Application Directory
274 EF.ICCID 2fe2 ICC Identification
275 EF.PL 2f05 Preferred Languages
276 EF.ARR 2f06 Access Rule Reference
277 EF.UMPC 2f08 UICC Maximum Power Consumption
278 DF.TELECOM 7f10 None
279 EF.ADN 6f3a Abbreviated Dialing Numbers
280 ...
281
282
Harald Weltebe9516f2021-04-03 11:30:10 +0200283
284verify_adm
285~~~~~~~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200286Verify the ADM (Administrator) PIN specified as argument. This is typically needed in order
287to get write/update permissions to most of the files on SIM cards.
288
289Currently only ADM1 is supported.
Harald Weltebe9516f2021-04-03 11:30:10 +0200290
291
Harald Weltedaf2b392021-05-03 23:17:29 +0200292reset
293~~~~~
Harald Weltedaf2b392021-05-03 23:17:29 +0200294Perform card reset and display the card ATR.
295
Harald Weltebd02f842021-10-21 14:40:39 +0200296intro
297~~~~~
298[Re-]Display the introductory banner
299
300
301equip
302~~~~~
303Equip pySim-shell with a card; particularly useful if the program was
304started before a card was present, or after a card has been replaced by
305the user while pySim-shell was kept running.
306
307bulk_script
308~~~~~~~~~~~
309.. argparse::
310 :module: pySim-shell
311 :func: PysimApp.bulk_script_parser
312
Harald Weltebd02f842021-10-21 14:40:39 +0200313
314echo
315~~~~
316.. argparse::
317 :module: pySim-shell
318 :func: PysimApp.echo_parser
319
320
Harald Welte12af7932022-02-15 16:39:08 +0100321apdu
322~~~~
323.. argparse::
324 :module: pySim-shell
325 :func: PySimCommands.apdu_cmd_parser
326
327
Harald Weltedaf2b392021-05-03 23:17:29 +0200328
Harald Weltebe9516f2021-04-03 11:30:10 +0200329Linear Fixed EF commands
330------------------------
331
332These commands become enabled only when your currently selected file is of *Linear Fixed EF* type.
333
334read_record
335~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200336.. argparse::
337 :module: pySim.filesystem
338 :func: LinFixedEF.ShellCommands.read_rec_parser
339
Harald Weltebe9516f2021-04-03 11:30:10 +0200340
341read_record_decoded
342~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200343.. argparse::
344 :module: pySim.filesystem
345 :func: LinFixedEF.ShellCommands.read_rec_dec_parser
346
Harald Weltebe9516f2021-04-03 11:30:10 +0200347
Harald Welte850b72a2021-04-07 09:33:03 +0200348read_records
349~~~~~~~~~~~~
350.. argparse::
351 :module: pySim.filesystem
352 :func: LinFixedEF.ShellCommands.read_recs_parser
353
354
355read_records_decoded
356~~~~~~~~~~~~~~~~~~~~
357.. argparse::
358 :module: pySim.filesystem
359 :func: LinFixedEF.ShellCommands.read_recs_dec_parser
360
361
Harald Weltebe9516f2021-04-03 11:30:10 +0200362update_record
363~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200364.. argparse::
365 :module: pySim.filesystem
366 :func: LinFixedEF.ShellCommands.upd_rec_parser
367
Harald Weltebe9516f2021-04-03 11:30:10 +0200368
369update_record_decoded
370~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200371.. argparse::
372 :module: pySim.filesystem
373 :func: LinFixedEF.ShellCommands.upd_rec_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200374
375
Harald Welte4145d3c2021-04-08 20:34:13 +0200376edit_record_decoded
377~~~~~~~~~~~~~~~~~~~
378.. argparse::
379 :module: pySim.filesystem
380 :func: LinFixedEF.ShellCommands.edit_rec_dec_parser
381
382This command will read the selected record, decode it to its JSON representation, save
383that JSON to a temporary file on your computer, and launch your configured text editor.
384
385You may then perform whatever modifications to the JSON representation, save + leave your
386text editor.
387
388Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
389back to the record on the SIM card.
390
391This allows for easy interactive modification of records.
392
393
Harald Welteaefd0642022-02-25 15:26:37 +0100394decode_hex
395~~~~~~~~~~
396.. argparse::
397 :module: pySim.filesystem
398 :func: LinFixedEF.ShellCommands.dec_hex_parser
399
400
Harald Weltebe9516f2021-04-03 11:30:10 +0200401
402Transparent EF commands
403-----------------------
404
405These commands become enabled only when your currently selected file is of *Transparent EF* type.
406
407
408read_binary
409~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200410.. argparse::
411 :module: pySim.filesystem
412 :func: TransparentEF.ShellCommands.read_bin_parser
413
Harald Weltebe9516f2021-04-03 11:30:10 +0200414
415read_binary_decoded
416~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200417.. argparse::
418 :module: pySim.filesystem
419 :func: TransparentEF.ShellCommands.read_bin_dec_parser
420
Harald Weltebe9516f2021-04-03 11:30:10 +0200421
422update_binary
423~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200424.. argparse::
425 :module: pySim.filesystem
426 :func: TransparentEF.ShellCommands.upd_bin_parser
427
Harald Weltebe9516f2021-04-03 11:30:10 +0200428
429update_binary_decoded
430~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200431.. argparse::
432 :module: pySim.filesystem
433 :func: TransparentEF.ShellCommands.upd_bin_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200434
Harald Welte0d4e98a2021-04-07 00:14:40 +0200435In normal operation, update_binary_decoded needs a JSON document representing the entire file contents as
436input. This can be inconvenient if you want to keep 99% of the content but just toggle one specific
437parameter. That's where the JSONpath support comes in handy: You can specify a JSONpath to an element
438inside the document as well as a new value for tat field:
439
440Th below example demonstrates this by modifying the ofm field within EF.AD:
441
442::
443
444 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
445 {
446 "ms_operation_mode": "normal",
447 "specific_facilities": {
448 "ofm": true
449 },
450 "len_of_mnc_in_imsi": 2
451 }
452 pySIM-shell (MF/ADF.USIM/EF.AD)> update_binary_decoded --json-path specific_facilities.ofm false
453 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
454 {
455 "ms_operation_mode": "normal",
456 "specific_facilities": {
457 "ofm": false
458 },
459 "len_of_mnc_in_imsi": 2
460 }
461
Harald Weltebe9516f2021-04-03 11:30:10 +0200462
Harald Welte4145d3c2021-04-08 20:34:13 +0200463edit_binary_decoded
464~~~~~~~~~~~~~~~~~~~
465This command will read the selected binary EF, decode it to its JSON representation, save
466that JSON to a temporary file on your computer, and launch your configured text editor.
467
468You may then perform whatever modifications to the JSON representation, save + leave your
469text editor.
470
471Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
472to the SIM card.
473
474This allows for easy interactive modification of file contents.
475
Harald Weltebe9516f2021-04-03 11:30:10 +0200476
Harald Welteaefd0642022-02-25 15:26:37 +0100477decode_hex
478~~~~~~~~~~
479.. argparse::
480 :module: pySim.filesystem
481 :func: TransparentEF.ShellCommands.dec_hex_parser
482
483
Harald Welte917d98c2021-04-21 11:51:25 +0200484
485BER-TLV EF commands
486-------------------
487
488BER-TLV EFs are files that contain BER-TLV structured data. Every file can contain any number
489of variable-length IEs (DOs). The tag within a BER-TLV EF must be unique within the file.
490
491The commands below become enabled only when your currently selected file is of *BER-TLV EF* type.
492
493retrieve_tags
494~~~~~~~~~~~~~
495
496Retrieve a list of all tags present in the currently selected file.
497
498
499retrieve_data
500~~~~~~~~~~~~~
501.. argparse::
502 :module: pySim.filesystem
503 :func: BerTlvEF.ShellCommands.retrieve_data_parser
504
505
506set_data
507~~~~~~~~
508.. argparse::
509 :module: pySim.filesystem
510 :func: BerTlvEF.ShellCommands.set_data_parser
511
512
513del_data
514~~~~~~~~
515.. argparse::
516 :module: pySim.filesystem
517 :func: BerTlvEF.ShellCommands.del_data_parser
518
519
520
Harald Welte15fae982021-04-10 10:22:27 +0200521USIM commands
522-------------
523
Harald Welte577312a2023-02-23 09:51:30 +0100524These commands are available only while ADF.USIM (or ADF.ISIM, respectively) is selected.
525
Harald Welte15fae982021-04-10 10:22:27 +0200526authenticate
527~~~~~~~~~~~~
528.. argparse::
529 :module: pySim.ts_31_102
530 :func: ADF_USIM.AddlShellCommands.authenticate_parser
531
Harald Welte12af7932022-02-15 16:39:08 +0100532terminal_profile
533~~~~~~~~~~~~~~~~
534.. argparse::
535 :module: pySim.ts_31_102
536 :func: ADF_USIM.AddlShellCommands.term_prof_parser
537
538envelope
539~~~~~~~~
540.. argparse::
541 :module: pySim.ts_31_102
542 :func: ADF_USIM.AddlShellCommands.envelope_parser
543
544envelope_sms
545~~~~~~~~~~~~
546.. argparse::
547 :module: pySim.ts_31_102
548 :func: ADF_USIM.AddlShellCommands.envelope_sms_parser
549
550
Harald Welte577312a2023-02-23 09:51:30 +0100551File-specific commands
552----------------------
553
554These commands are valid only if the respective file is currently selected. They perform some
555operation that's specific to this file only.
556
557EF.ARR: read_arr_record
558~~~~~~~~~~~~~~~~~~~~~~~
559Read one EF.ARR record in flattened, human-friendly form.
560
561EF.ARR: read_arr_records
562~~~~~~~~~~~~~~~~~~~~~~~~
563Read + decode all EF.ARR records in flattened, human-friendly form.
564
Harald Weltec224b3b2023-05-23 18:44:44 +0200565DF.GSM/EF.SST: sst_service_allocate
566~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
567Mark a given single service as allocated in EF.SST. Requires service number as argument.
568
569DF.GSM/EF.SST: sst_service_activate
570~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
571Mark a given single service as activated in EF.SST. Requires service number as argument.
572
573DF.GSM/EF.SST: sst_service_deallocate
574~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
575Mark a given single service as deallocated in EF.SST. Requires service number as argument.
576
577DF.GSM/EF.SST: sst_service_deactivate
578~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
579Mark a given single service as deactivated in EF.SST. Requires service number as argument.
580
Harald Weltea07d5092023-02-23 10:02:49 +0100581ADF.USIM/EF.EST: est_service_enable
582~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
583Enables a single service in EF.EST. Requires service number as argument.
584
585ADF.USIM/EF.EST: est_service_disable
586~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
587Disables a single service in EF.EST. Requires service number as argument.
588
Harald Welte577312a2023-02-23 09:51:30 +0100589EF.IMSI: update_imsi_plmn
590~~~~~~~~~~~~~~~~~~~~~~~~~
591Change the PLMN part (MCC+MNC) of the IMSI. Requires a single argument consisting of 5/6 digits of
592concatenated MCC+MNC.
593
594ADF.USIM/EF.UST: ust_service_activate
595~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
596Activates a single service in EF.UST. Requires service number as argument.
597
598ADF.USIM/EF.UST: ust_service_deactivate
599~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
600Deactivates a single service in EF.UST. Requires service number as argument.
601
602ADF.USIM/EF.UST: ust_service_check
603~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
604Check consistency between services of this file and files present/activated.
605Many services determine if one or multiple files shall be present/activated or if they shall be
606absent/deactivated. This performs a consistency check to ensure that no services are activated
607for files that are not - and vice-versa, no files are activated for services that are not. Error
608messages are printed for every inconsistency found.
609
610ADF.ISIM/EF.IST: ist_service_activate
611~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
612Activates a single service in EF.IST. Requires service number as argument.
613
614ADF.ISIM/EF.IST: ist_service_deactivate
615~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
616Deactivates a single service in EF.UST. Requires service number as argument.
617
618ADF.ISIM/EF.IST: ist_service_check
619~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
620Check consistency between services of this file and files present/activated.
621Many services determine if one or multiple files shall be present/activated or if they shall be
622absent/deactivated. This performs a consistency check to ensure that no services are activated
623for files that are not - and vice-versa, no files are activated for services that are not. Error
624messages are printed for every inconsistency found.
625
626
627UICC Administrative commands
628----------------------------
629
630ETSI TS 102 222 specifies a set of *Administrative Commands*, which can
631be used by the card issuer / operator to modify the file system structure
632(delete files, create files) or even to terminate individual files or the
633entire card.
634
635pySim-shell supports those commands, but **use extreme caution**.
636Unless you know exactly what you're doing, it's very easy to render your
637card unusable. You've been warned!
638
639delete_file
640~~~~~~~~~~~
641.. argparse::
642 :module: pySim.ts_102_222
643 :func: Ts102222Commands.delfile_parser
644
645
646terminate_df
647~~~~~~~~~~~~
648.. argparse::
649 :module: pySim.ts_102_222
650 :func: Ts102222Commands.termdf_parser
651
652terminate_ef
653~~~~~~~~~~~~
654.. argparse::
655 :module: pySim.ts_102_222
656 :func: Ts102222Commands.termdf_parser
657
658terminate_card
659~~~~~~~~~~~~~~
660.. argparse::
661 :module: pySim.ts_102_222
662 :func: Ts102222Commands.tcard_parser
663
664create_ef
665~~~~~~~~~
666.. argparse::
667 :module: pySim.ts_102_222
668 :func: Ts102222Commands.create_parser
669
670create_df
671~~~~~~~~~
672.. argparse::
673 :module: pySim.ts_102_222
674 :func: Ts102222Commands.createdf_parser
Harald Welte12af7932022-02-15 16:39:08 +0100675
Harald Welte0707b802023-03-07 11:43:37 +0100676resize_ef
677~~~~~~~~~
678.. argparse::
679 :module: pySim.ts_102_222
680 :func: Ts102222Commands.resize_ef_parser
681
Harald Welte15fae982021-04-10 10:22:27 +0200682
Harald Welte95ce6b12021-10-20 18:40:54 +0200683ARA-M commands
684--------------
685
686The ARA-M commands exist to manage the access rules stored in an ARA-M applet on the card.
687
688ARA-M in the context of SIM cards is primarily used to enable Android UICC Carrier Privileges,
689please see https://source.android.com/devices/tech/config/uicc for more details on the background.
690
691
692aram_get_all
693~~~~~~~~~~~~
694
695Obtain and decode all access rules from the ARA-M applet on the card.
696
697NOTE: if the total size of the access rules exceeds 255 bytes, this command will fail, as
698it doesn't yet implement fragmentation/reassembly on rule retrieval. YMMV
699
700::
701
702 pySIM-shell (MF/ADF.ARA-M)> aram_get_all
703 [
704 {
705 "ResponseAllRefArDO": [
706 {
707 "RefArDO": [
708 {
709 "RefDO": [
710 {
711 "AidRefDO": "ffffffffffff"
712 },
713 {
714 "DevAppIdRefDO": "e46872f28b350b7e1f140de535c2a8d5804f0be3"
715 }
716 ]
717 },
718 {
719 "ArDO": [
720 {
721 "ApduArDO": {
722 "generic_access_rule": "always"
723 }
724 },
725 {
726 "PermArDO": {
727 "permissions": "0000000000000001"
728 }
729 }
730 ]
731 }
732 ]
733 }
734 ]
735 }
736 ]
737
738aram_get_config
739~~~~~~~~~~~~~~~
740Perform Config handshake with ARA-M applet: Tell it our version and retrieve its version.
741
742NOTE: Not supported in all ARA-M implementations.
743
Harald Welte95ce6b12021-10-20 18:40:54 +0200744
745aram_store_ref_ar_do
746~~~~~~~~~~~~~~~~~~~~
Harald Welte95ce6b12021-10-20 18:40:54 +0200747.. argparse::
748 :module: pySim.ara_m
749 :func: ADF_ARAM.AddlShellCommands.store_ref_ar_do_parse
750
751For 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 +0200752::
753
754 pySIM-shell (MF/ADF.ARA-M)> aram_store_ref_ar_do --aid FFFFFFFFFFFF --device-app-id E46872F28B350B7E1F140DE535C2A8D5804F0BE3 --android-permissions 0000000000000001 --apdu-always
755
756
757aram_delete_all
758~~~~~~~~~~~~~~~
759This command will request deletion of all access rules stored within the
760ARA-M applet. Use it with caution, there is no undo. Any rules later
761intended must be manually inserted again using `aram_store_ref_ar_do`
762
763
Harald Welte577312a2023-02-23 09:51:30 +0100764GlobalPlatform commands
765-----------------------
766
767pySim-shell has only the mots rudimentary support for GlobalPlatform at this point. Please use dedicated
768projects like GlobalPlatformPro meanwhile.
769
770get_data
771~~~~~~~~
772Performs the GET DATA command as specified by GlobalPlatform.
773
Harald Welte15fae982021-04-10 10:22:27 +0200774
Harald Weltebe9516f2021-04-03 11:30:10 +0200775cmd2 settable parameters
776------------------------
777
778``cmd2`` has the concept of *settable parameters* which act a bit like environment variables in an OS-level
779shell: They can be read and set, and they will influence the behavior somehow.
780
781conserve_write
782~~~~~~~~~~~~~~
783
784If enabled, pySim will (when asked to write to a card) always first read the respective file/record and
785verify if the to-be-written value differs from the current on-card value. If not, the write will be skipped.
786Writes will only be performed if the new value is different from the current on-card value.
787
788If disabled, pySim will always write irrespective of the current/new value.
789
Harald Welte1748b932021-04-06 21:12:25 +0200790json_pretty_print
791~~~~~~~~~~~~~~~~~
792
793This parameter determines if generated JSON output should (by default) be pretty-printed (multi-line
794output with indent level of 4 spaces) or not.
795
796The default value of this parameter is 'true'.
797
Harald Weltebe9516f2021-04-03 11:30:10 +0200798debug
799~~~~~
800
801If enabled, full python back-traces will be displayed in case of exceptions
802
Harald Welte7829d8a2021-04-10 11:28:53 +0200803apdu_trace
804~~~~~~~~~~
805
806Boolean variable that determines if a hex-dump of the command + response APDU shall be printed.
807
Harald Weltebe9516f2021-04-03 11:30:10 +0200808numeric_path
809~~~~~~~~~~~~
810
811Boolean variable that determines if path (e.g. in prompt) is displayed with numeric FIDs or string names.
812
813::
814
815 pySIM-shell (MF/EF.ICCID)> set numeric_path True
816 numeric_path - was: False
817 now: True
818 pySIM-shell (3f00/2fe2)> set numeric_path False
819 numeric_path - was: True
820 now: False
821 pySIM-shell (MF/EF.ICCID)> help set