Harald Welte | 94e8735 | 2021-04-02 13:38:00 +0200 | [diff] [blame] | 1 | pySim-shell |
| 2 | =========== |
Harald Welte | be9516f | 2021-04-03 11:30:10 +0200 | [diff] [blame^] | 3 | |
| 4 | pySim-shell is an interactive command line shell for all kind of interactions with SIM cards. |
| 5 | |
| 6 | The 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 | |
| 18 | By 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 | |
| 26 | |
| 27 | cmd2 basics |
| 28 | ----------- |
| 29 | |
| 30 | FIXME |
| 31 | |
| 32 | |
| 33 | |
| 34 | ISO7816 commands |
| 35 | ---------------- |
| 36 | |
| 37 | This category of commands relates to commands that originate in the ISO 7861-4 specifications, |
| 38 | most of them have a 1:1 resemblance in the specification. |
| 39 | |
| 40 | select |
| 41 | ~~~~~~ |
| 42 | |
| 43 | The ``select`` command is used to select a file, either by its FID, AID or by its symbolic name. |
| 44 | |
| 45 | Try ``select`` with tab-completion to get a list of all current selectable items: |
| 46 | |
| 47 | :: |
| 48 | |
| 49 | pySIM-shell (MF)> select |
| 50 | .. 2fe2 a0000000871004 EF.ARR MF |
| 51 | 2f00 3f00 ADF.ISIM EF.DIR |
| 52 | 2f05 7f10 ADF.USIM EF.ICCID |
| 53 | 2f06 7f20 DF.GSM EF.PL |
| 54 | 2f08 a0000000871002 DF.TELECOM EF.UMPC |
| 55 | |
| 56 | Use ``select`` with a specific FID or name to select the new file. |
| 57 | |
| 58 | This will |
| 59 | |
| 60 | * output the [JSON decoded, if possible] select response |
| 61 | * change the prompt to the newly selected file |
| 62 | * enable any commands specific to the newly-selected file |
| 63 | |
| 64 | :: |
| 65 | |
| 66 | pySIM-shell (MF)> select ADF.USIM |
| 67 | { |
| 68 | "file_descriptor": { |
| 69 | "shareable": true, |
| 70 | "file_type": "df", |
| 71 | "structure": "no_info_given" |
| 72 | }, |
| 73 | "df_name": "A0000000871002FFFFFFFF8907090000", |
| 74 | "proprietary_info": { |
| 75 | "uicc_characteristics": "71", |
| 76 | "available_memory": 101640 |
| 77 | }, |
| 78 | "life_cycle_status_int": "operational_activated", |
| 79 | "security_attrib_compact": "00", |
| 80 | "pin_status_template_do": "90017083010183018183010A83010B" |
| 81 | } |
| 82 | pySIM-shell (MF/ADF.USIM)> |
| 83 | |
| 84 | |
| 85 | |
| 86 | change_chv |
| 87 | ~~~~~~~~~~ |
| 88 | |
| 89 | This command allows you to change a CHV (PIN). |
| 90 | |
| 91 | |
| 92 | disable_chv |
| 93 | ~~~~~~~~~~~ |
| 94 | |
| 95 | This command allows you to disable a CHV (PIN). |
| 96 | |
| 97 | enable_chv |
| 98 | ~~~~~~~~~~ |
| 99 | |
| 100 | This command allows you to enable a CHV (PIN). |
| 101 | |
| 102 | |
| 103 | unblock_chv |
| 104 | ~~~~~~~~~~~ |
| 105 | |
| 106 | This command allows you to unblock a CHV (PIN) using the PUK. |
| 107 | |
| 108 | verify_chv |
| 109 | ~~~~~~~~~~ |
| 110 | |
| 111 | This command allows you to verify a CHV (PIN), which is how the specifications call |
| 112 | it if you authenticate yourself with the said CHV/PIN. |
| 113 | |
| 114 | |
| 115 | |
| 116 | pySim commands |
| 117 | -------------- |
| 118 | |
| 119 | Commands in this category are pySim specific; they do not have a 1:1 correspondence to ISO 7816 |
| 120 | or 3GPP commands. Mostly they will operate either only on local (in-memory) state, or execute |
| 121 | a complex sequence of card-commands. |
| 122 | |
| 123 | desc |
| 124 | ~~~~ |
| 125 | |
| 126 | Display human readable file description for the currently selected file. |
| 127 | |
| 128 | |
| 129 | dir |
| 130 | ~~~ |
| 131 | |
| 132 | :: |
| 133 | |
| 134 | usage: dir [-h] [--fids] [--names] [--apps] [--all] |
| 135 | |
| 136 | Show a listing of files available in currently selected DF or MF |
| 137 | |
| 138 | optional arguments: |
| 139 | -h, --help show this help message and exit |
| 140 | --fids Show file identifiers |
| 141 | --names Show file names |
| 142 | --apps Show applications |
| 143 | --all Show all selectable identifiers and names |
| 144 | |
| 145 | |
| 146 | export |
| 147 | ~~~~~~ |
| 148 | |
| 149 | tree |
| 150 | ~~~~ |
| 151 | |
| 152 | verify_adm |
| 153 | ~~~~~~~~~~ |
| 154 | |
| 155 | |
| 156 | |
| 157 | Linear Fixed EF commands |
| 158 | ------------------------ |
| 159 | |
| 160 | These commands become enabled only when your currently selected file is of *Linear Fixed EF* type. |
| 161 | |
| 162 | read_record |
| 163 | ~~~~~~~~~~~ |
| 164 | |
| 165 | read_record_decoded |
| 166 | ~~~~~~~~~~~~~~~~~~~ |
| 167 | |
| 168 | update_record |
| 169 | ~~~~~~~~~~~~~ |
| 170 | |
| 171 | update_record_decoded |
| 172 | ~~~~~~~~~~~~~~~~~~~~~ |
| 173 | |
| 174 | |
| 175 | |
| 176 | Transparent EF commands |
| 177 | ----------------------- |
| 178 | |
| 179 | These commands become enabled only when your currently selected file is of *Transparent EF* type. |
| 180 | |
| 181 | |
| 182 | read_binary |
| 183 | ~~~~~~~~~~~ |
| 184 | |
| 185 | read_binary_decoded |
| 186 | ~~~~~~~~~~~~~~~~~~~ |
| 187 | |
| 188 | update_binary |
| 189 | ~~~~~~~~~~~~~ |
| 190 | |
| 191 | update_binary_decoded |
| 192 | ~~~~~~~~~~~~~~~~~~~~~ |
| 193 | |
| 194 | |
| 195 | |
| 196 | cmd2 settable parameters |
| 197 | ------------------------ |
| 198 | |
| 199 | ``cmd2`` has the concept of *settable parameters* which act a bit like environment variables in an OS-level |
| 200 | shell: They can be read and set, and they will influence the behavior somehow. |
| 201 | |
| 202 | conserve_write |
| 203 | ~~~~~~~~~~~~~~ |
| 204 | |
| 205 | If enabled, pySim will (when asked to write to a card) always first read the respective file/record and |
| 206 | verify if the to-be-written value differs from the current on-card value. If not, the write will be skipped. |
| 207 | Writes will only be performed if the new value is different from the current on-card value. |
| 208 | |
| 209 | If disabled, pySim will always write irrespective of the current/new value. |
| 210 | |
| 211 | debug |
| 212 | ~~~~~ |
| 213 | |
| 214 | If enabled, full python back-traces will be displayed in case of exceptions |
| 215 | |
| 216 | numeric_path |
| 217 | ~~~~~~~~~~~~ |
| 218 | |
| 219 | Boolean variable that determines if path (e.g. in prompt) is displayed with numeric FIDs or string names. |
| 220 | |
| 221 | :: |
| 222 | |
| 223 | pySIM-shell (MF/EF.ICCID)> set numeric_path True |
| 224 | numeric_path - was: False |
| 225 | now: True |
| 226 | pySIM-shell (3f00/2fe2)> set numeric_path False |
| 227 | numeric_path - was: True |
| 228 | now: False |
| 229 | pySIM-shell (MF/EF.ICCID)> help set |