Daniel Willmann | de07b95 | 2020-10-19 10:32:34 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 2 | |
| 3 | # |
| 4 | # Utility to display some informations about a SIM card |
| 5 | # |
| 6 | # |
| 7 | # Copyright (C) 2009 Sylvain Munaut <tnt@246tNt.com> |
| 8 | # Copyright (C) 2010 Harald Welte <laforge@gnumonks.org> |
| 9 | # Copyright (C) 2013 Alexander Chemeris <alexander.chemeris@gmail.com> |
| 10 | # |
| 11 | # This program is free software: you can redistribute it and/or modify |
| 12 | # it under the terms of the GNU General Public License as published by |
| 13 | # the Free Software Foundation, either version 2 of the License, or |
| 14 | # (at your option) any later version. |
| 15 | # |
| 16 | # This program is distributed in the hope that it will be useful, |
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | # GNU General Public License for more details. |
| 20 | # |
| 21 | # You should have received a copy of the GNU General Public License |
| 22 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | # |
| 24 | |
| 25 | import hashlib |
Harald Welte | 8fe1d20 | 2021-04-11 12:31:40 +0200 | [diff] [blame] | 26 | import argparse |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 27 | import os |
| 28 | import random |
| 29 | import re |
| 30 | import sys |
Harald Welte | b314b9b | 2023-07-09 22:19:49 +0200 | [diff] [blame] | 31 | |
Harald Welte | 57ad38e | 2023-07-09 22:14:09 +0200 | [diff] [blame] | 32 | from pySim.ts_51_011 import EF_SST_map, EF_AD |
| 33 | from pySim.legacy.ts_51_011 import EF, DF |
Harald Welte | b314b9b | 2023-07-09 22:19:49 +0200 | [diff] [blame] | 34 | from pySim.ts_31_102 import EF_UST_map |
| 35 | from pySim.legacy.ts_31_102 import EF_USIM_ADF_map |
| 36 | from pySim.ts_31_103 import EF_IST_map |
| 37 | from pySim.legacy.ts_31_103 import EF_ISIM_ADF_map |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 38 | |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 39 | from pySim.commands import SimCardCommands |
Harald Welte | 8fe1d20 | 2021-04-11 12:31:40 +0200 | [diff] [blame] | 40 | from pySim.transport import init_reader, argparse_add_reader_args |
Philipp Maier | abc2336 | 2021-11-15 17:24:44 +0100 | [diff] [blame] | 41 | from pySim.exceptions import SwMatchError |
Harald Welte | f8d2e2b | 2023-07-09 17:58:38 +0200 | [diff] [blame] | 42 | from pySim.legacy.cards import card_detect, SimCard, UsimCard, IsimCard |
| 43 | from pySim.utils import h2b, h2s, swap_nibbles, rpad, dec_imsi, dec_iccid, dec_msisdn |
| 44 | from pySim.legacy.utils import format_xplmn_w_act, dec_st |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 45 | |
Harald Welte | f422eb1 | 2023-06-09 11:15:09 +0200 | [diff] [blame] | 46 | option_parser = argparse.ArgumentParser(description='Legacy tool for reading some parts of a SIM card', |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 47 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
Harald Welte | 8fe1d20 | 2021-04-11 12:31:40 +0200 | [diff] [blame] | 48 | argparse_add_reader_args(option_parser) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 49 | |
Philipp Maier | abc2336 | 2021-11-15 17:24:44 +0100 | [diff] [blame] | 50 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 51 | def select_app(adf: str, card: SimCard): |
| 52 | """Select application by its AID""" |
| 53 | sw = 0 |
| 54 | try: |
| 55 | if card._scc.cla_byte == "00": |
| 56 | data, sw = card.select_adf_by_aid(adf) |
| 57 | except SwMatchError as e: |
| 58 | if e.sw_actual == "6a82": |
| 59 | # If we can't select the file because it does not exist, we just remain silent since it means |
| 60 | # that this card just does not have an USIM application installed, which is not an error. |
| 61 | pass |
| 62 | else: |
| 63 | print("ADF." + adf + ": Can't select application -- " + str(e)) |
| 64 | except Exception as e: |
| 65 | print("ADF." + adf + ": Can't select application -- " + str(e)) |
| 66 | |
| 67 | return sw |
| 68 | |
Philipp Maier | abc2336 | 2021-11-15 17:24:44 +0100 | [diff] [blame] | 69 | |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 70 | if __name__ == '__main__': |
| 71 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 72 | # Parse options |
| 73 | opts = option_parser.parse_args() |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 74 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 75 | # Init card reader driver |
| 76 | sl = init_reader(opts) |
| 77 | if sl is None: |
| 78 | exit(1) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 79 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 80 | # Create command layer |
| 81 | scc = SimCardCommands(transport=sl) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 82 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 83 | # Wait for SIM card |
| 84 | sl.wait_for_card() |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 85 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 86 | # Assuming UICC SIM |
| 87 | scc.cla_byte = "00" |
| 88 | scc.sel_ctrl = "0004" |
Supreeth Herle | 3e6f16d | 2020-03-23 10:00:50 +0100 | [diff] [blame] | 89 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 90 | # Testing for Classic SIM or UICC |
| 91 | (res, sw) = sl.send_apdu(scc.cla_byte + "a4" + scc.sel_ctrl + "02" + "3f00") |
| 92 | if sw == '6e00': |
| 93 | # Just a Classic SIM |
| 94 | scc.cla_byte = "a0" |
| 95 | scc.sel_ctrl = "0000" |
Supreeth Herle | 3e6f16d | 2020-03-23 10:00:50 +0100 | [diff] [blame] | 96 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 97 | # Read the card |
| 98 | print("Reading ...") |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 99 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 100 | # Initialize Card object by auto detecting the card |
| 101 | card = card_detect("auto", scc) or SimCard(scc) |
Supreeth Herle | 4c306ab | 2020-03-18 11:38:00 +0100 | [diff] [blame] | 102 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 103 | # Read all AIDs on the UICC |
| 104 | card.read_aids() |
Supreeth Herle | 3bf4363 | 2020-03-20 20:20:27 +0100 | [diff] [blame] | 105 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 106 | # EF.ICCID |
| 107 | (res, sw) = card.read_iccid() |
| 108 | if sw == '9000': |
| 109 | print("ICCID: %s" % (res,)) |
| 110 | else: |
| 111 | print("ICCID: Can't read, response code = %s" % (sw,)) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 112 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 113 | # EF.IMSI |
| 114 | (res, sw) = card.read_imsi() |
| 115 | if sw == '9000': |
| 116 | print("IMSI: %s" % (res,)) |
| 117 | else: |
| 118 | print("IMSI: Can't read, response code = %s" % (sw,)) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 119 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 120 | # EF.GID1 |
| 121 | try: |
| 122 | (res, sw) = card.read_gid1() |
| 123 | if sw == '9000': |
| 124 | print("GID1: %s" % (res,)) |
| 125 | else: |
| 126 | print("GID1: Can't read, response code = %s" % (sw,)) |
| 127 | except Exception as e: |
| 128 | print("GID1: Can't read file -- %s" % (str(e),)) |
Supreeth Herle | ab46d62 | 2020-03-05 15:30:22 +0100 | [diff] [blame] | 129 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 130 | # EF.GID2 |
| 131 | try: |
| 132 | (res, sw) = card.read_binary('GID2') |
| 133 | if sw == '9000': |
| 134 | print("GID2: %s" % (res,)) |
| 135 | else: |
| 136 | print("GID2: Can't read, response code = %s" % (sw,)) |
| 137 | except Exception as e: |
| 138 | print("GID2: Can't read file -- %s" % (str(e),)) |
Supreeth Herle | 0e90e6c | 2020-03-05 15:33:00 +0100 | [diff] [blame] | 139 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 140 | # EF.SMSP |
| 141 | (res, sw) = card.read_record('SMSP', 1) |
| 142 | if sw == '9000': |
| 143 | print("SMSP: %s" % (res,)) |
| 144 | else: |
| 145 | print("SMSP: Can't read, response code = %s" % (sw,)) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 146 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 147 | # EF.SPN |
| 148 | try: |
| 149 | (res, sw) = card.read_spn() |
| 150 | if sw == '9000': |
| 151 | print("SPN: %s" % (res[0] or "Not available")) |
| 152 | print("Show in HPLMN: %s" % (res[1],)) |
| 153 | print("Hide in OPLMN: %s" % (res[2],)) |
| 154 | else: |
| 155 | print("SPN: Can't read, response code = %s" % (sw,)) |
| 156 | except Exception as e: |
| 157 | print("SPN: Can't read file -- %s" % (str(e),)) |
Supreeth Herle | f829945 | 2019-06-08 07:49:08 +0200 | [diff] [blame] | 158 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 159 | # EF.PLMNsel |
| 160 | try: |
| 161 | (res, sw) = card.read_binary('PLMNsel') |
| 162 | if sw == '9000': |
| 163 | print("PLMNsel: %s" % (res)) |
| 164 | else: |
| 165 | print("PLMNsel: Can't read, response code = %s" % (sw,)) |
| 166 | except Exception as e: |
| 167 | print("PLMNsel: Can't read file -- " + str(e)) |
Philipp Maier | a265049 | 2018-07-11 23:05:58 +0200 | [diff] [blame] | 168 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 169 | # EF.PLMNwAcT |
| 170 | try: |
| 171 | (res, sw) = card.read_plmn_act() |
| 172 | if sw == '9000': |
| 173 | print("PLMNwAcT:\n%s" % (res)) |
| 174 | else: |
| 175 | print("PLMNwAcT: Can't read, response code = %s" % (sw,)) |
| 176 | except Exception as e: |
| 177 | print("PLMNwAcT: Can't read file -- " + str(e)) |
Philipp Maier | a265049 | 2018-07-11 23:05:58 +0200 | [diff] [blame] | 178 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 179 | # EF.OPLMNwAcT |
| 180 | try: |
| 181 | (res, sw) = card.read_oplmn_act() |
| 182 | if sw == '9000': |
| 183 | print("OPLMNwAcT:\n%s" % (res)) |
| 184 | else: |
| 185 | print("OPLMNwAcT: Can't read, response code = %s" % (sw,)) |
| 186 | except Exception as e: |
| 187 | print("OPLMNwAcT: Can't read file -- " + str(e)) |
Philipp Maier | a265049 | 2018-07-11 23:05:58 +0200 | [diff] [blame] | 188 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 189 | # EF.HPLMNAcT |
| 190 | try: |
| 191 | (res, sw) = card.read_hplmn_act() |
| 192 | if sw == '9000': |
| 193 | print("HPLMNAcT:\n%s" % (res)) |
| 194 | else: |
| 195 | print("HPLMNAcT: Can't read, response code = %s" % (sw,)) |
| 196 | except Exception as e: |
| 197 | print("HPLMNAcT: Can't read file -- " + str(e)) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 198 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 199 | # EF.ACC |
| 200 | (res, sw) = card.read_binary('ACC') |
| 201 | if sw == '9000': |
| 202 | print("ACC: %s" % (res,)) |
| 203 | else: |
| 204 | print("ACC: Can't read, response code = %s" % (sw,)) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 205 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 206 | # EF.MSISDN |
| 207 | try: |
| 208 | (res, sw) = card.read_msisdn() |
| 209 | if sw == '9000': |
| 210 | # (npi, ton, msisdn) = res |
| 211 | if res is not None: |
| 212 | print("MSISDN (NPI=%d ToN=%d): %s" % res) |
| 213 | else: |
| 214 | print("MSISDN: Not available") |
| 215 | else: |
| 216 | print("MSISDN: Can't read, response code = %s" % (sw,)) |
| 217 | except Exception as e: |
| 218 | print("MSISDN: Can't read file -- " + str(e)) |
Alexander Chemeris | 6e58914 | 2013-07-04 17:34:06 +0400 | [diff] [blame] | 219 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 220 | # EF.AD |
| 221 | (res, sw) = card.read_binary('AD') |
| 222 | if sw == '9000': |
| 223 | print("Administrative data: %s" % (res,)) |
| 224 | ad = EF_AD() |
| 225 | decoded_data = ad.decode_hex(res) |
| 226 | print("\tMS operation mode: %s" % decoded_data['ms_operation_mode']) |
| 227 | if decoded_data['ofm']: |
| 228 | print("\tCiphering Indicator: enabled") |
| 229 | else: |
| 230 | print("\tCiphering Indicator: disabled") |
| 231 | else: |
| 232 | print("AD: Can't read, response code = %s" % (sw,)) |
Philipp Maier | ee908ae | 2019-03-21 16:21:12 +0100 | [diff] [blame] | 233 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 234 | # EF.SST |
| 235 | (res, sw) = card.read_binary('SST') |
| 236 | if sw == '9000': |
| 237 | print("SIM Service Table: %s" % res) |
| 238 | # Print those which are available |
| 239 | print("%s" % dec_st(res)) |
| 240 | else: |
| 241 | print("SIM Service Table: Can't read, response code = %s" % (sw,)) |
Supreeth Herle | e26331e | 2020-03-20 18:50:39 +0100 | [diff] [blame] | 242 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 243 | # Check whether we have th AID of USIM, if so select it by its AID |
| 244 | # EF.UST - File Id in ADF USIM : 6f38 |
| 245 | sw = select_app("USIM", card) |
| 246 | if sw == '9000': |
| 247 | # Select USIM profile |
| 248 | usim_card = UsimCard(scc) |
herlesupreeth | cebf8b1 | 2021-01-21 05:57:06 +0100 | [diff] [blame] | 249 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 250 | # EF.EHPLMN |
| 251 | if usim_card.file_exists(EF_USIM_ADF_map['EHPLMN']): |
| 252 | (res, sw) = usim_card.read_ehplmn() |
| 253 | if sw == '9000': |
| 254 | print("EHPLMN:\n%s" % (res)) |
| 255 | else: |
| 256 | print("EHPLMN: Can't read, response code = %s" % (sw,)) |
herlesupreeth | 4a3580b | 2020-09-29 10:11:36 +0200 | [diff] [blame] | 257 | |
Matan Perelman | 777ee9e | 2023-05-14 08:58:50 +0300 | [diff] [blame] | 258 | # EF.FPLMN |
| 259 | if usim_card.file_exists(EF_USIM_ADF_map['FPLMN']): |
| 260 | res, sw = usim_card.read_fplmn() |
| 261 | if sw == '9000': |
| 262 | print(f'FPLMN:\n{res}') |
| 263 | else: |
| 264 | print(f'FPLMN: Can\'t read, response code = {sw}') |
| 265 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 266 | # EF.UST |
| 267 | try: |
| 268 | if usim_card.file_exists(EF_USIM_ADF_map['UST']): |
| 269 | # res[0] - EF content of UST |
| 270 | # res[1] - Human readable format of services marked available in UST |
| 271 | (res, sw) = usim_card.read_ust() |
| 272 | if sw == '9000': |
| 273 | print("USIM Service Table: %s" % res[0]) |
| 274 | print("%s" % res[1]) |
| 275 | else: |
| 276 | print("USIM Service Table: Can't read, response code = %s" % (sw,)) |
| 277 | except Exception as e: |
| 278 | print("USIM Service Table: Can't read file -- " + str(e)) |
Supreeth Herle | 9641299 | 2020-03-22 08:20:11 +0100 | [diff] [blame] | 279 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 280 | # EF.ePDGId - Home ePDG Identifier |
| 281 | try: |
| 282 | if usim_card.file_exists(EF_USIM_ADF_map['ePDGId']): |
| 283 | (res, sw) = usim_card.read_epdgid() |
| 284 | if sw == '9000': |
| 285 | print("ePDGId:\n%s" % |
| 286 | (len(res) and res or '\tNot available\n',)) |
| 287 | else: |
| 288 | print("ePDGId: Can't read, response code = %s" % (sw,)) |
| 289 | except Exception as e: |
| 290 | print("ePDGId: Can't read file -- " + str(e)) |
Supreeth Herle | b1634db | 2020-03-22 10:00:43 +0100 | [diff] [blame] | 291 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 292 | # EF.ePDGSelection - ePDG Selection Information |
| 293 | try: |
| 294 | if usim_card.file_exists(EF_USIM_ADF_map['ePDGSelection']): |
| 295 | (res, sw) = usim_card.read_ePDGSelection() |
| 296 | if sw == '9000': |
| 297 | print("ePDGSelection:\n%s" % (res,)) |
| 298 | else: |
| 299 | print("ePDGSelection: Can't read, response code = %s" % (sw,)) |
| 300 | except Exception as e: |
| 301 | print("ePDGSelection: Can't read file -- " + str(e)) |
Supreeth Herle | 99d5555 | 2020-03-24 13:03:43 +0100 | [diff] [blame] | 302 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 303 | # Select ISIM application by its AID |
| 304 | sw = select_app("ISIM", card) |
| 305 | if sw == '9000': |
| 306 | # Select USIM profile |
| 307 | isim_card = IsimCard(scc) |
herlesupreeth | cebf8b1 | 2021-01-21 05:57:06 +0100 | [diff] [blame] | 308 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 309 | # EF.P-CSCF - P-CSCF Address |
| 310 | try: |
| 311 | if isim_card.file_exists(EF_ISIM_ADF_map['PCSCF']): |
| 312 | res = isim_card.read_pcscf() |
| 313 | print("P-CSCF:\n%s" % |
| 314 | (len(res) and res or '\tNot available\n',)) |
| 315 | except Exception as e: |
| 316 | print("P-CSCF: Can't read file -- " + str(e)) |
Supreeth Herle | 5ad9aec | 2020-03-24 17:26:40 +0100 | [diff] [blame] | 317 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 318 | # EF.DOMAIN - Home Network Domain Name e.g. ims.mncXXX.mccXXX.3gppnetwork.org |
| 319 | try: |
| 320 | if isim_card.file_exists(EF_ISIM_ADF_map['DOMAIN']): |
| 321 | (res, sw) = isim_card.read_domain() |
| 322 | if sw == '9000': |
| 323 | print("Home Network Domain Name: %s" % |
| 324 | (len(res) and res or 'Not available',)) |
| 325 | else: |
| 326 | print( |
| 327 | "Home Network Domain Name: Can't read, response code = %s" % (sw,)) |
| 328 | except Exception as e: |
| 329 | print("Home Network Domain Name: Can't read file -- " + str(e)) |
Supreeth Herle | 05b2807 | 2020-03-25 10:23:48 +0100 | [diff] [blame] | 330 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 331 | # EF.IMPI - IMS private user identity |
| 332 | try: |
| 333 | if isim_card.file_exists(EF_ISIM_ADF_map['IMPI']): |
| 334 | (res, sw) = isim_card.read_impi() |
| 335 | if sw == '9000': |
| 336 | print("IMS private user identity: %s" % |
| 337 | (len(res) and res or 'Not available',)) |
| 338 | else: |
| 339 | print( |
| 340 | "IMS private user identity: Can't read, response code = %s" % (sw,)) |
| 341 | except Exception as e: |
| 342 | print("IMS private user identity: Can't read file -- " + str(e)) |
Supreeth Herle | 3f67f9c | 2020-03-25 15:38:02 +0100 | [diff] [blame] | 343 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 344 | # EF.IMPU - IMS public user identity |
| 345 | try: |
| 346 | if isim_card.file_exists(EF_ISIM_ADF_map['IMPU']): |
| 347 | res = isim_card.read_impu() |
| 348 | print("IMS public user identity:\n%s" % |
| 349 | (len(res) and res or '\tNot available\n',)) |
| 350 | except Exception as e: |
| 351 | print("IMS public user identity: Can't read file -- " + str(e)) |
Supreeth Herle | 0c02d8a | 2020-03-26 09:00:06 +0100 | [diff] [blame] | 352 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 353 | # EF.UICCIARI - UICC IARI |
| 354 | try: |
| 355 | if isim_card.file_exists(EF_ISIM_ADF_map['UICCIARI']): |
| 356 | res = isim_card.read_iari() |
| 357 | print("UICC IARI:\n%s" % |
| 358 | (len(res) and res or '\tNot available\n',)) |
| 359 | except Exception as e: |
| 360 | print("UICC IARI: Can't read file -- " + str(e)) |
Supreeth Herle | be3b641 | 2020-06-01 12:53:57 +0200 | [diff] [blame] | 361 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 362 | # EF.IST |
| 363 | (res, sw) = card.read_binary('6f07') |
| 364 | if sw == '9000': |
| 365 | print("ISIM Service Table: %s" % res) |
| 366 | # Print those which are available |
| 367 | print("%s" % dec_st(res, table="isim")) |
| 368 | else: |
| 369 | print("ISIM Service Table: Can't read, response code = %s" % (sw,)) |
Supreeth Herle | ee15c77 | 2020-03-22 08:58:33 +0100 | [diff] [blame] | 370 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 371 | # Done for this card and maybe for everything ? |
| 372 | print("Done !\n") |