mirror of https://gerrit.osmocom.org/simtrace2
mitm.py: read atr on startup, do not reset card to retrieve atr
This commit is contained in:
parent
7741f7159c
commit
6f664a3cc2
|
@ -45,25 +45,21 @@ def poll_ep(dev, ep):
|
||||||
def write_phone(dev, resp):
|
def write_phone(dev, resp):
|
||||||
dev.write(PHONE_WR, resp, 1000)
|
dev.write(PHONE_WR, resp, 1000)
|
||||||
|
|
||||||
def reset_sim(sm_con):
|
|
||||||
sm_con.disconnect_card()
|
|
||||||
sm_con.connect_card()
|
|
||||||
|
|
||||||
def do_mitm():
|
def do_mitm():
|
||||||
dev = find_dev()
|
dev = find_dev()
|
||||||
with closing(SmartcardConnection()) as sm_con:
|
with closing(SmartcardConnection()) as sm_con:
|
||||||
|
atr = sm_con.getATR()
|
||||||
while True:
|
while True:
|
||||||
cmd = poll_ep(dev, PHONE_INT)
|
cmd = poll_ep(dev, PHONE_INT)
|
||||||
if cmd is not None:
|
if cmd is not None:
|
||||||
print(cmd)
|
print(cmd)
|
||||||
assert cmd[0] == ord('R')
|
assert cmd[0] == ord('R')
|
||||||
reset_sim(sm_con)
|
# FIXME: restart card anyways?
|
||||||
|
# sm_con.reset_card()
|
||||||
|
write_phone(dev, atr)
|
||||||
|
|
||||||
cmd = poll_ep(dev, PHONE_RD)
|
cmd = poll_ep(dev, PHONE_RD)
|
||||||
if cmd is not None:
|
if cmd is not None:
|
||||||
print(cmd)
|
print(cmd)
|
||||||
sim_data = sm_con.send_receive_cmd(cmd)
|
sim_data = sm_con.send_receive_cmd(cmd)
|
||||||
if sim_data is None:
|
|
||||||
continue
|
|
||||||
write_phone(dev, sim_data)
|
write_phone(dev, sim_data)
|
||||||
|
|
Loading…
Reference in New Issue