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