mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-19 06:48:34 +03:00
array to hex function, reduced usb timeout
This commit is contained in:
@@ -6,6 +6,7 @@ import phone
|
||||
|
||||
from contextlib import closing
|
||||
|
||||
from util import HEX
|
||||
|
||||
def find_dev():
|
||||
dev = usb.core.find(idVendor=0x03eb, idProduct=0x6004)
|
||||
@@ -36,14 +37,15 @@ ERR_TIMEOUT = 110
|
||||
|
||||
def poll_ep(dev, ep):
|
||||
try:
|
||||
return dev.read(ep, 64, 1000)
|
||||
return dev.read(ep, 64, 100)
|
||||
except usb.core.USBError as e:
|
||||
if e.errno != ERR_TIMEOUT:
|
||||
raise
|
||||
return None
|
||||
|
||||
def write_phone(dev, resp):
|
||||
dev.write(PHONE_WR, resp, 1000)
|
||||
print("WR: ", HEX(resp))
|
||||
dev.write(PHONE_WR, resp, 100)
|
||||
|
||||
def do_mitm():
|
||||
dev = find_dev()
|
||||
@@ -52,14 +54,15 @@ def do_mitm():
|
||||
while True:
|
||||
cmd = poll_ep(dev, PHONE_INT)
|
||||
if cmd is not None:
|
||||
print(cmd)
|
||||
print("Int line ", HEX(cmd))
|
||||
assert cmd[0] == ord('R')
|
||||
# FIXME: restart card anyways?
|
||||
# sm_con.reset_card()
|
||||
print("Write atr: ", HEX(atr))
|
||||
write_phone(dev, atr)
|
||||
|
||||
cmd = poll_ep(dev, PHONE_RD)
|
||||
if cmd is not None:
|
||||
print(cmd)
|
||||
print("RD: ", HEX(cmd))
|
||||
sim_data = sm_con.send_receive_cmd(cmd)
|
||||
write_phone(dev, sim_data)
|
||||
|
||||
Reference in New Issue
Block a user