laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27238 )
Change subject: Add scripts/deacivate-5g.script
......................................................................
Add scripts/deacivate-5g.script
This script can be used to deactivate all 5G related services and files.
Change-Id: I5dc3e9f0ae76a7ae57484e5a3369e11ff02c7eca
---
A scripts/deactivate-5g.script
1 file changed, 69 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/scripts/deactivate-5g.script b/scripts/deactivate-5g.script
new file mode 100644
index 0000000..13206fa
--- /dev/null
+++ b/scripts/deactivate-5g.script
@@ -0,0 +1,69 @@
+# script to be used with pySim-shell.py which is part of the Osmocom pysim package,
+# found at https://osmocom.org/projects/pysim/wiki
+set echo true
+
+# this script will deactivate all 5G related services and files. This can be used
+# in case you do not wish to use any 5G services, or you do not wish to configure
+# the 5G specific files on the USIM card. The card will then behave like a 3G USIM
+# without any 5G capability, using the default fall-back mechanisms specified by 3GPP.
+
+# TODO: add your card-specific ADM pin at the end of the verify_adm line below
+verify_adm
+
+# deactivate any 5G related services in EF.UST
+select ADF.USIM
+select EF.UST
+ust_service_deactivate 122
+ust_service_deactivate 123
+ust_service_deactivate 124
+ust_service_deactivate 125
+ust_service_deactivate 127
+ust_service_deactivate 129
+ust_service_deactivate 130
+ust_service_deactivate 132
+ust_service_deactivate 133
+ust_service_deactivate 134
+ust_service_deactivate 135
+
+# deactivate all files in EF.5GS
+select ADF.USIM
+select DF.5GS
+
+select EF.5GAUTHKEYS
+deactivate_file
+
+select EF.5GS3GPPLOCI
+deactivate_file
+
+select EF.5GSN3GPPNSC
+deactivate_file
+
+select EF.5GSN3GPPLOCI
+deactivate_file
+
+select EF.5GS3GPPNSC
+deactivate_file
+
+# only exists on sysmoISIM-SJA2v2
+select EF.OPL5G
+deactivate_file
+
+select EF.Routing_Indicator
+deactivate_file
+
+select EF.SUCI_Calc_Info
+deactivate_file
+
+select EF.SUPI_NAI
+deactivate_file
+
+# only exists on sysmoISIM-SJA2v2
+select EF.TN3GPPSNN
+deactivate_file
+
+select EF.UAC_AIC
+deactivate_file
+
+# only exists on sysmoISIM-SJA2v2
+select EF.URSP
+deactivate_file
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27238
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5dc3e9f0ae76a7ae57484e5a3369e11ff02c7eca
Gerrit-Change-Number: 27238
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27235 )
Change subject: shell: Proper argparser (for help + manual) activate_file
......................................................................
shell: Proper argparser (for help + manual) activate_file
Change-Id: I5929ae3deff4d15b5db4a1d866576271c57a955f
---
M docs/shell.rst
M pySim-shell.py
2 files changed, 11 insertions(+), 4 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/docs/shell.rst b/docs/shell.rst
index 58588a2..fcc171b 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -143,7 +143,12 @@
activate_file
~~~~~~~~~~~~~
-Activate the currently selected file. This used to be called REHABILITATE in TS 11.11.
+Activate the specified file. This used to be called REHABILITATE in TS 11.11.
+You need to specify the name or FID of the file to activate.
+
+.. argparse::
+ :module: pySim-shell
+ :func: Iso7816Commands.activate_file_parser
open_channel
~~~~~~~~~~~~
diff --git a/pySim-shell.py b/pySim-shell.py
index ad76ba0..ec417c7 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -805,13 +805,15 @@
self._cmd.poutput("CHV enable successful")
def do_deactivate_file(self, opts):
- """Deactivate the current EF"""
+ """Deactivate the currently selected EF"""
(data, sw) = self._cmd.card._scc.deactivate_file()
+ activate_file_parser = argparse.ArgumentParser()
+ activate_file_parser.add_argument('NAME', type=str, help='File name or FID of file to activate')
+ @cmd2.with_argparser(activate_file_parser)
def do_activate_file(self, opts):
"""Activate the specified EF"""
- path = opts.arg_list[0]
- (data, sw) = self._cmd.rs.activate_file(path)
+ (data, sw) = self._cmd.rs.activate_file(opts.NAME)
def complete_activate_file(self, text, line, begidx, endidx) -> List[str]:
"""Command Line tab completion for ACTIVATE FILE"""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27235
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5929ae3deff4d15b5db4a1d866576271c57a955f
Gerrit-Change-Number: 27235
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27237 )
Change subject: doc: Improve documentation in various places
......................................................................
doc: Improve documentation in various places
* don't duplicate information between .rst files and docstrings
* if there's more than a trivial single-line documentation, put it as
docstring into the python source and use ".. argparse" to pul it into
the manual
* add documentation for some commands for which it was missing
* show one level deeper in the navigation table, listing the commands
Change-Id: Ib88bb7d12faaac7d149ee1f6379bc128b83bbdd5
---
M docs/conf.py
M docs/index.rst
M docs/shell.rst
M pySim-shell.py
M pySim/ara_m.py
M pySim/ts_31_102.py
6 files changed, 91 insertions(+), 28 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/docs/conf.py b/docs/conf.py
index a96b87e..6fea583 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -18,7 +18,7 @@
# -- Project information -----------------------------------------------------
project = 'osmopysim-usermanual'
-copyright = '2009-2021 by Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle'
+copyright = '2009-2022 by Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle'
author = 'Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle'
diff --git a/docs/index.rst b/docs/index.rst
index c647880..471802a 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -34,7 +34,7 @@
* the [legacy] :ref:`pySim-prog and pySim-read tools<Legacy tools>`
.. toctree::
- :maxdepth: 2
+ :maxdepth: 3
:caption: Contents:
shell
diff --git a/docs/shell.rst b/docs/shell.rst
index 0f3139f..f24dc93 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -164,9 +164,6 @@
verify_chv
~~~~~~~~~~
-This command allows you to verify a CHV (PIN), which is how the specifications call
-it if you authenticate yourself with the said CHV/PIN.
-
.. argparse::
:module: pySim-shell
:func: Iso7816Commands.verify_chv_parser
@@ -178,9 +175,6 @@
activate_file
~~~~~~~~~~~~~
-Activate the specified file. This used to be called REHABILITATE in TS 11.11.
-You need to specify the name or FID of the file to activate.
-
.. argparse::
:module: pySim-shell
:func: Iso7816Commands.activate_file_parser
@@ -212,6 +206,7 @@
:func: Iso7816Commands.suspend_uicc_parser
+
pySim commands
--------------
@@ -221,7 +216,6 @@
desc
~~~~
-
Display human readable file description for the currently selected file.
@@ -231,6 +225,17 @@
:module: pySim-shell
:func: PySimCommands.dir_parser
+Example:
+::
+
+ pySIM-shell (MF)> dir
+ MF
+ 3f00
+ .. ADF.USIM DF.SYSTEM EF.DIR EF.UMPC
+ ADF.ARA-M DF.EIRENE DF.TELECOM EF.ICCID MF
+ ADF.ISIM DF.GSM EF.ARR EF.PL
+ 14 files
+
export
~~~~~~
@@ -250,15 +255,27 @@
tree
~~~~
-
Display a tree of the card filesystem. It is important to note that this displays a tree
of files that might potentially exist (based on the card profile). In order to determine if
a given file really exists on a given card, you have to try to select that file.
+Example:
+::
+
+ pySIM-shell (MF)> tree --help
+ EF.DIR 2f00 Application Directory
+ EF.ICCID 2fe2 ICC Identification
+ EF.PL 2f05 Preferred Languages
+ EF.ARR 2f06 Access Rule Reference
+ EF.UMPC 2f08 UICC Maximum Power Consumption
+ DF.TELECOM 7f10 None
+ EF.ADN 6f3a Abbreviated Dialing Numbers
+ ...
+
+
verify_adm
~~~~~~~~~~
-
Verify the ADM (Administrator) PIN specified as argument. This is typically needed in order
to get write/update permissions to most of the files on SIM cards.
@@ -286,8 +303,6 @@
:module: pySim-shell
:func: PysimApp.bulk_script_parser
-Run a script for bulk-provisioning of multiple cards.
-
echo
~~~~
@@ -296,6 +311,13 @@
:func: PysimApp.echo_parser
+apdu
+~~~~
+.. argparse::
+ :module: pySim-shell
+ :func: PySimCommands.apdu_cmd_parser
+
+
Linear Fixed EF commands
------------------------
@@ -484,6 +506,26 @@
:module: pySim.ts_31_102
:func: ADF_USIM.AddlShellCommands.authenticate_parser
+terminal_profile
+~~~~~~~~~~~~~~~~
+.. argparse::
+ :module: pySim.ts_31_102
+ :func: ADF_USIM.AddlShellCommands.term_prof_parser
+
+envelope
+~~~~~~~~
+.. argparse::
+ :module: pySim.ts_31_102
+ :func: ADF_USIM.AddlShellCommands.envelope_parser
+
+envelope_sms
+~~~~~~~~~~~~
+.. argparse::
+ :module: pySim.ts_31_102
+ :func: ADF_USIM.AddlShellCommands.envelope_sms_parser
+
+
+
ARA-M commands
--------------
@@ -546,21 +588,14 @@
NOTE: Not supported in all ARA-M implementations.
-.. argparse::
- :module: pySim.ara_m
- :func: ADF_ARAM.AddlShellCommands.get_config_parser
-
aram_store_ref_ar_do
~~~~~~~~~~~~~~~~~~~~
-Store a [new] access rule on the ARA-M applet.
-
.. argparse::
:module: pySim.ara_m
:func: ADF_ARAM.AddlShellCommands.store_ref_ar_do_parse
For 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:
-
::
pySIM-shell (MF/ADF.ARA-M)> aram_store_ref_ar_do --aid FFFFFFFFFFFF --device-app-id E46872F28B350B7E1F140DE535C2A8D5804F0BE3 --android-permissions 0000000000000001 --apdu-always
diff --git a/pySim-shell.py b/pySim-shell.py
index ec417c7..0753b10 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -683,7 +683,8 @@
def do_apdu(self, opts):
"""Send a raw APDU to the card, and print SW + Response.
DANGEROUS: pySim-shell will not know any card state changes, and
- not continue to work as expected if you e.g. select a different file."""
+ not continue to work as expected if you e.g. select a different
+ file."""
data, sw = self._cmd.card._scc._tp.send_apdu(opts.APDU)
self._cmd.poutput("SW: %s %s, RESP: %s" % (sw, self._cmd.rs.interpret_sw(sw), data))
@@ -739,7 +740,9 @@
@cmd2.with_argparser(verify_chv_parser)
def do_verify_chv(self, opts):
- """Verify (authenticate) using specified PIN code"""
+ """Verify (authenticate) using specified CHV (PIN) code, which is how the specifications
+ call it if you authenticate yourself using the specified PIN. There usually is at least PIN1 and
+ PIN2."""
pin = self.get_code(opts.pin_code)
(data, sw) = self._cmd.card._scc.verify_chv(opts.pin_nr, h2b(pin))
self._cmd.poutput("CHV verification successful")
@@ -812,7 +815,8 @@
activate_file_parser.add_argument('NAME', type=str, help='File name or FID of file to activate')
@cmd2.with_argparser(activate_file_parser)
def do_activate_file(self, opts):
- """Activate the specified EF"""
+ """Activate the specified EF. This used to be called REHABILITATE in TS 11.11 for classic
+ SIM. You need to specify the name or FID of the file to activate."""
(data, sw) = self._cmd.rs.activate_file(opts.NAME)
def complete_activate_file(self, text, line, begidx, endidx) -> List[str]:
diff --git a/pySim/ara_m.py b/pySim/ara_m.py
index 0928f8d..59f205c 100644
--- a/pySim/ara_m.py
+++ b/pySim/ara_m.py
@@ -311,7 +311,7 @@
self._cmd.poutput_json(res_do.to_dict())
def do_aram_get_config(self, opts):
- """GET DATA [Config] on the ARA-M Applet"""
+ """Perform GET DATA [Config] on the ARA-M Applet: Tell it our version and retrieve its version."""
res_do = ADF_ARAM.get_config(self._cmd.card._scc._tp)
if res_do:
self._cmd.poutput_json(res_do.to_dict())
@@ -345,7 +345,7 @@
@cmd2.with_argparser(store_ref_ar_do_parse)
def do_aram_store_ref_ar_do(self, opts):
- """Perform STORE DATA [Command-Store-REF-AR-DO] to store a new access rule."""
+ """Perform STORE DATA [Command-Store-REF-AR-DO] to store a (new) access rule."""
# REF
ref_do_content = []
if opts.aid:
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 3995dfa..c6bfa2d 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -1310,18 +1310,42 @@
(data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn)
self._cmd.poutput_json(data)
+ term_prof_parser = argparse.ArgumentParser()
+ term_prof_parser.add_argument('PROFILE', help='Hexstring of encoded terminal profile')
+
+ @cmd2.with_argparser(term_prof_parser)
def do_terminal_profile(self, arg):
- """Send a TERMINAL PROFILE command to the card."""
+ """Send a TERMINAL PROFILE command to the card.
+ This is used to inform the card about which optional
+ features the terminal (modem/phone) supports, particularly
+ in the context of SIM Toolkit, Proactive SIM and OTA. You
+ must specify a hex-string with the encoded terminal profile
+ you want to send to the card."""
(data, sw) = self._cmd.card._scc.terminal_profile(arg)
self._cmd.poutput('SW: %s, data: %s' % (sw, data))
+ envelope_parser = argparse.ArgumentParser()
+ envelope_parser.add_argument('PAYLOAD', help='Hexstring of encoded payload to ENVELOPE')
+
+ @cmd2.with_argparser(envelope_parser)
def do_envelope(self, arg):
- """Send an ENVELOPE command to the card."""
+ """Send an ENVELOPE command to the card. This is how a
+ variety of information is communicated from the terminal
+ (modem/phone) to the card, particularly in the context of
+ SIM Toolkit, Proactive SIM and OTA."""
(data, sw) = self._cmd.card._scc.envelope(arg)
self._cmd.poutput('SW: %s, data: %s' % (sw, data))
+ envelope_sms_parser = argparse.ArgumentParser()
+ envelope_sms_parser.add_argument('TPDU', help='Hexstring of encoded SMS TPDU')
+
+ @cmd2.with_argparser(envelope_sms_parser)
def do_envelope_sms(self, arg):
- """Send an ENVELOPE command to the card."""
+ """Send an ENVELOPE(SMS-PP-Download) command to the card.
+ This emulates a terminal (modem/phone) having received a SMS
+ with a PID of 'SMS for the SIM card'. You can use this
+ command in the context of testing OTA related features
+ without a modem/phone or a cellular netwokr."""
tpdu_ie = SMS_TPDU()
tpdu_ie.from_bytes(h2b(arg))
dev_ids = DeviceIdentities(
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27237
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib88bb7d12faaac7d149ee1f6379bc128b83bbdd5
Gerrit-Change-Number: 27237
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27208 )
Change subject: docs/legcay.txt: Point to pySim-shell as replacement
......................................................................
docs/legcay.txt: Point to pySim-shell as replacement
Change-Id: I9ca6b9d8c35e23be2ec8752107bb7d1e4f6f9bc1
---
M docs/legacy.rst
1 file changed, 8 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/docs/legacy.rst b/docs/legacy.rst
index ec3ddfc..d93358f 100644
--- a/docs/legacy.rst
+++ b/docs/legacy.rst
@@ -4,6 +4,9 @@
*legacy tools* are the classic ``pySim-prog`` and ``pySim-read`` programs that
existed long before ``pySim-shell``.
+These days, you should primarily use ``pySim-shell`` instead of these
+legacy tools.
+
pySim-prog
----------
@@ -45,6 +48,11 @@
``pySim-read`` allows you to read some data from a SIM card. It will only some files
of the card, and will only read files accessible to a normal user (without any special authentication)
+These days, you should use the ``export`` command of ``pySim-shell``
+instead. It performs a much more comprehensive export of all of the
+[standard] files that can be found on the card. To get a human-readable
+decode instead of the raw hex export, you can use ``export --json``.
+
Specifically, pySim-read will dump the following:
* MF
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27208
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I9ca6b9d8c35e23be2ec8752107bb7d1e4f6f9bc1
Gerrit-Change-Number: 27208
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27209 )
Change subject: pySim-shell: export: Add FCP template to export
......................................................................
pySim-shell: export: Add FCP template to export
The FCP template provides us a lot of context, like the permissions of
a given file. Let's make it part of the 'export' output, both in raw
and in decoded form.
Change-Id: I05f17bbebd7a9b3535204b821900851a5f66e88f
Closes: OS#5457
---
M pySim-shell.py
M pySim/filesystem.py
2 files changed, 6 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/pySim-shell.py b/pySim-shell.py
index 12f35fd..ad76ba0 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -532,6 +532,8 @@
structure = self._cmd.rs.selected_file_structure()
self._cmd.poutput("# structure: %s" % str(structure))
+ self._cmd.poutput("# RAW FCP Template: %s" % str(self._cmd.rs.selected_file_fcp_hex))
+ self._cmd.poutput("# Decoded FCP Template: %s" % str(self._cmd.rs.selected_file_fcp))
for f in df_path_list:
self._cmd.poutput("select " + str(f))
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 8303a4b..f8b86c5 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1221,6 +1221,8 @@
self.card = card
self.selected_file = self.mf # type: CardDF
self.profile = profile
+ self.selected_file_fcp = None
+ self.selected_file_fcp_hex = None
# make sure the class and selection control bytes, which are specified
# by the card profile are used
@@ -1464,7 +1466,8 @@
select_resp = f.decode_select_response(data)
else:
select_resp = self.probe_file(name, cmd_app)
- # store the decoded FCP for later reference
+ # store the raw + decoded FCP for later reference
+ self.selected_file_fcp_hex = data
self.selected_file_fcp = select_resp
self._select_post(cmd_app)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27209
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I05f17bbebd7a9b3535204b821900851a5f66e88f
Gerrit-Change-Number: 27209
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/27237 )
Change subject: doc: Improve documentation in various places
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27237
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib88bb7d12faaac7d149ee1f6379bc128b83bbdd5
Gerrit-Change-Number: 27237
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 18 Feb 2022 11:56:28 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment