diff options
author | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2013-07-02 16:56:55 +0400 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2013-07-02 15:19:09 +0200 |
commit | 21885249cfb777f299c36b6def8bb768f61942a3 (patch) | |
tree | 4016c5e52e1f493ed2090399c9d11b027335be61 | |
parent | 5da8d4e0d4be75974bf83e8562911eb7cc4f277d (diff) |
Implement setting of EF.ACC file in GrcardSim and _MagicSimBase
From: Alexander Chemeris <Alexander.Chemeris@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rwxr-xr-x | pySim-prog.py | 16 | ||||
-rw-r--r-- | pySim/cards.py | 10 |
2 files changed, 24 insertions, 2 deletions
diff --git a/pySim-prog.py b/pySim-prog.py index 46b1842..b0b65ef 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -105,6 +105,9 @@ def parse_options(): parser.add_option("--op", dest="op", help="Set OP to derive OPC from OP and KI", ) + parser.add_option("--acc", dest="acc", + help="Set ACC bits (Access Control Code). not all card types are supported", + ) parser.add_option("-z", "--secret", dest="secret", metavar="STR", @@ -316,6 +319,17 @@ def gen_parameters(opts): '00' # TP-Validity period ) + # ACC + if opts.acc is not None: + acc = opts.acc + if not _ishex(acc): + raise ValueError('ACC must be hex digits only !') + if len(acc) != 2*2: + raise ValueError('ACC must be exactly 2 bytes') + + else: + acc = None + # Ki (random) if opts.ki is not None: ki = opts.ki @@ -346,6 +360,7 @@ def gen_parameters(opts): 'smsp' : smsp, 'ki' : ki, 'opc' : opc, + 'acc' : acc, } @@ -359,6 +374,7 @@ def print_parameters(params): > IMSI : %(imsi)s > Ki : %(ki)s > OPC : %(opc)s + > ACC : %(acc)s """ % params diff --git a/pySim/cards.py b/pySim/cards.py index 18ccaa9..4bc5777 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -130,6 +130,12 @@ class _MagicSimBase(Card): # PLMN_Sel v+= '6f30' + '18' + rpad(hplmn, 36) + # ACC + # This doesn't work with "fake" SuperSIM cards, + # but will hopefully work with real SuperSIMs. + if p.get('acc') is not None: + v+= '6f78' + '02' + lpad(p['acc'], 4) + self._scc.update_record(self._files['b_ef'][0], 1, rpad(v, self._files['b_ef'][1]*2) ) @@ -283,8 +289,8 @@ class GrcardSim(Card): data, sw = self._scc.update_binary('6f07', self._e_imsi(p['imsi'])) # EF.ACC - #r = self._scc.select_file(['3f00', '7f20', '6f78']) - #self._scc.update_binary('6f78', self._e_imsi(p['imsi']) + if p.get('acc') is not None: + data, sw = self._scc.update_binary('6f78', lpad(p['acc'], 4)) # EF.SMSP r = self._scc.select_file(['3f00', '7f10', '6f42']) |