mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
ccid.py: Removed read_bin command
The code was used as early debug code to read different files from the SIM card and therefore acquire the IMSI, and other SIM card specific information. This only was useful for testing that the firmware worked properly. Is is not needed for regular use cases.
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from pySim.commands import SimCardCommands
|
||||
from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid
|
||||
from pySim.transport.pcsc import PcscSimLink
|
||||
|
||||
|
||||
|
||||
def pySim_read():
|
||||
sl = PcscSimLink(0)
|
||||
|
||||
# Create command layer
|
||||
scc = SimCardCommands(transport=sl)
|
||||
|
||||
# Wait for SIM card
|
||||
sl.wait_for_card()
|
||||
|
||||
# Program the card
|
||||
print("Reading ...")
|
||||
|
||||
# EF.ICCID
|
||||
try:
|
||||
(res, sw) = scc.read_binary(['3f00', '2fe2'])
|
||||
if sw == '9000':
|
||||
print("ICCID: %s" % (dec_iccid(res),))
|
||||
else:
|
||||
print("ICCID: Can't read, response code = %s" % (sw,))
|
||||
except:
|
||||
print("Unexpected error:", sys.exc_info()[0])
|
||||
print(traceback.format_exc())
|
||||
|
||||
# EF.IMSI
|
||||
try:
|
||||
(res, sw) = scc.read_binary(['3f00', '7f20', '6f07'])
|
||||
if sw == '9000':
|
||||
print("IMSI: %s" % (dec_imsi(res),))
|
||||
else:
|
||||
print("IMSI: Can't read, response code = %s" % (sw,))
|
||||
except:
|
||||
print("Unexpected error:", sys.exc_info()[0])
|
||||
print(traceback.format_exc())
|
||||
|
||||
# EF.SMSP
|
||||
try:
|
||||
(res, sw) = scc.read_record(['3f00', '7f10', '6f42'], 1)
|
||||
if sw == '9000':
|
||||
print("SMSP: %s" % (res,))
|
||||
else:
|
||||
print("SMSP: Can't read, response code = %s" % (sw,))
|
||||
except:
|
||||
print("Unexpected error:", sys.exc_info()[0])
|
||||
print(traceback.format_exc())
|
||||
|
||||
# EF.HPLMN
|
||||
try:
|
||||
(res, sw) = scc.read_binary(['3f00', '7f20', '6f30'])
|
||||
if sw == '9000':
|
||||
print("HPLMN: %s" % (res))
|
||||
print("HPLMN: %s" % (dec_hplmn(res),))
|
||||
else:
|
||||
print("HPLMN: Can't read, response code = %s" % (sw,))
|
||||
except:
|
||||
print("Unexpected error:", sys.exc_info()[0])
|
||||
print(traceback.format_exc())
|
||||
|
||||
# EF.ACC
|
||||
try:
|
||||
(res, sw) = scc.read_binary(['3f00', '7f20', '6f78'])
|
||||
if sw == '9000':
|
||||
print("ACC: %s" % (res,))
|
||||
else:
|
||||
print("ACC: Can't read, response code = %s" % (sw,))
|
||||
except:
|
||||
print("Unexpected error:", sys.exc_info()[0])
|
||||
print(traceback.format_exc())
|
||||
|
||||
# EF.MSISDN
|
||||
try:
|
||||
# print(scc.record_size(['3f00', '7f10', '6f40']))
|
||||
(res, sw) = scc.read_record(['3f00', '7f10', '6f40'], 1)
|
||||
if sw == '9000':
|
||||
if res[1] != 'f':
|
||||
print("MSISDN: %s" % (res,))
|
||||
else:
|
||||
print("MSISDN: Not available")
|
||||
else:
|
||||
print("MSISDN: Can't read, response code = %s" % (sw,))
|
||||
except:
|
||||
print("MSISDN: Can't read. Probably not existing file, error: ", sys.exc_info()[0])
|
||||
print(traceback.format_exc())
|
||||
|
||||
print("Done !\n")
|
||||
@@ -24,7 +24,6 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
# FIXME: config names instead of numbers
|
||||
parser.add_argument("-C", "--conf", type=int, choices=[1, 2, 3, 4], help="Set USB config")
|
||||
parser.add_argument("-b", "--read_bin", help="read ICCID, IMSI, etc.", action='store_true')
|
||||
parser.add_argument("-s", "--sniff", help="Sniff communication!", action='store_true')
|
||||
parser.add_argument("-S", "--select_file", help="Transmit SELECT cmd!", action='store_true')
|
||||
parser.add_argument("-p", "--phone", help="Emulates simcard", action='store_true')
|
||||
@@ -38,8 +37,6 @@ def main():
|
||||
dev.set_configuration(args.conf)
|
||||
# Give pcsclite time to find the device
|
||||
time.sleep(1)
|
||||
if args.read_bin is True:
|
||||
ccid.pySim_read()
|
||||
if args.sniff is True:
|
||||
sniffer.sniff(dev)
|
||||
if args.select_file is True:
|
||||
|
||||
Reference in New Issue
Block a user