mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-25 14:58:33 +03:00
re-program: Instead of specifying the IMSI, read it from the card.
This commit is contained in:
committed by
Harald Welte
parent
8c1b33c439
commit
4e824686f5
@@ -116,9 +116,10 @@ def parse_options():
|
|||||||
)
|
)
|
||||||
parser.add_option("--acc", dest="acc",
|
parser.add_option("--acc", dest="acc",
|
||||||
help="Set ACC bits (Access Control Code). not all card types are supported",
|
help="Set ACC bits (Access Control Code). not all card types are supported",
|
||||||
|
)
|
||||||
|
parser.add_option("--read-imsi", dest="read_imsi", action="store_true",
|
||||||
|
help="Read the IMSI from the CARD", default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
parser.add_option("-z", "--secret", dest="secret", metavar="STR",
|
parser.add_option("-z", "--secret", dest="secret", metavar="STR",
|
||||||
help="Secret used for ICCID/IMSI autogen",
|
help="Secret used for ICCID/IMSI autogen",
|
||||||
)
|
)
|
||||||
@@ -156,8 +157,8 @@ def parse_options():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if options.source == 'csv':
|
if options.source == 'csv':
|
||||||
if (options.imsi is None) and (options.batch_mode is False):
|
if (options.imsi is None) and (options.batch_mode is False) and (options.read_imsi is False):
|
||||||
parser.error("CSV mode needs either an IMSI or batch mode")
|
parser.error("CSV mode needs either an IMSI, --read-imsi or batch mode")
|
||||||
if options.read_csv is None:
|
if options.read_csv is None:
|
||||||
parser.error("CSV mode requires a CSV input file")
|
parser.error("CSV mode requires a CSV input file")
|
||||||
elif options.source == 'cmdline':
|
elif options.source == 'cmdline':
|
||||||
@@ -432,7 +433,7 @@ def _read_params_csv(opts, imsi):
|
|||||||
cr = csv.DictReader(f, row)
|
cr = csv.DictReader(f, row)
|
||||||
i = 0
|
i = 0
|
||||||
for row in cr:
|
for row in cr:
|
||||||
if opts.num is not None:
|
if opts.num is not None and opts.read_imsi is False:
|
||||||
if opts.num == i:
|
if opts.num == i:
|
||||||
f.close()
|
f.close()
|
||||||
return row;
|
return row;
|
||||||
@@ -613,7 +614,16 @@ if __name__ == '__main__':
|
|||||||
if opts.source == 'cmdline':
|
if opts.source == 'cmdline':
|
||||||
cp = gen_parameters(opts)
|
cp = gen_parameters(opts)
|
||||||
elif opts.source == 'csv':
|
elif opts.source == 'csv':
|
||||||
cp = read_params_csv(opts, opts.imsi)
|
if opts.read_imsi:
|
||||||
|
if opts.dry_run:
|
||||||
|
# Connect transport
|
||||||
|
print "Insert card now (or CTRL-C to cancel)"
|
||||||
|
sl.wait_for_card(newcardonly=not first)
|
||||||
|
(res,_) = scc.read_binary(['3f00', '7f20', '6f07'])
|
||||||
|
imsi = swap_nibbles(res)[3:]
|
||||||
|
else:
|
||||||
|
imsi = opts.imsi
|
||||||
|
cp = read_params_csv(opts, imsi)
|
||||||
if cp is None:
|
if cp is None:
|
||||||
print "Error reading parameters\n"
|
print "Error reading parameters\n"
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user