blob: 9ffbac380f02791c4845a178acd04e672c37ad3b [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
39
Harald Weltebe9516f2021-04-03 11:30:10 +020040
41cmd2 basics
42-----------
43
44FIXME
45
46
47
48ISO7816 commands
49----------------
50
51This category of commands relates to commands that originate in the ISO 7861-4 specifications,
52most of them have a 1:1 resemblance in the specification.
53
54select
55~~~~~~
56
57The ``select`` command is used to select a file, either by its FID, AID or by its symbolic name.
58
59Try ``select`` with tab-completion to get a list of all current selectable items:
60
61::
62
63 pySIM-shell (MF)> select
64 .. 2fe2 a0000000871004 EF.ARR MF
65 2f00 3f00 ADF.ISIM EF.DIR
66 2f05 7f10 ADF.USIM EF.ICCID
67 2f06 7f20 DF.GSM EF.PL
68 2f08 a0000000871002 DF.TELECOM EF.UMPC
69
70Use ``select`` with a specific FID or name to select the new file.
71
72This will
73
74* output the [JSON decoded, if possible] select response
75* change the prompt to the newly selected file
76* enable any commands specific to the newly-selected file
77
78::
79
80 pySIM-shell (MF)> select ADF.USIM
81 {
82 "file_descriptor": {
Harald Welte747a9782022-02-13 17:52:28 +010083 "file_descriptor_byte": {
84 "shareable": true,
85 "file_type": "df",
86 "structure": "no_info_given"
87 }
Harald Weltebe9516f2021-04-03 11:30:10 +020088 },
89 "df_name": "A0000000871002FFFFFFFF8907090000",
90 "proprietary_info": {
91 "uicc_characteristics": "71",
92 "available_memory": 101640
93 },
94 "life_cycle_status_int": "operational_activated",
95 "security_attrib_compact": "00",
96 "pin_status_template_do": "90017083010183018183010A83010B"
97 }
98 pySIM-shell (MF/ADF.USIM)>
99
100
Harald Welted01bd362022-02-15 15:56:48 +0100101status
102~~~~~~
103
104The ``status`` command [re-]obtains the File Control Template of the
105currently-selected file and print its decoded output.
106
107Example:
108
109::
110
111 pySIM-shell (MF/ADF.ISIM)> status
112 {
113 "file_descriptor": {
114 "file_descriptor_byte": {
115 "shareable": true,
116 "file_type": "df",
117 "structure": "no_info_given"
118 },
119 "record_len": null,
120 "num_of_rec": null
121 },
122 "file_identifier": "ff01",
123 "df_name": "a0000000871004ffffffff8907090000",
124 "proprietary_information": {
125 "uicc_characteristics": "71",
126 "available_memory": 101640
127 },
128 "life_cycle_status_integer": "operational_activated",
129 "security_attrib_compact": "00",
130 "pin_status_template_do": {
131 "ps_do": "70",
132 "key_reference": 11
133 }
134 }
135
Harald Weltebe9516f2021-04-03 11:30:10 +0200136
137change_chv
138~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200139.. argparse::
140 :module: pySim-shell
141 :func: Iso7816Commands.change_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200142
143
144disable_chv
145~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200146.. argparse::
147 :module: pySim-shell
148 :func: Iso7816Commands.disable_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200149
Harald Weltebe9516f2021-04-03 11:30:10 +0200150
151enable_chv
152~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200153.. argparse::
154 :module: pySim-shell
155 :func: Iso7816Commands.enable_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200156
157
158unblock_chv
159~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200160.. argparse::
161 :module: pySim-shell
162 :func: Iso7816Commands.unblock_chv_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200163
Harald Weltebe9516f2021-04-03 11:30:10 +0200164
165verify_chv
166~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200167.. argparse::
168 :module: pySim-shell
169 :func: Iso7816Commands.verify_chv_parser
170
Harald Weltea4631612021-04-10 18:17:55 +0200171deactivate_file
172~~~~~~~~~~~~~~~
173Deactivate the currently selected file. This used to be called INVALIDATE in TS 11.11.
174
175
176activate_file
177~~~~~~~~~~~~~
Harald Welte799c3542022-02-15 15:56:28 +0100178.. argparse::
179 :module: pySim-shell
180 :func: Iso7816Commands.activate_file_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200181
Harald Welte703f9332021-04-10 18:39:32 +0200182open_channel
183~~~~~~~~~~~~
184.. argparse::
185 :module: pySim-shell
186 :func: Iso7816Commands.open_chan_parser
187
188close_channel
189~~~~~~~~~~~~~
190.. argparse::
191 :module: pySim-shell
192 :func: Iso7816Commands.close_chan_parser
193
Harald Weltebe9516f2021-04-03 11:30:10 +0200194
Harald Welteec950532021-10-20 13:09:00 +0200195suspend_uicc
196~~~~~~~~~~~~
197This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
198recent power-saving addition to the UICC specifications, allowing for suspend/resume while maintaining
199state, as opposed to a full power-off (deactivate) and power-on (activate) of the card.
200
201The pySim command just sends that SUSPEND UICC command and doesn't perform the full related sequence
202including the electrical power down.
203
204.. argparse::
205 :module: pySim-shell
206 :func: Iso7816Commands.suspend_uicc_parser
207
208
Harald Welte12af7932022-02-15 16:39:08 +0100209
Harald Weltebe9516f2021-04-03 11:30:10 +0200210pySim commands
211--------------
212
213Commands in this category are pySim specific; they do not have a 1:1 correspondence to ISO 7816
214or 3GPP commands. Mostly they will operate either only on local (in-memory) state, or execute
215a complex sequence of card-commands.
216
217desc
218~~~~
Harald Weltebe9516f2021-04-03 11:30:10 +0200219Display human readable file description for the currently selected file.
220
221
222dir
223~~~
Harald Welted36f6942021-04-04 14:37:55 +0200224.. argparse::
225 :module: pySim-shell
226 :func: PySimCommands.dir_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200227
Harald Welte12af7932022-02-15 16:39:08 +0100228Example:
229::
230
231 pySIM-shell (MF)> dir
232 MF
233 3f00
234 .. ADF.USIM DF.SYSTEM EF.DIR EF.UMPC
235 ADF.ARA-M DF.EIRENE DF.TELECOM EF.ICCID MF
236 ADF.ISIM DF.GSM EF.ARR EF.PL
237 14 files
238
Harald Weltebe9516f2021-04-03 11:30:10 +0200239
240export
241~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200242.. argparse::
243 :module: pySim-shell
244 :func: PySimCommands.export_parser
245
Harald Weltebd02f842021-10-21 14:40:39 +0200246Please note that `export` works relative to the current working
247directory, so if you are in `MF`, then the export will contain all known
248files on the card. However, if you are in `ADF.ISIM`, only files below
249that ADF will be part of the export.
250
251Furthermore, it is strongly advised to first enter the ADM1 pin
252(`verify_adm`) to maximize the chance of having permission to read
253all/most files.
254
Harald Weltebe9516f2021-04-03 11:30:10 +0200255
256tree
257~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200258Display a tree of the card filesystem. It is important to note that this displays a tree
259of files that might potentially exist (based on the card profile). In order to determine if
260a given file really exists on a given card, you have to try to select that file.
Harald Welted36f6942021-04-04 14:37:55 +0200261
Harald Welte12af7932022-02-15 16:39:08 +0100262Example:
263::
264
265 pySIM-shell (MF)> tree --help
266 EF.DIR 2f00 Application Directory
267 EF.ICCID 2fe2 ICC Identification
268 EF.PL 2f05 Preferred Languages
269 EF.ARR 2f06 Access Rule Reference
270 EF.UMPC 2f08 UICC Maximum Power Consumption
271 DF.TELECOM 7f10 None
272 EF.ADN 6f3a Abbreviated Dialing Numbers
273 ...
274
275
Harald Weltebe9516f2021-04-03 11:30:10 +0200276
277verify_adm
278~~~~~~~~~~
Harald Welte7743c202021-05-03 23:30:11 +0200279Verify the ADM (Administrator) PIN specified as argument. This is typically needed in order
280to get write/update permissions to most of the files on SIM cards.
281
282Currently only ADM1 is supported.
Harald Weltebe9516f2021-04-03 11:30:10 +0200283
284
Harald Weltedaf2b392021-05-03 23:17:29 +0200285reset
286~~~~~
Harald Weltedaf2b392021-05-03 23:17:29 +0200287Perform card reset and display the card ATR.
288
Harald Weltebd02f842021-10-21 14:40:39 +0200289intro
290~~~~~
291[Re-]Display the introductory banner
292
293
294equip
295~~~~~
296Equip pySim-shell with a card; particularly useful if the program was
297started before a card was present, or after a card has been replaced by
298the user while pySim-shell was kept running.
299
300bulk_script
301~~~~~~~~~~~
302.. argparse::
303 :module: pySim-shell
304 :func: PysimApp.bulk_script_parser
305
Harald Weltebd02f842021-10-21 14:40:39 +0200306
307echo
308~~~~
309.. argparse::
310 :module: pySim-shell
311 :func: PysimApp.echo_parser
312
313
Harald Welte12af7932022-02-15 16:39:08 +0100314apdu
315~~~~
316.. argparse::
317 :module: pySim-shell
318 :func: PySimCommands.apdu_cmd_parser
319
320
Harald Weltedaf2b392021-05-03 23:17:29 +0200321
Harald Weltebe9516f2021-04-03 11:30:10 +0200322Linear Fixed EF commands
323------------------------
324
325These commands become enabled only when your currently selected file is of *Linear Fixed EF* type.
326
327read_record
328~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200329.. argparse::
330 :module: pySim.filesystem
331 :func: LinFixedEF.ShellCommands.read_rec_parser
332
Harald Weltebe9516f2021-04-03 11:30:10 +0200333
334read_record_decoded
335~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200336.. argparse::
337 :module: pySim.filesystem
338 :func: LinFixedEF.ShellCommands.read_rec_dec_parser
339
Harald Weltebe9516f2021-04-03 11:30:10 +0200340
Harald Welte850b72a2021-04-07 09:33:03 +0200341read_records
342~~~~~~~~~~~~
343.. argparse::
344 :module: pySim.filesystem
345 :func: LinFixedEF.ShellCommands.read_recs_parser
346
347
348read_records_decoded
349~~~~~~~~~~~~~~~~~~~~
350.. argparse::
351 :module: pySim.filesystem
352 :func: LinFixedEF.ShellCommands.read_recs_dec_parser
353
354
Harald Weltebe9516f2021-04-03 11:30:10 +0200355update_record
356~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200357.. argparse::
358 :module: pySim.filesystem
359 :func: LinFixedEF.ShellCommands.upd_rec_parser
360
Harald Weltebe9516f2021-04-03 11:30:10 +0200361
362update_record_decoded
363~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200364.. argparse::
365 :module: pySim.filesystem
366 :func: LinFixedEF.ShellCommands.upd_rec_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200367
368
Harald Welte4145d3c2021-04-08 20:34:13 +0200369edit_record_decoded
370~~~~~~~~~~~~~~~~~~~
371.. argparse::
372 :module: pySim.filesystem
373 :func: LinFixedEF.ShellCommands.edit_rec_dec_parser
374
375This command will read the selected record, decode it to its JSON representation, save
376that JSON to a temporary file on your computer, and launch your configured text editor.
377
378You may then perform whatever modifications to the JSON representation, save + leave your
379text editor.
380
381Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
382back to the record on the SIM card.
383
384This allows for easy interactive modification of records.
385
386
Harald Welteaefd0642022-02-25 15:26:37 +0100387decode_hex
388~~~~~~~~~~
389.. argparse::
390 :module: pySim.filesystem
391 :func: LinFixedEF.ShellCommands.dec_hex_parser
392
393
Harald Weltebe9516f2021-04-03 11:30:10 +0200394
395Transparent EF commands
396-----------------------
397
398These commands become enabled only when your currently selected file is of *Transparent EF* type.
399
400
401read_binary
402~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200403.. argparse::
404 :module: pySim.filesystem
405 :func: TransparentEF.ShellCommands.read_bin_parser
406
Harald Weltebe9516f2021-04-03 11:30:10 +0200407
408read_binary_decoded
409~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200410.. argparse::
411 :module: pySim.filesystem
412 :func: TransparentEF.ShellCommands.read_bin_dec_parser
413
Harald Weltebe9516f2021-04-03 11:30:10 +0200414
415update_binary
416~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200417.. argparse::
418 :module: pySim.filesystem
419 :func: TransparentEF.ShellCommands.upd_bin_parser
420
Harald Weltebe9516f2021-04-03 11:30:10 +0200421
422update_binary_decoded
423~~~~~~~~~~~~~~~~~~~~~
Harald Welted36f6942021-04-04 14:37:55 +0200424.. argparse::
425 :module: pySim.filesystem
426 :func: TransparentEF.ShellCommands.upd_bin_dec_parser
Harald Weltebe9516f2021-04-03 11:30:10 +0200427
Harald Welte0d4e98a2021-04-07 00:14:40 +0200428In normal operation, update_binary_decoded needs a JSON document representing the entire file contents as
429input. This can be inconvenient if you want to keep 99% of the content but just toggle one specific
430parameter. That's where the JSONpath support comes in handy: You can specify a JSONpath to an element
431inside the document as well as a new value for tat field:
432
433Th below example demonstrates this by modifying the ofm field within EF.AD:
434
435::
436
437 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
438 {
439 "ms_operation_mode": "normal",
440 "specific_facilities": {
441 "ofm": true
442 },
443 "len_of_mnc_in_imsi": 2
444 }
445 pySIM-shell (MF/ADF.USIM/EF.AD)> update_binary_decoded --json-path specific_facilities.ofm false
446 pySIM-shell (MF/ADF.USIM/EF.AD)> read_binary_decoded
447 {
448 "ms_operation_mode": "normal",
449 "specific_facilities": {
450 "ofm": false
451 },
452 "len_of_mnc_in_imsi": 2
453 }
454
Harald Weltebe9516f2021-04-03 11:30:10 +0200455
Harald Welte4145d3c2021-04-08 20:34:13 +0200456edit_binary_decoded
457~~~~~~~~~~~~~~~~~~~
458This command will read the selected binary EF, decode it to its JSON representation, save
459that JSON to a temporary file on your computer, and launch your configured text editor.
460
461You may then perform whatever modifications to the JSON representation, save + leave your
462text editor.
463
464Afterwards, the modified JSON will be re-encoded to the binary format, and the result written
465to the SIM card.
466
467This allows for easy interactive modification of file contents.
468
Harald Weltebe9516f2021-04-03 11:30:10 +0200469
Harald Welteaefd0642022-02-25 15:26:37 +0100470decode_hex
471~~~~~~~~~~
472.. argparse::
473 :module: pySim.filesystem
474 :func: TransparentEF.ShellCommands.dec_hex_parser
475
476
Harald Welte917d98c2021-04-21 11:51:25 +0200477
478BER-TLV EF commands
479-------------------
480
481BER-TLV EFs are files that contain BER-TLV structured data. Every file can contain any number
482of variable-length IEs (DOs). The tag within a BER-TLV EF must be unique within the file.
483
484The commands below become enabled only when your currently selected file is of *BER-TLV EF* type.
485
486retrieve_tags
487~~~~~~~~~~~~~
488
489Retrieve a list of all tags present in the currently selected file.
490
491
492retrieve_data
493~~~~~~~~~~~~~
494.. argparse::
495 :module: pySim.filesystem
496 :func: BerTlvEF.ShellCommands.retrieve_data_parser
497
498
499set_data
500~~~~~~~~
501.. argparse::
502 :module: pySim.filesystem
503 :func: BerTlvEF.ShellCommands.set_data_parser
504
505
506del_data
507~~~~~~~~
508.. argparse::
509 :module: pySim.filesystem
510 :func: BerTlvEF.ShellCommands.del_data_parser
511
512
513
Harald Welte15fae982021-04-10 10:22:27 +0200514USIM commands
515-------------
516
Harald Welte577312a2023-02-23 09:51:30 +0100517These commands are available only while ADF.USIM (or ADF.ISIM, respectively) is selected.
518
Harald Welte15fae982021-04-10 10:22:27 +0200519authenticate
520~~~~~~~~~~~~
521.. argparse::
522 :module: pySim.ts_31_102
523 :func: ADF_USIM.AddlShellCommands.authenticate_parser
524
Harald Welte12af7932022-02-15 16:39:08 +0100525terminal_profile
526~~~~~~~~~~~~~~~~
527.. argparse::
528 :module: pySim.ts_31_102
529 :func: ADF_USIM.AddlShellCommands.term_prof_parser
530
531envelope
532~~~~~~~~
533.. argparse::
534 :module: pySim.ts_31_102
535 :func: ADF_USIM.AddlShellCommands.envelope_parser
536
537envelope_sms
538~~~~~~~~~~~~
539.. argparse::
540 :module: pySim.ts_31_102
541 :func: ADF_USIM.AddlShellCommands.envelope_sms_parser
542
543
Harald Welte577312a2023-02-23 09:51:30 +0100544File-specific commands
545----------------------
546
547These commands are valid only if the respective file is currently selected. They perform some
548operation that's specific to this file only.
549
550EF.ARR: read_arr_record
551~~~~~~~~~~~~~~~~~~~~~~~
552Read one EF.ARR record in flattened, human-friendly form.
553
554EF.ARR: read_arr_records
555~~~~~~~~~~~~~~~~~~~~~~~~
556Read + decode all EF.ARR records in flattened, human-friendly form.
557
Harald Weltea07d5092023-02-23 10:02:49 +0100558ADF.USIM/EF.EST: est_service_enable
559~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
560Enables a single service in EF.EST. Requires service number as argument.
561
562ADF.USIM/EF.EST: est_service_disable
563~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
564Disables a single service in EF.EST. Requires service number as argument.
565
Harald Welte577312a2023-02-23 09:51:30 +0100566EF.IMSI: update_imsi_plmn
567~~~~~~~~~~~~~~~~~~~~~~~~~
568Change the PLMN part (MCC+MNC) of the IMSI. Requires a single argument consisting of 5/6 digits of
569concatenated MCC+MNC.
570
571ADF.USIM/EF.UST: ust_service_activate
572~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
573Activates a single service in EF.UST. Requires service number as argument.
574
575ADF.USIM/EF.UST: ust_service_deactivate
576~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
577Deactivates a single service in EF.UST. Requires service number as argument.
578
579ADF.USIM/EF.UST: ust_service_check
580~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
581Check consistency between services of this file and files present/activated.
582Many services determine if one or multiple files shall be present/activated or if they shall be
583absent/deactivated. This performs a consistency check to ensure that no services are activated
584for files that are not - and vice-versa, no files are activated for services that are not. Error
585messages are printed for every inconsistency found.
586
587ADF.ISIM/EF.IST: ist_service_activate
588~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
589Activates a single service in EF.IST. Requires service number as argument.
590
591ADF.ISIM/EF.IST: ist_service_deactivate
592~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
593Deactivates a single service in EF.UST. Requires service number as argument.
594
595ADF.ISIM/EF.IST: ist_service_check
596~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
597Check consistency between services of this file and files present/activated.
598Many services determine if one or multiple files shall be present/activated or if they shall be
599absent/deactivated. This performs a consistency check to ensure that no services are activated
600for files that are not - and vice-versa, no files are activated for services that are not. Error
601messages are printed for every inconsistency found.
602
603
604UICC Administrative commands
605----------------------------
606
607ETSI TS 102 222 specifies a set of *Administrative Commands*, which can
608be used by the card issuer / operator to modify the file system structure
609(delete files, create files) or even to terminate individual files or the
610entire card.
611
612pySim-shell supports those commands, but **use extreme caution**.
613Unless you know exactly what you're doing, it's very easy to render your
614card unusable. You've been warned!
615
616delete_file
617~~~~~~~~~~~
618.. argparse::
619 :module: pySim.ts_102_222
620 :func: Ts102222Commands.delfile_parser
621
622
623terminate_df
624~~~~~~~~~~~~
625.. argparse::
626 :module: pySim.ts_102_222
627 :func: Ts102222Commands.termdf_parser
628
629terminate_ef
630~~~~~~~~~~~~
631.. argparse::
632 :module: pySim.ts_102_222
633 :func: Ts102222Commands.termdf_parser
634
635terminate_card
636~~~~~~~~~~~~~~
637.. argparse::
638 :module: pySim.ts_102_222
639 :func: Ts102222Commands.tcard_parser
640
641create_ef
642~~~~~~~~~
643.. argparse::
644 :module: pySim.ts_102_222
645 :func: Ts102222Commands.create_parser
646
647create_df
648~~~~~~~~~
649.. argparse::
650 :module: pySim.ts_102_222
651 :func: Ts102222Commands.createdf_parser
Harald Welte12af7932022-02-15 16:39:08 +0100652
Harald Welte0707b802023-03-07 11:43:37 +0100653resize_ef
654~~~~~~~~~
655.. argparse::
656 :module: pySim.ts_102_222
657 :func: Ts102222Commands.resize_ef_parser
658
Harald Welte15fae982021-04-10 10:22:27 +0200659
Harald Welte95ce6b12021-10-20 18:40:54 +0200660ARA-M commands
661--------------
662
663The ARA-M commands exist to manage the access rules stored in an ARA-M applet on the card.
664
665ARA-M in the context of SIM cards is primarily used to enable Android UICC Carrier Privileges,
666please see https://source.android.com/devices/tech/config/uicc for more details on the background.
667
668
669aram_get_all
670~~~~~~~~~~~~
671
672Obtain and decode all access rules from the ARA-M applet on the card.
673
674NOTE: if the total size of the access rules exceeds 255 bytes, this command will fail, as
675it doesn't yet implement fragmentation/reassembly on rule retrieval. YMMV
676
677::
678
679 pySIM-shell (MF/ADF.ARA-M)> aram_get_all
680 [
681 {
682 "ResponseAllRefArDO": [
683 {
684 "RefArDO": [
685 {
686 "RefDO": [
687 {
688 "AidRefDO": "ffffffffffff"
689 },
690 {
691 "DevAppIdRefDO": "e46872f28b350b7e1f140de535c2a8d5804f0be3"
692 }
693 ]
694 },
695 {
696 "ArDO": [
697 {
698 "ApduArDO": {
699 "generic_access_rule": "always"
700 }
701 },
702 {
703 "PermArDO": {
704 "permissions": "0000000000000001"
705 }
706 }
707 ]
708 }
709 ]
710 }
711 ]
712 }
713 ]
714
715aram_get_config
716~~~~~~~~~~~~~~~
717Perform Config handshake with ARA-M applet: Tell it our version and retrieve its version.
718
719NOTE: Not supported in all ARA-M implementations.
720
Harald Welte95ce6b12021-10-20 18:40:54 +0200721
722aram_store_ref_ar_do
723~~~~~~~~~~~~~~~~~~~~
Harald Welte95ce6b12021-10-20 18:40:54 +0200724.. argparse::
725 :module: pySim.ara_m
726 :func: ADF_ARAM.AddlShellCommands.store_ref_ar_do_parse
727
728For 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 +0200729::
730
731 pySIM-shell (MF/ADF.ARA-M)> aram_store_ref_ar_do --aid FFFFFFFFFFFF --device-app-id E46872F28B350B7E1F140DE535C2A8D5804F0BE3 --android-permissions 0000000000000001 --apdu-always
732
733
734aram_delete_all
735~~~~~~~~~~~~~~~
736This command will request deletion of all access rules stored within the
737ARA-M applet. Use it with caution, there is no undo. Any rules later
738intended must be manually inserted again using `aram_store_ref_ar_do`
739
740
Harald Welte577312a2023-02-23 09:51:30 +0100741GlobalPlatform commands
742-----------------------
743
744pySim-shell has only the mots rudimentary support for GlobalPlatform at this point. Please use dedicated
745projects like GlobalPlatformPro meanwhile.
746
747get_data
748~~~~~~~~
749Performs the GET DATA command as specified by GlobalPlatform.
750
Harald Welte15fae982021-04-10 10:22:27 +0200751
Harald Weltebe9516f2021-04-03 11:30:10 +0200752cmd2 settable parameters
753------------------------
754
755``cmd2`` has the concept of *settable parameters* which act a bit like environment variables in an OS-level
756shell: They can be read and set, and they will influence the behavior somehow.
757
758conserve_write
759~~~~~~~~~~~~~~
760
761If enabled, pySim will (when asked to write to a card) always first read the respective file/record and
762verify if the to-be-written value differs from the current on-card value. If not, the write will be skipped.
763Writes will only be performed if the new value is different from the current on-card value.
764
765If disabled, pySim will always write irrespective of the current/new value.
766
Harald Welte1748b932021-04-06 21:12:25 +0200767json_pretty_print
768~~~~~~~~~~~~~~~~~
769
770This parameter determines if generated JSON output should (by default) be pretty-printed (multi-line
771output with indent level of 4 spaces) or not.
772
773The default value of this parameter is 'true'.
774
Harald Weltebe9516f2021-04-03 11:30:10 +0200775debug
776~~~~~
777
778If enabled, full python back-traces will be displayed in case of exceptions
779
Harald Welte7829d8a2021-04-10 11:28:53 +0200780apdu_trace
781~~~~~~~~~~
782
783Boolean variable that determines if a hex-dump of the command + response APDU shall be printed.
784
Harald Weltebe9516f2021-04-03 11:30:10 +0200785numeric_path
786~~~~~~~~~~~~
787
788Boolean variable that determines if path (e.g. in prompt) is displayed with numeric FIDs or string names.
789
790::
791
792 pySIM-shell (MF/EF.ICCID)> set numeric_path True
793 numeric_path - was: False
794 now: True
795 pySIM-shell (3f00/2fe2)> set numeric_path False
796 numeric_path - was: True
797 now: False
798 pySIM-shell (MF/EF.ICCID)> help set