mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-25 14:58:33 +03:00
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
This commit is contained in:
@@ -673,6 +673,17 @@ class PySimCommands(CommandSet):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("error: cannot authenticate, no adm-pin!")
|
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')
|
@with_default_category('ISO7816 Commands')
|
||||||
class Iso7816Commands(CommandSet):
|
class Iso7816Commands(CommandSet):
|
||||||
|
|||||||
Reference in New Issue
Block a user