diff options
author | Harald Welte <laforge@osmocom.org> | 2022-02-11 16:03:06 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2022-02-14 00:48:16 +0100 |
commit | afb8d3f925f7ac3aac4e839f2855c48c9890760a (patch) | |
tree | fcadc9af732f4fdf162080c00f9277cf9d54eed3 /pySim-shell.py | |
parent | 08b11abc2ff84fd220fc9f7010aac25b14fac882 (diff) |
pySim-shell: introduce 'apdu' command for sending raw APDU to card
This can be useful when playing around with cards, for example
sending commands for which pySim-shell doesn't yet have proper support.
Change-Id: Ib504431d26ed2b6f71f77a143ff0a7fb4f5ea02e
Diffstat (limited to 'pySim-shell.py')
-rwxr-xr-x | pySim-shell.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pySim-shell.py b/pySim-shell.py index 3b17a75..a82d56f 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -673,6 +673,17 @@ class PySimCommands(CommandSet): else: raise ValueError("error: cannot authenticate, no adm-pin!") + apdu_cmd_parser = argparse.ArgumentParser() + apdu_cmd_parser.add_argument('APDU', type=str, help='APDU as hex string') + + @cmd2.with_argparser(apdu_cmd_parser) + def do_apdu(self, opts): + """Send a raw APDU to the card, and print SW + Response. + DANGEROUS: pySim-shell will not know any card state changes, and + not continue to work as expected if you e.g. select a different file.""" + data, sw = self._cmd.card._scc._tp.send_apdu(opts.APDU) + self._cmd.poutput("SW: %s %s, RESP: %s" % (sw, self._cmd.rs.interpret_sw(sw), data)) + @with_default_category('ISO7816 Commands') class Iso7816Commands(CommandSet): |