Project

General

Profile

Feature #4963

Implement an interactive pysim-shell

Added by laforge 9 months ago. Updated 6 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
Start date:
01/20/2021
Due date:
% Done:

100%

Spec Reference:

Description

pySim-prog was nice when there were only 5 parameters on a SIM that we could program, and where the use case was pretty limited. Today, we have SIM/USIM/ISIM cards with hundreds of files and even more parameters to program. We cannot add a command line argument for each file to pySim-prog.

Instead, this introduces an interactive command-line shell / REPL, in which one can navigate the file system of the card, read and update files both in raw format and in decoded/parsed format.

The idea is primarily inspired by Henryk Ploetz' venerable cyberflex-shell, but implemented on a more modern basis using the cmd2 python module.

You can see the very first prototype in the laforge/shell branch of pysim.git

You can do things with it like this:

Start-up and authenticate with adm pin

$ ./pysim-shell.py -p 0
Using PC/SC reader interface
Autodetected card type: sysmoISIM-SJA2
AIDs on card: ['a0000000871002ffffffff8907090000', 'a0000000871004ffffffff8907090000']
Welcome to pySim-shell!
pySIM-shell (3f00)> verify_adm 92990895

interactive help

pySIM-shell (3f00)> help

Documented commands (use 'help -v' for verbose/'help <topic>' for details):

ISO7816 Commands
================
read_binary  select_adf  select_file  update_binary  update_record  verify_chv

pySim Commands
==============
intro  verify_adm

USIM Commands
=============
read_ehplmn  ust_service_activate  ust_service_deactivate

pySim-shell built-in commands
=============================
alias  help     macro  quit          run_script  shell
edit   history  py     run_pyscript  set         shortcuts

more interactive help

pySIM-shell (3f00)> help read_binary
usage: read_binary [-h] [--file-id FILE_ID] [--offset OFFSET] [--length LENGTH] [--record-nr RECORD_NR]

Read binary data from a transparent EF

optional arguments:
  -h, --help            show this help message and exit
  --file-id FILE_ID     File ID
  --offset OFFSET       Byte offset for start of read
  --length LENGTH       Number of bytes to read
  --record-nr RECORD_NR
                        Number of record to read

navigating the FS and reading files

pySIM-shell (3f00)> select_file 7f20
['622c8202782183027f20a509800171830400018d088a01058b032f0601c60f90017083010183018183010a83010b']
pySIM-shell (3f00/7f20)> read_binary --file-id 6f07
089910070000400310

interaction with local filesystem, i.e. I/O redirect + shell commands

pySIM-shell (3f00)> select_adf a0000000871002
pySIM-shell (a0000000871002)> select_file 5f3b
pySIM-shell (a0000000871002/5f3b)> read_binary --file-id 4f20 > /tmp/f
pySIM-shell (a0000000871002/5f3b)> !cat /tmp/f
ffffffffffffffff07

piping output through shell tools like grep

pySIM-shell (3f00)> read_ust  | grep 86
        Service 86 - Allowed CSG Lists and corresponding indications

enabling/disabling services

pySIM-shell (3f00/7f20)> ust_service_activate 123
pySIM-shell (3f00/7f20)> ust_service_deactivate 123

The major tasks I see to make this go anywhere is:

  • have "File" class with encoder/decoder methods, which are registered automatically with a 'file system' layer that knows about the DF/ADF hierarchy
    • this allows us to have a "read-decoded" command, which will call the decode method of the file, automatically resolved by the selected FID/path
  • automatic mapping of file-name -> FID and FID -> file name
    • when printing (like in the path), use the human-readable names
    • allow users to use human-readable names in SELECT
  • decode + display the TLVs / FCPs after a SELECT (like cyberflex-shell
  • ability to enable/disable APDU trace
  • dynamically register/deregster commands based on the path, i.e. offer USIM commands only when in ADF_USIM

Related issues

Related to pySim - Bug #4962: add setup.py to pySimResolved01/20/2021

Associated revisions

Revision 62b2af80 (diff)
Added by dexter 8 months ago

ts_x1_xxx: fix typo

Change-Id: Ife6d3f1aaa4546ea424301f538c1e933fed6f6ae
Related: OS#4963

Revision 9d215982 (diff)
Added by dexter 8 months ago

pysim-shell: exit on reader init failure

Change-Id: Iadcc3612de425313198ebe1d968b3545a25a8733
Related: OS#4963

Revision 68da3ea1 (diff)
Added by dexter 8 months ago

pysim-shell: rename pysim-shell.py to pySim-shell.py

The executeable scripts usually start with "pySim-" (with capital 'S')
not "pysim-" prefix.

Change-Id: Ia94769fe242b672d9214cdd3442f32a734a6f5d1
Related: OS#4963

Revision 0fece4cd (diff)
Added by dexter 8 months ago

ts_102_221: fix wrong array element indexing in FCP parsing

The python array indexing is complex. Its not x[start:length], its
x[start:end] instead. Also the offests used are off by one.

Change-Id: If8abcd5f5edf5872bebf8b131962fd4342dd1ae1
Related: OS#4963

Revision 8121bcf4 (diff)
Added by dexter 8 months ago

filesystem: add flags to filter selectables

When requesting what DF/EF/ADF are selectable it is useful to have some
control of what we do not want in the resulting list.

Change-Id: Idb50a512bfdbfdf2e98f2ce0e89928cb0ff19f5e
Related: OS#4963

Revision 09a5cd97 (diff)
Added by dexter 8 months ago

filesystem: case insensitive select.

It makes sense to have a case insensitive select since for example 6f20
and 6F20 or ef.adn and EF.ADN are actually the same.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision 10f23ec6 (diff)
Added by dexter 8 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision 0ffaf013 (diff)
Added by dexter 8 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision ac56fc9c (diff)
Added by dexter 8 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision 42e42e4e (diff)
Added by dexter 8 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 37f828a3 (diff)
Added by dexter 8 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 013ff2e2 (diff)
Added by dexter 8 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision 928971d5 (diff)
Added by dexter 8 months ago

filesystem: fall back to profile when app does not define interpret_sw

An application can have own status words that are different from what is
defined in the card profile. However, the ADF still may lack the
interpret_sw method. If this is the case we fall back to the card
profile.

Change-Id: I52812af2a6ea33ed801c8bcebcc7487240af148b
Related: OS#4963

Revision 56bf9ecf (diff)
Added by laforge 8 months ago

Add a new pySim-shell program

pySim-prog was nice when there were only 5 parameters on a SIM that we
could program, and where the use case was pretty limited. Today, we
have SIM/USIM/ISIM cards with hundreds of files and even more parameters
to program. We cannot add a command line argument for each file to
pySim-prog.

Instead, this introduces an interactive command-line shell / REPL,
in which one can navigate the file system of the card, read and update
files both in raw format and in decoded/parsed format.

The idea is primarily inspired by Henryk Ploatz' venerable
cyberflex-shell, but implemented on a more modern basis using
the cmd2 python module.

Most code by Harald Welte. Some bug fixes by Philipp Maier
have been squashed.

Change-Id: Iad117596e922223bdc1e5b956f84844b7c577e02
Related: OS#4963

Revision 16c62759 (diff)
Added by dexter 8 months ago

filesystem: add flags to filter selectables

When requesting what DF/EF/ADF are selectable it is useful to have some
control of what we do not want in the resulting list.

Change-Id: Idb50a512bfdbfdf2e98f2ce0e89928cb0ff19f5e
Related: OS#4963

Revision ebf17980 (diff)
Added by dexter 8 months ago

filesystem: case insensitive select.

It makes sense to have a case insensitive select since for example 6f20
and 6F20 or ef.adn and EF.ADN are actually the same.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision a0ed1524 (diff)
Added by dexter 8 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision 995f5772 (diff)
Added by dexter 8 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision 4d44913f (diff)
Added by dexter 8 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision ceaeb973 (diff)
Added by dexter 8 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision bfdc63d7 (diff)
Added by dexter 8 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 9b1e12ad (diff)
Added by dexter 8 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision 670e6fbd (diff)
Added by laforge 8 months ago

Add a new pySim-shell program

pySim-prog was nice when there were only 5 parameters on a SIM that we
could program, and where the use case was pretty limited. Today, we
have SIM/USIM/ISIM cards with hundreds of files and even more parameters
to program. We cannot add a command line argument for each file to
pySim-prog.

Instead, this introduces an interactive command-line shell / REPL,
in which one can navigate the file system of the card, read and update
files both in raw format and in decoded/parsed format.

The idea is primarily inspired by Henryk Ploatz' venerable
cyberflex-shell, but implemented on a more modern basis using
the cmd2 python module.

Most code by Harald Welte. Some bug fixes by Philipp Maier
have been squashed.

Change-Id: Iad117596e922223bdc1e5b956f84844b7c577e02
Related: OS#4963

Revision 00683cc8 (diff)
Added by dexter 8 months ago

filesystem: add flags to filter selectables

When requesting what DF/EF/ADF are selectable it is useful to have some
control of what we do not want in the resulting list.

Change-Id: Idb50a512bfdbfdf2e98f2ce0e89928cb0ff19f5e
Related: OS#4963

Revision 6b2d1a34 (diff)
Added by dexter 8 months ago

filesystem: case insensitive select.

It makes sense to have a case insensitive select since for example 6f20
and 6F20 or ef.adn and EF.ADN are actually the same.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision a1809a46 (diff)
Added by dexter 8 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision 7f2fb567 (diff)
Added by dexter 8 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision d123d144 (diff)
Added by dexter 8 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision 982504b6 (diff)
Added by dexter 8 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 14314caa (diff)
Added by dexter 8 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision e0abf0d9 (diff)
Added by dexter 8 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision b2edd144 (diff)
Added by laforge 8 months ago

Add a new pySim-shell program

pySim-prog was nice when there were only 5 parameters on a SIM that we
could program, and where the use case was pretty limited. Today, we
have SIM/USIM/ISIM cards with hundreds of files and even more parameters
to program. We cannot add a command line argument for each file to
pySim-prog.

Instead, this introduces an interactive command-line shell / REPL,
in which one can navigate the file system of the card, read and update
files both in raw format and in decoded/parsed format.

The idea is primarily inspired by Henryk Ploatz' venerable
cyberflex-shell, but implemented on a more modern basis using
the cmd2 python module.

See https://lists.osmocom.org/pipermail/simtrace/2021-January/000860.html
and https://lists.osmocom.org/pipermail/simtrace/2021-February/000864.html
for some related background.

Most code by Harald Welte. Some bug fixes by Philipp Maier
have been squashed.

Change-Id: Iad117596e922223bdc1e5b956f84844b7c577e02
Related: OS#4963

Revision 1024fb46 (diff)
Added by dexter 8 months ago

filesystem: add flags to filter selectables

When requesting what DF/EF/ADF are selectable it is useful to have some
control of what we do not want in the resulting list.

Change-Id: Idb50a512bfdbfdf2e98f2ce0e89928cb0ff19f5e
Related: OS#4963

Revision 26e88296 (diff)
Added by dexter 8 months ago

filesystem: case insensitive select.

It makes sense to have a case insensitive select since for example 6f20
and 6F20 or ef.adn and EF.ADN are actually the same.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision 9f3e44db (diff)
Added by dexter 8 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision 0aff9c5a (diff)
Added by dexter 8 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision 6852e55a (diff)
Added by dexter 8 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision 17ce6ff0 (diff)
Added by dexter 8 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 058e11ae (diff)
Added by dexter 8 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision df848a16 (diff)
Added by dexter 8 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision 6b031dd6 (diff)
Added by dexter 7 months ago

filesystem: add flags to filter selectables

When requesting what DF/EF/ADF are selectable it is useful to have some
control of what we do not want in the resulting list.

Change-Id: Idb50a512bfdbfdf2e98f2ce0e89928cb0ff19f5e
Related: OS#4963

Revision ff5be270 (diff)
Added by dexter 7 months ago

filesystem: be case insensitive when selecting files by fid (HEX)

The file identifier (and allso application ids for ADFs), are
hexadecimal. We should be case insensitive when accepting hex
identifiers but file names should still be full matched.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision 06a42e10 (diff)
Added by dexter 7 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision 0f201926 (diff)
Added by dexter 7 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision 8a71670e (diff)
Added by dexter 7 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision 2a7e2fa8 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 0ae049be (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 3178a6c3 (diff)
Added by dexter 7 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision 273c61ff (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision fab5969f (diff)
Added by dexter 7 months ago

utils: add is_hex function to check hex strings

since we have added pySim-shell.py that has a lot of locations where the
user can enter hexadecimal data there is an increased need for input
validation. Lets add a central is_hex function that verifies hex
strings.

Change-Id: Ia29a13c9215357dd2adf141f2ef222c823f8456d
Related: OS#4963

Revision 6689dfe8 (diff)
Added by dexter 7 months ago

filesystem: be case insensitive when selecting files by fid (HEX)

The file identifier (and allso application ids for ADFs), are
hexadecimal. We should be case insensitive when accepting hex
identifiers but file names should still be full matched.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision cbd43bc9 (diff)
Added by dexter 7 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision 4e059f79 (diff)
Added by dexter 7 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision 4f67c55d (diff)
Added by dexter 7 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision a6099f83 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 4875d5ba (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 4261243d (diff)
Added by dexter 7 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision 23c76aa3 (diff)
Added by dexter 7 months ago

filesystem: fix exception string (fid != name)

It is better to use the term "fid" instead of "name" when a reserved FID
is detected.

Change-Id: I054f3b3a156f0164c62610cfde1aec2145c20925
Related: OS#4963

Revision ec2f02f2 (diff)
Added by dexter 7 months ago

filesystem: add comment to inform about checks in add_file()

The method add_file of class CardDF does some constraint checking
to the basic file parameters (e.g. fid). Since one might also expect
those checks in the superclass CardFile lets leave a comment to make
the code better understandable.

Change-Id: Iebae28909fe6aade3bd4024112a222819572d735
Related: OS#4963

Revision 61f4d5e1 (diff)
Added by dexter 7 months ago

filesystem: be more strict in method add_file()

The file identifier of a file is strictly defined as a two digit
hexadecimal number. Do not allow adding child files that violate this
constraint.

Since the human readable name also plays a major role in identifying
the type of the file (ADF, EF or DF) ensure that when adding files it
is ensured that the file actually has a name and that the name starts
with "DF.", "EF." or "ADF.".

Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963

Revision ed70717b (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 17174960 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision f54e827a (diff)
Added by dexter 7 months ago

pysim-shell: select MF on startup to make commands accessible

On the cration of the PysimApp object only the basic commands in
pySim-shell.py are registered, since the MF is only created but not
selected, the file specific commands of the MF are not available. To
make them available, select the MF once on startup before entering the
cmdloop.

Change-Id: Ib63191f44e7c8ae07b0128a9affba40b44957adc
Related: OS#4963

Revision 5304c5ac (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision 96b50b58 (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision 1dc852ca (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision 37cafc55 (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision 579c418c (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision 80d52ee4 (diff)
Added by dexter 7 months ago

filesystem: drop main from filesystem.py

The main function in filesystem.py seems to be some experimental
testcode from the very beginning of pySim-shell. Lets drop it.

Change-Id: I34f459469dfc45711ad0928c83184d7f99e0f5e3
Related: OS#4963

Revision 3b37270a (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision 66a6cad4 (diff)
Added by dexter 7 months ago

commands: better exception string for authentication failures

At the moment we use the send_apdu_checksw() method to send the APDU for
ADM authentication. This method only checks if the command returns with
sw = 9000. If not it raises an exception that the sw is not as expected.
The user may think that this is a problem with thr reader, pcscd or
pySim in the first place and may try multiple times until the card is
permanently locked. A better execption string that also displays the
tries which are left may be helpful.

Change-Id: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13
Related: OS#4963

Revision cc54bad0 (diff)
Added by dexter 7 months ago

cards: remove unnecessary execptions.

The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.

Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963

Revision 6856368b (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision 786f781a (diff)
Added by dexter 7 months ago

filesystem: add flags to filter selectables

When requesting what DF/EF/ADF are selectable it is useful to have some
control of what we do not want in the resulting list.

Change-Id: Idb50a512bfdbfdf2e98f2ce0e89928cb0ff19f5e
Related: OS#4963

Revision 47236500 (diff)
Added by dexter 7 months ago

utils: add is_hex function to check hex strings

since we have added pySim-shell.py that has a lot of locations where the
user can enter hexadecimal data there is an increased need for input
validation. Lets add a central is_hex function that verifies hex
strings.

Change-Id: Ia29a13c9215357dd2adf141f2ef222c823f8456d
Related: OS#4963

Revision 7744b6e9 (diff)
Added by dexter 7 months ago

filesystem: be case insensitive when selecting files by fid (HEX)

The file identifier (and allso application ids for ADFs), are
hexadecimal. We should be case insensitive when accepting hex
identifiers but file names should still be full matched.

Change-Id: Ibe283a108ddc9058af77c823b7222db555e1e0f6
Related: OS#4963

Revision 50a89af2 (diff)
Added by dexter 7 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision da2c28f2 (diff)
Added by dexter 7 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision 35841a2b (diff)
Added by dexter 7 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision 9f35d60a (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 68b6c930 (diff)
Added by dexter 7 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision fb82f57c (diff)
Added by dexter 7 months ago

filesystem: fix exception string (fid != name)

It is better to use the term "fid" instead of "name" when a reserved FID
is detected.

Change-Id: I054f3b3a156f0164c62610cfde1aec2145c20925
Related: OS#4963

Revision aca19742 (diff)
Added by dexter 7 months ago

filesystem: add comment to inform about checks in add_file()

The method add_file of class CardDF does some constraint checking
to the basic file parameters (e.g. fid). Since one might also expect
those checks in the superclass CardFile lets leave a comment to make
the code better understandable.

Change-Id: Iebae28909fe6aade3bd4024112a222819572d735
Related: OS#4963

Revision 559bd54d (diff)
Added by dexter 7 months ago

filesystem: be more strict in method add_file()

The file identifier of a file is strictly defined as a two digit
hexadecimal number. Do not allow adding child files that violate this
constraint.

Since the human readable name also plays a major role in identifying
the type of the file (ADF, EF or DF) ensure that when adding files it
is ensured that the file actually has a name and that the name starts
with "DF.", "EF." or "ADF.".

Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963

Revision fc7314e5 (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision cb932540 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 7e5c3ce4 (diff)
Added by dexter 7 months ago

pysim-shell: select MF on startup to make commands accessible

On the cration of the PysimApp object only the basic commands in
pySim-shell.py are registered, since the MF is only created but not
selected, the file specific commands of the MF are not available. To
make them available, select the MF once on startup before entering the
cmdloop.

Change-Id: Ib63191f44e7c8ae07b0128a9affba40b44957adc
Related: OS#4963

Revision 537a9546 (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision c5a78ba6 (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision d98af9b6 (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision 63a7005b (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision d126a008 (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision abc6c75b (diff)
Added by dexter 7 months ago

filesystem: drop main from filesystem.py

The main function in filesystem.py seems to be some experimental
testcode from the very beginning of pySim-shell. Lets drop it.

Change-Id: I34f459469dfc45711ad0928c83184d7f99e0f5e3
Related: OS#4963

Revision 598a8c46 (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision d78a2417 (diff)
Added by dexter 7 months ago

commands: better exception string for authentication failures

At the moment we use the send_apdu_checksw() method to send the APDU for
ADM authentication. This method only checks if the command returns with
sw = 9000. If not it raises an exception that the sw is not as expected.
The user may think that this is a problem with thr reader, pcscd or
pySim in the first place and may try multiple times until the card is
permanently locked. A better execption string that also displays the
tries which are left may be helpful.

Change-Id: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13
Related: OS#4963

Revision 8f144409 (diff)
Added by dexter 7 months ago

cards: remove unnecessary execptions.

The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.

Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963

Revision 0a0162ae (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision 9f684f56 (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 71785985 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 85bf5db0 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 41555736 (diff)
Added by dexter 7 months ago

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963

Revision bd8ed2c4 (diff)
Added by dexter 7 months ago

filesystem: fix flag model used with get_selectable_names()

The flags NAMES, FIDS and APPS do not properly distinguish between
applications and normal files. With APPS it is only possible to exclude
or include the selectable applications in a list with NAMES or FIDS, but
it is not possible to get only the application names or identifiers.

- remove the APPS flag
- rename NAMES to FNAMES and make it only normal file related
- add ANAMES and relate it only to application (ADF) names
- add AIDS and relate it only to application identifiers

Change-Id: Id07e0dcbab10cd78c1b78d37319b7b0e5e83b64d
Related: OS#4963

Revision 5d3e2592 (diff)
Added by dexter 7 months ago

pySim-shell: add "dir" command.

pysim-shell does not have a convinient way to list the files available
in one directory. Tab completion currently is the only way to obtain a
list of the available files. Lets add a dir command to print a file
list.

Change-Id: Ic06a60e0a0ec54d9bb26e151453ceb49d69e3df7
Related: OS#4963

Revision ff9dae24 (diff)
Added by dexter 7 months ago

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963

Revision 6c0db4d9 (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision d202b744 (diff)
Added by dexter 7 months ago

pySim-shell: add basic filesystem check

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision dd6e23c7 (diff)
Added by dexter 7 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision 6725de1d (diff)
Added by dexter 7 months ago

filesystem: fix exception string (fid != name)

It is better to use the term "fid" instead of "name" when a reserved FID
is detected.

Change-Id: I054f3b3a156f0164c62610cfde1aec2145c20925
Related: OS#4963

Revision 2d125024 (diff)
Added by dexter 7 months ago

filesystem: add comment to inform about checks in add_file()

The method add_file of class CardDF does some constraint checking
to the basic file parameters (e.g. fid). Since one might also expect
those checks in the superclass CardFile lets leave a comment to make
the code better understandable.

Change-Id: Iebae28909fe6aade3bd4024112a222819572d735
Related: OS#4963

Revision 0ec50b1b (diff)
Added by dexter 7 months ago

filesystem: be more strict in method add_file()

The file identifier of a file is strictly defined as a two digit
hexadecimal number. Do not allow adding child files that violate this
constraint.

Since the human readable name also plays a major role in identifying
the type of the file (ADF, EF or DF) ensure that when adding files it
is ensured that the file actually has a name and that the name starts
with "DF.", "EF." or "ADF.".

Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963

Revision 29ea1d99 (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 33122cf2 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 964c6dc3 (diff)
Added by dexter 7 months ago

pysim-shell: select MF on startup to make commands accessible

On the cration of the PysimApp object only the basic commands in
pySim-shell.py are registered, since the MF is only created but not
selected, the file specific commands of the MF are not available. To
make them available, select the MF once on startup before entering the
cmdloop.

Change-Id: Ib63191f44e7c8ae07b0128a9affba40b44957adc
Related: OS#4963

Revision edd91774 (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision fa0bae2f (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision 3dc22aab (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision cc5e1b0d (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision b445e1a5 (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision bfda7828 (diff)
Added by dexter 7 months ago

filesystem: drop main from filesystem.py

The main function in filesystem.py seems to be some experimental
testcode from the very beginning of pySim-shell. Lets drop it.

Change-Id: I34f459469dfc45711ad0928c83184d7f99e0f5e3
Related: OS#4963

Revision 744ef5e6 (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision ea38054e (diff)
Added by dexter 7 months ago

commands: better exception string for authentication failures

At the moment we use the send_apdu_checksw() method to send the APDU for
ADM authentication. This method only checks if the command returns with
sw = 9000. If not it raises an exception that the sw is not as expected.
The user may think that this is a problem with thr reader, pcscd or
pySim in the first place and may try multiple times until the card is
permanently locked. A better execption string that also displays the
tries which are left may be helpful.

Change-Id: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13
Related: OS#4963

Revision 8fadb1ac (diff)
Added by dexter 7 months ago

cards: remove unnecessary execptions.

The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.

Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963

Revision 1f890b99 (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision b8ed4162 (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 069074da (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 6d774d41 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision e8bc1b42 (diff)
Added by dexter 7 months ago

filesystem: fix exception string (fid != name)

It is better to use the term "fid" instead of "name" when a reserved FID
is detected.

Change-Id: I054f3b3a156f0164c62610cfde1aec2145c20925
Related: OS#4963

Revision 66061580 (diff)
Added by dexter 7 months ago

filesystem: add comment to inform about checks in add_file()

The method add_file of class CardDF does some constraint checking
to the basic file parameters (e.g. fid). Since one might also expect
those checks in the superclass CardFile lets leave a comment to make
the code better understandable.

Change-Id: Iebae28909fe6aade3bd4024112a222819572d735
Related: OS#4963

Revision d51d8b55 (diff)
Added by dexter 7 months ago

filesystem: drop main from filesystem.py

The main function in filesystem.py seems to be some experimental
testcode from the very beginning of pySim-shell. Lets drop it.

Change-Id: I34f459469dfc45711ad0928c83184d7f99e0f5e3
Related: OS#4963

Revision 989e9b6a (diff)
Added by dexter 7 months ago

commands: better exception string for authentication failures

At the moment we use the send_apdu_checksw() method to send the APDU for
ADM authentication. This method only checks if the command returns with
sw = 9000. If not it raises an exception that the sw is not as expected.
The user may think that this is a problem with thr reader, pcscd or
pySim in the first place and may try multiple times until the card is
permanently locked. A better execption string that also displays the
tries which are left may be helpful.

Change-Id: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13
Related: OS#4963

Revision 2bc7d816 (diff)
Added by dexter 7 months ago

cards: remove unnecessary execptions.

The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.

Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963

Revision 585f4f99 (diff)
Added by dexter 7 months ago

filesystem: be more strict in method add_file()

The file identifier of a file is strictly defined as a two digit
hexadecimal number. Do not allow adding child files that violate this
constraint.

Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963

Revision e6e3dfd9 (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 07ebeb29 (diff)
Added by dexter 7 months ago

pySim-shell: add basic filesystem check

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision 7129de34 (diff)
Added by dexter 7 months ago

ts_102_221: fix fixup_fcp_proprietary_tlv_map()

According to its description, the function
fixup_fcp_proprietary_tlv_map() is supposed to add propritary TLV tags
to satisfy the pyTlv parser, which can't handle unexpected tags.
However, the function adds tags but it does only fill up the gaps from
0xd0 onwards. This makes no sense, lets extended it so that it adds a
propritary tag for each tag that it is not already in the dictionary so
that we get a continious dictionary that starts at 0x00 and ends at 0xff

Change-Id: Ib06041361851f05dd990576fff47048dc1aa6290
Related: OS#4963

Revision bb41e3f5 (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 82f8ad5f (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision b560fd77 (diff)
Added by dexter 7 months ago

pysim-shell: select MF on startup to make commands accessible

On the cration of the PysimApp object only the basic commands in
pySim-shell.py are registered, since the MF is only created but not
selected, the file specific commands of the MF are not available. To
make them available, select the MF once on startup before entering the
cmdloop.

Change-Id: Ib63191f44e7c8ae07b0128a9affba40b44957adc
Related: OS#4963

Revision 0fb885ed (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision a2f010a3 (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision 37d3d989 (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision d403793c (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision 2d460669 (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision 7a199158 (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision c7f8e696 (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision 6340436a (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision a2b07506 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision dad0547f (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 3aec8719 (diff)
Added by dexter 7 months ago

filesystem: be more strict in method add_file()

The file identifier of a file is strictly defined as a two digit
hexadecimal number. Do not allow adding child files that violate this
constraint.

Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963

Revision a31e9a9a (diff)
Added by dexter 7 months ago

commands: better exception string for authentication failures

At the moment we use the send_apdu_checksw() method to send the APDU for
ADM authentication. This method only checks if the command returns with
sw = 9000. If not it raises an exception that the sw is not as expected.
The user may think that this is a problem with thr reader, pcscd or
pySim in the first place and may try multiple times until the card is
permanently locked. A better execption string that also displays the
tries which are left may be helpful.

Change-Id: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13
Related: OS#4963

Revision 05f42ee9 (diff)
Added by dexter 7 months ago

cards: remove unnecessary execptions.

The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.

Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963

Revision 78e32f2b (diff)
Added by dexter 7 months ago

utils: fix sw_match()

The SW_match function takes a given status word and compares it against
a pattern that may contain wildcards (x or ?). This works by creating a
masked version of the SW using a pattern first (each hex digit is
replaced by a wildcard charafter if the pattern has a wildcard in the
same position). Once this is done, the resulting masked version is
compared at the pattern. However, the current implementation can not
work, since it compares the input SW against the pattern to decide
wihich chrafters should be masked. The input SW never contains wildcard
charafters.

Change-Id: I805ad32160fcfcb8628bf919b64f7eee0fe03c7e
Related: OS#4963

Revision 9c1a4ece (diff)
Added by dexter 7 months ago

pysim-shell: select MF on startup to make commands accessible

On the cration of the PysimApp object only the basic commands in
pySim-shell.py are registered, since the MF is only created but not
selected, the file specific commands of the MF are not available. To
make them available, select the MF once on startup before entering the
cmdloop.

Change-Id: Ib63191f44e7c8ae07b0128a9affba40b44957adc
Related: OS#4963

Revision 84b0d164 (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision 9abc187f (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision 1508a847 (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision a0ade725 (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 7a7507bf (diff)
Added by dexter 7 months ago

pySim-shell: add availability check for elementry files

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision 0362ad58 (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision f761d77d (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision d17a2139 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 95597acc (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision e51a582f (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision 4f4a85a0 (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision 2cc135e7 (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 273e6b75 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision a4c98205 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 3bc47a74 (diff)
Added by dexter 7 months ago

pySim-shell: fix verify_chv command

The verify_chv command passes the code directly to _scc.verify_chv(), but
this method accepts bytes not an ascii string. Like with verfy_adm we
need to run the code through sanitize_pin_adm() and h2b() first.

Change-Id: I3a003fc57bcf6c4f0a1ea8142e08b3183e655fad
Related: OS#4963

Revision 60cc2298 (diff)
Added by dexter 7 months ago

commands: improve exception string of verify_chv()

The execption string in verify_chv() is ADM centric, but since
pySim-shell also allows the user to verify a regular chv (PIN), this
string also appears when the verify_chv command is used with a wrong
PIN. Lets make it more generic and lets also output the CHV number so
that the user knows which CHV type was tried.

Change-Id: I41602de8edd22bea30ac68cb1c41e20ea1e4549c
Related: OS#4963

Revision 7d55e137 (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision b2fd19ba (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision cd4e9a22 (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision d1f72a44 (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 0872da21 (diff)
Added by dexter 7 months ago

pySim-shell: add availability check for elementry files

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision 152e2162 (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision e5204d0d (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 7eb08a16 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision c22d7b1e (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision 4203dd76 (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision ff94b3d9 (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision f9057dcf (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision bd27b4a3 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision fd606c89 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision eb72fa46 (diff)
Added by dexter 7 months ago

filesystem: fix typo in method call app()->append()

In the method add_application() the method name should be append()
instead of add().

Change-Id: Ic8ad62567968e09786eac86f219b56a3d3200511
Related: OS#4963

Revision 6e71a94d (diff)
Added by dexter 7 months ago

pySim-shell: add availability check for elementry files

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision 0fd8cd1d (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision acaf7c24 (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 2aba0b4e (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision dac502ba (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision d6f6c8e9 (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision 50921115 (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision 4cb302e8 (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 1e896f3d (diff)
Added by dexter 7 months ago

pySim-shell: add ADF.ISIM / ADF.USIM dynamically

currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.

Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963

Revision fdb1c7a7 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 681bc7ba (diff)
Added by dexter 7 months ago

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963

Revision e39750c2 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision f62866f4 (diff)
Added by dexter 7 months ago

pySim-shell: output currently selected file using select command

When the select command is entered with no parameters it fails with an
exception. Lets just output the currently selected file and exit
instead.

Change-Id: I541bd5ed14f240cd1c2bd63647c830f669d26130
Related: OS#4963

Revision 59f28f9b (diff)
Added by dexter 7 months ago

pySim-shell: be more specific when finding no ADM-PIN

When no ADM pin is found in the external data source, then print an
error message that tells the user that this is the case.

Change-Id: If8f88b43f283fbe459be1b30db35d984022840ac
Related: OS#4963

Revision 24f7bd3a (diff)
Added by dexter 7 months ago

pySim-shell: add filesystem exporter

add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.

Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963

Revision 7ae71f8d (diff)
Added by dexter 7 months ago

pySim-shells: complete CHV/PIN management tools

At the moment we only have a basic version of a verify_chv commnad, but
in order to handle any CHV/PIN related situation we also need commands
to enable, disable, change and unblock CHV.

- fix verify_chv commnad: more distinct parameter names, better help
strings, correct pin code encoding and add external source lookup
- Add unblock_chv, change_chv, enable_chv and disable_chv commands
- add/fix related functions in commands.py

Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Related: OS#4963

Revision 2558aa69 (diff)
Added by dexter 7 months ago

pySim-shell: add command to show file description

All all files (CardFile) have a human readable description but there is
no command to display that description yet

Change-Id: If716cf3c6b09d53dca652b588671487d5343cf58
Related: OS#4963

Revision 972043da (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 826c087e (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 4f790746 (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision ac1d4f9a (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision d799517d (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision a49c768d (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 9f779673 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 05e0243c (diff)
Added by dexter 7 months ago

pySim-shell: be more specific when finding no ADM-PIN

When no ADM pin is found in the external data source, then print an
error message that tells the user that this is the case.

Change-Id: If8f88b43f283fbe459be1b30db35d984022840ac
Related: OS#4963

Revision 56a7f944 (diff)
Added by dexter 7 months ago

pySim-shells: complete CHV/PIN management tools

At the moment we only have a basic version of a verify_chv commnad, but
in order to handle any CHV/PIN related situation we also need commands
to enable, disable, change and unblock CHV.

- fix verify_chv commnad: more distinct parameter names, better help
strings, correct pin code encoding and add external source lookup
- Add unblock_chv, change_chv, enable_chv and disable_chv commands
- add/fix related functions in commands.py

Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Related: OS#4963

Revision 9845aa91 (diff)
Added by dexter 7 months ago

pySim-shell: add availability check for elementry files

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision 3c92ccdf (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 388b7c3f (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision a895b7eb (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 1be9b93f (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision e00b9afb (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision dc630813 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision ab8d7dd4 (diff)
Added by dexter 7 months ago

pySim-shell: be more specific when finding no ADM-PIN

When no ADM pin is found in the external data source, then print an
error message that tells the user that this is the case.

Change-Id: If8f88b43f283fbe459be1b30db35d984022840ac
Related: OS#4963

Revision a2847b90 (diff)
Added by dexter 7 months ago

pySim-shells: complete CHV/PIN management tools

At the moment we only have a basic version of a verify_chv commnad, but
in order to handle any CHV/PIN related situation we also need commands
to enable, disable, change and unblock CHV.

- fix verify_chv commnad: more distinct parameter names, better help
strings, correct pin code encoding and add external source lookup
- Add unblock_chv, change_chv, enable_chv and disable_chv commands
- add/fix related functions in commands.py

Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Related: OS#4963

Revision a65655be (diff)
Added by dexter 7 months ago

pySim-shell: add availability check for elementry files

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision e6bc4f90 (diff)
Added by dexter 7 months ago

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963

Revision 6244f64c (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 228c98e4 (diff)
Added by dexter 7 months ago

pySim-shell: use -a / -A commandline option to authenticate

pySim-shell defines, just like the other pySim programs commandline
arguments that take an ADM pin to authenticate at the card as admin. The
arguments are defined, but not used. Add the missing authentication
part.

Change-Id: I6bed14eb8f4124e28d593cf0816dbe58e7271322
Related: OS#4963

Revision 13f56a9c (diff)
Added by dexter 7 months ago

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 59aec2ae (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 8706bf0a (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision eda22ad2 (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 1b71cee6 (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 3ee895e2 (diff)
Added by dexter 7 months ago

pySim-shell: be more specific when finding no ADM-PIN

When no ADM pin is found in the external data source, then print an
error message that tells the user that this is the case.

Change-Id: If8f88b43f283fbe459be1b30db35d984022840ac
Related: OS#4963

Revision fcaf19af (diff)
Added by dexter 7 months ago

pySim-shells: complete CHV/PIN management tools

At the moment we only have a basic version of a verify_chv commnad, but
in order to handle any CHV/PIN related situation we also need commands
to enable, disable, change and unblock CHV.

- fix verify_chv commnad: more distinct parameter names, better help
strings, correct pin code encoding and add external source lookup
- Add unblock_chv, change_chv, enable_chv and disable_chv commands
- add/fix related functions in commands.py

Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Related: OS#4963

Revision 541de52b (diff)
Added by dexter 7 months ago

pySim-shell: add availability check for elementry files

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963

Revision ea6b3698 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 0ab2878b (diff)
Added by dexter 7 months ago

filesystem: allow selection of arbitrary files

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID the file can still be
selected and it is possible to read the file type and memory model from
the select response. This info can be used to create a new file object
at runtime that will work like any other EF/DF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision 5e756af1 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision 6e94c123 (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision 796437e9 (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision f140678d (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision 77a265e9 (diff)
Added by dexter 7 months ago

pySim-shell: be more specific when finding no ADM-PIN

When no ADM pin is found in the external data source, then print an
error message that tells the user that this is the case.

Change-Id: If8f88b43f283fbe459be1b30db35d984022840ac
Related: OS#4963

Revision 3ef9849c (diff)
Added by dexter 7 months ago

pySim-shell: complete CHV/PIN management tools

At the moment we only have a basic version of a verify_chv commnad, but
in order to handle any CHV/PIN related situation we also need commands
to enable, disable, change and unblock CHV.

- fix verify_chv commnad: more distinct parameter names, better help
strings, correct pin code encoding and add external source lookup
- Add unblock_chv, change_chv, enable_chv and disable_chv commands
- add/fix related functions in commands.py

Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Related: OS#4963

Revision 66148ce9 (diff)
Added by dexter 7 months ago

pySim-shell: prevent inconsitancy when walking through the FS tree

When using the method walk() to walk through the filesystem tree, then
the action() callback must not change the currently selected file.
Unfortunately this can easily happen and result in unpredictable
behavior. Lets add a check + an exeception for this to make debugging
easier.

Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c
Related: OS#4963

Revision 069c9872 (diff)
Added by dexter 7 months ago

pySim-shell: fix and improve file system exporter

The file system exporter function export() selects the exported EF from
inside a try block. It also selects the parent DF again when leaving the
try block. If an exception ocurrs during select this is fine, but if it
happens during read it leaves the EF selected which makes messes up the
recursive filesystem walk.

There are also minor inconsistancies with the exception strings and the
path displayed in the execption strings

Related: OS#4963
Change-Id: Ie9b1712b37e5b39e9016497185510a2a45c4ca6c

Revision 4894fbe5 (diff)
Added by dexter 7 months ago

filesystem: decode select response for MF

We always use the select response parser from the parent file. The usual
case will be that on the way up at least one parent has overloeaded the
response parser from the MF. However, this is not the case when an EF at
the top level is selected, then we will just get the hexdump of the
response since no response parser is available. Lets add a response
parser for the MF as well so that we always parse the select response.

Change-Id: Ib2b2476fc0e7d34cdacf7eb100ffadceb788c4d2
Related: OS#4963

Revision 63f572df (diff)
Added by dexter 7 months ago

filesystem: allow selection of arbitrary files

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID the file can still be
selected and it is possible to read the file type and memory model from
the select response. This info can be used to create a new file object
at runtime that will work like any other EF/DF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963

Revision ad073e83 (diff)
Added by dexter 7 months ago

ts_31_102: do not add empty ShellCommands class.

The class ShellCommands defined in ADF_USIM overloads useful CommandSet
classes defined in the superclass, making their commands inaccessible.
Also ts_31_102 does not have such a class definition in the ADF_ISIM
class, so lets remove this class.

Change-Id: I0e67c570fc4f17641d990a9cd239632ecf622de3
Related: OS#4963

Revision cba6dbce (diff)
Added by dexter 7 months ago

fileystem: fix ADF selection

When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.

Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963

Revision 2b11c32e (diff)
Added by dexter 7 months ago

pySim-shell: automatic ADM pin from CSV-File

It can be hard to manage ADM pins when working with different cards at
the same time. To make this easier, add an automatic way to determine
the ADM pin for each card from a CSV file.

- add a CardData clas model that can be extended to to get the data from
various different sources. For now use CSV-Files. Also add a way how
multiple CardData classes can be registered so that one global get
function can query all registered CardData classes at once.

- automatically check for CSV-File in home directory and use it as
default CardData source unless the user specifies a CSV file via
commandline argument.

- extend the verify_adm command so that it automatically queries the
ADM pin if no argument is given. Also do not try to authenticate if
no ADM pin could be determined.

Change-Id: I51835ccb16bcbce35e7f3765e8927a4451509e77
Related: OS#4963

Revision 38c74f6d (diff)
Added by dexter 7 months ago

commands: conserve write cycles

When a record or a binary file is written the card goes throth a full
flash/eeprom write cycle at this location, even when the data does not
change. This can be optimized by reading before writing in order to
compere if the data we are about to write is actually different.

Change-Id: Ifd1b80d3ede15a7caa29077a37ac7cf58c9053f1
Related: OS#4963

Revision b63766b9 (diff)
Added by dexter 7 months ago

pySim-shell: be more specific when finding no ADM-PIN

When no ADM pin is found in the external data source, then print an
error message that tells the user that this is the case.

Change-Id: If8f88b43f283fbe459be1b30db35d984022840ac
Related: OS#4963

Revision 46f09af1 (diff)
Added by dexter 7 months ago

pySim-shell: complete CHV/PIN management tools

At the moment we only have a basic version of a verify_chv commnad, but
in order to handle any CHV/PIN related situation we also need commands
to enable, disable, change and unblock CHV.

- fix verify_chv commnad: more distinct parameter names, better help
strings, correct pin code encoding and add external source lookup
- Add unblock_chv, change_chv, enable_chv and disable_chv commands
- add/fix related functions in commands.py

Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Related: OS#4963

Revision b152a9e0 (diff)
Added by dexter 7 months ago

pySim-shell: prevent inconsitancy when walking through the FS tree

When using the method walk() to walk through the filesystem tree, then
the action() callback must not change the currently selected file.
Unfortunately this can easily happen and result in unpredictable
behavior. Lets add a check + an exeception for this to make debugging
easier.

Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c
Related: OS#4963

Revision ac34dcc1 (diff)
Added by dexter 7 months ago

pySim-shell: fix and improve file system exporter

The file system exporter function export() selects the exported EF from
inside a try block. It also selects the parent DF again when leaving the
try block. If an exception ocurrs during select this is fine, but if it
happens during read it leaves the EF selected which makes messes up the
recursive filesystem walk.

There are also minor inconsistancies with the exception strings and the
path displayed in the execption strings

Related: OS#4963
Change-Id: Ie9b1712b37e5b39e9016497185510a2a45c4ca6c

Revision c98ef8a7 (diff)
Added by dexter 6 months ago

ts_102_221.py: fix fixup_fcp_proprietary_tlv_map()

The function fixup_fcp_proprietary_tlv_map() addes propritary TLV
tags in the range of d0 to ff to the TLV map. However, the spec defines
this range as b7 and b8 of the first tag byte set to 1. This results
in a range from c0 to ff. See also ETSI TS 102 221, section 11.1.1.4.6.0

Change-Id: I8359527c9ff303b257b181b87dc440f27735ece9
Related: OS#4963

Revision dc4402e5 (diff)
Added by dexter 6 months ago

pySim-shell: fix wrong reference to iccid.

It should be self.iccid instead of self._cmd.iccid

Change-Id: Icb7378929187a4fc39a8f1ddbaa18291f16caf79
Related: OS#4963

Revision 13e258dc (diff)
Added by dexter 6 months ago

pySim-shell: be sure that startup script file exists

When a startup script file is specified that does not exists pySim-shell
skips the script and starts normally. This is dangerous because if
pySim-shell is called by a shellscript with a nonexisting script file
the shellscript may hang forever because there is no script that exists
pySim-shell again

Change-Id: I4ff2226c8852727aa23357aa54d1e2d480bfaf2d
Related: OS#4963

Revision f408a400 (diff)
Added by dexter 6 months ago

pySim-shell: tree/export: catch errors during DF selection

When a DF is selected, then the method walk() does not catch the
related execption, which causes the command to stop immediately. Lets
also catch those exceptions and generate appropriate error messages
during export.

Change-Id: I24ccf64965e7b0756c3db77eb2084b22c357a570
Related: OS#4963

Revision 80ce71f5 (diff)
Added by dexter 6 months ago

pySim-shell: separate export summary with a headline

the export summary is printed after the log entry for the last file
without separation. This is confusing because it looks like if the
summary would refer to the last file only. Lets add a headline to make
clear that the last few lines are the "Export summary"

Change-Id: I90771e525b2b114bdb41a8e90d298ca991c09c3d
Related: OS#4963

Revision 0adabf61 (diff)
Added by dexter 6 months ago

filesystem: fix wrong comment

The property rec_len is not a tuple, it is a set.

Related: OS#4963
Change-Id: I366772c62d0bb5a6400ce5b431eb94ac9248dccc

Revision fe1fb037 (diff)
Added by dexter 6 months ago

filesystem: fix wrong helpstring for update_record_decoded

the helpstring of update_record_decoded mentions hex bytes for the data
parameter, but it should be mentioned as abstract json data like in
update_binary_decoded

Change-Id: Ibae2ab49054ac5dd6fcccddd28c98d886403dac9
Related: OS#4963

Revision b46cb3ff (diff)
Added by dexter 6 months ago

utils: fix encoding of EF.MSISDN

The encoding of EF.MSISDN is a bit unstrutured. The encoder function
does not return a valid result since it lacks the parameters
Capability/Configuration2 Record Identifier and Extension5 Record
Identifier, which are mandatory but can be set to 0xFF. Also the
encoder gets its input from pySim-shell, so it should have some
more input validation, especially when the user encodes an empty
string. The encoder and decoder function also do not have unit-tests.

Since the encoder now adds the missing two bytes by isself this does
not have to be done manually anymore, so cards.py needs to be
re-aligned.

For pySim-shell.py the encoder is used from ts_51_011.py. Unfortunately
it is used wrongly there. The optional Alpha Identifier is required
here as well.

Related: OS#4963
Change-Id: Iee5369b3e3ba7fa1155facc8fa824bc60e33b55b

Revision f9cbe090 (diff)
Added by dexter 6 months ago

ts_51_011: fix encoding of EF.MSISDN

The json input that is used with EF.MSISDN seems to be somewhat
ambigious. The original code accepts {"msisdn": "+4916012345678"}
only while the output is {"msisdn": [1, 1, "+4916012345678"]}. Lets
add a check and also accept the latter version.

Change-Id: I8f8dd68aac25d3fa3bc1aab06b855f8ec6640258
Related: OS#4963

Revision e6f8d683 (diff)
Added by dexter 6 months ago

utils: specify paremeters of enc_plmn() as Hexstr

To prevent missunderstandings when using enc_plmn(), specify the input
and return parameters as Hexstr.

Change-Id: I57cf8e2de357650aef2a06fbffc7615ccb2a45b4
Related: OS#4963

Revision 6c5cd803 (diff)
Added by dexter 6 months ago

utils: fix mcc/mnc encoding in dec_plmn (EF_PLMNsel)

The dec_plmn function takes an hexstring and returns the decoded MCC and
MNC as integer values. The result is then used by the json encoder in
EF_PLMNsel, which means the json output will contrary to the input, use
integer values instead of strings.

This is not correct since there may be leading zeros (e.g. mnc 01 and
001 both exist are different) which must be retained in order to know
the correct length of the MNC.

Related: OS#4963
Change-Id: I393e04836814d992d2a6d0a4e4e01850976d6e81

Revision e7d41795 (diff)
Added by dexter 6 months ago

ts_51_011, utils: fix Access Technology Identifier coding

When the Access Technology Identifier encoder sets the bits for E-UTRAN
it does not respect that bit "100" is also a valid bit combination that
encodes E-UTRAN WB-S1 and E-UTRAN NB-S1. Lets encode this bit
combination if the user is just specifying "E-UTRAN" without further
spefication of WB or NB.

The decoder only looks at bit 14 and decodes "1xx" always to "E-UTRAN".
This is not specific enough. Lets make sure that the decoder is
complementary to the encoder.

Change-Id: Ibfe8883a05f9ad6988d8e212cb9a598229954296
Related: OS#4963

Revision f39a4cb3 (diff)
Added by dexter 6 months ago

utils: specify type of parameter name in enc_spn

Related: OS#4963
Change-Id: I43a1e68afe9e756346bc0cfe8bda4ac665ac6c54

Revision c957ce8a (diff)
Added by dexter 5 months ago

ts_51_011: fix encoder of EF_SPN:

The encoder for EF_SPN is passing the 'spn' parameter (which is a list)
directly to enc_spn without taking it apart first.

Change-Id: I0a405793c8909d4279e634b93dcb76e5cb2963f3
Related: OS#4963

Revision e2c59a8b (diff)
Added by dexter 5 months ago

pySim_prog: remove unused import for dec_addr_tlv

The function dec_addr_tlv is imported from utils, but not used

Change-Id: I2a962d544f288259f16c1dca92715953d1c24d82
Related: OS#4963

Revision 42804d78 (diff)
Added by dexter 5 months ago

commands: pad short data input in update_record()

The method update_record as a "force_len" parameter, which is somewhat
irretatating. Some explainatory comments and a reformat of the if
statement will help to make it more understandable to the api user.

In the non force_len case the method determines the record length from
the select response and throws an exception if the data input does not
match that length. This makes sense if the data input exceeds the
record length of the file but if the data input is less then the record
length the situation is fixable by padding the input with 0xff. This
also a quite common case because in some situation it is not guaranteed
that the data will fill the entire record.

Change-Id: I9a5df0e46c3dd2e87d447c5c01cf15844b0eed07
Related: OS#4963

Revision be18f2a4 (diff)
Added by dexter 5 months ago

utils: split string formatting from dec_addr_tlv

The function dec_addr_tlv() takes an encoded FQDN or IPv4 address and
fromats it into a human readable string that contains the human readable
form and the encoded hex form. Unfortunately this limits the usecase of
dec_addr_tlv. Lets split the string generation into a separate function
so that we can use dec_addr_tlv universally

Change-Id: Id017b0786089adac4d6c5be688742eaa9699e529
Related: OS#4963

Revision 86b09da6 (diff)
Added by dexter 5 months ago

ts_31_103: finish decoder and fix encoder for EF.PCSCF

The encoder/decoder functions in class EF_PCSCF look rather unfinshed
because of problems with dec_addr_tlv(), since those problems are fixed
by a previous patch we can now finish the decoder function and fix the
decoder as well.

Change-Id: I7613b8b71624dc5802aca93163788a2a2d4ca345
Related: OS#4963

History

#1 Updated by laforge 9 months ago

  • Related to Bug #4962: add setup.py to pySim added

#2 Updated by dexter 8 months ago

  • Assignee changed from laforge to dexter
  • % Done changed from 30 to 40

I have continued the development now. I have worked myself through the code now and added some new features:

  • dir command: At the moment we can only use the tab completion to display the directory tree, however I think its more convenient to have a dir command that unless otherwise specified only shows the files and directories by their names.
  • export command: This command recursively walks through the file system and generates a script that consists of update_binary and update_record commands. This is effectively a backup of the card. To restore the backup the script can be executed in pySim-shell. It is also error tolerant. If for some reason a file can not be red during creation a comment is printed to the script and the script generation just moves on.
  • tree command: This is basically a byproduct of the export command. It walks through the filesystem and displays and displays a tree, this is very handy if one does not know where exactly a specific file is located.

The next steps will be to have specific support for sysmo-usim-sjs1 and sysmo-isim-sja2. We basically need to check the ATR and add the matching proprietary files to the card. I am currently on this.

The current status can be found on pmaier/shell

#3 Updated by laforge 8 months ago

I've now re-ordered the patch set to
  • first apply all infrastructure changes in the existing code, so we can test them without introducing pySim-shell
  • squash a number of small, non-controversial @dexter's fixes into the main pySim-shell commit

The result has been pushed, with the main shell commit in https://gerrit.osmocom.org/c/pysim/+/23175

#4 Updated by laforge 6 months ago

  • Status changed from In Progress to Resolved
  • Assignee changed from dexter to laforge
  • % Done changed from 40 to 100

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)