From ca0ebfdbd61d40c38edfaf84daaa343921260a78 Mon Sep 17 00:00:00 2001 From: Christina Quast Date: Fri, 19 Jun 2015 13:29:14 +0200 Subject: [PATCH] mitm.py: Bugfix: Always check for APDU_S_SEND_DATA When the command a0 c0 00 00 16 was send, and the the bytes a0 c0 00 00 where read first, and then only the byte 16 was read from simtrace, the code never entered the if condition if cmd is not None, and therefore never executed send_receive_cmd. Bug fix: Check for state APDU_S_SEND_DATA after apdu_split (parsing) the ACK-instruction byte, in case it was an instruction which requires an answer from the SIM card. --- usb_application/mitm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usb_application/mitm.py b/usb_application/mitm.py index 6f501df9..5e8ff6ef 100755 --- a/usb_application/mitm.py +++ b/usb_application/mitm.py @@ -105,10 +105,10 @@ def do_mitm(dev, sim_emul=True): write_phone(dev, replace(sim_data)) for c in sim_data: apdu.split(c) - elif apdu.state == apdu_states.APDU_S_SEND_DATA: - sim_data = sm_con.send_receive_cmd(replace(apdu.buf)) - sim_data.insert(0, apdu.ins) - write_phone(dev, replace(sim_data)) - apdu.state = apdu_states.APDU_S_SW1 - for c in sim_data: - apdu.split(c) + if apdu.state == apdu_states.APDU_S_SEND_DATA: + sim_data = sm_con.send_receive_cmd(replace(apdu.buf)) + #sim_data.insert(0, apdu.ins) + write_phone(dev, replace(sim_data)) + #apdu.state = apdu_states.APDU_S_SW1 + for c in sim_data: + apdu.split(c)