From 69d1f90c122a2384e2ae303c3a63f7220f2e957e Mon Sep 17 00:00:00 2001 From: Christina Quast Date: Fri, 3 Apr 2015 11:41:23 +0200 Subject: [PATCH] MITM python program first draft --- usb_application/mitm.py | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 usb_application/mitm.py diff --git a/usb_application/mitm.py b/usb_application/mitm.py new file mode 100644 index 00000000..3d8ea4c1 --- /dev/null +++ b/usb_application/mitm.py @@ -0,0 +1,53 @@ +import usb.core +import usb.util + +def find_dev(): + dev = usb.core.find(idVendor=0x03eb, idProduct=0x6004) + if dev is None: + raise ValueError("Device not found") + else: + print("Found device") + return dev + + +SIM_WR = 0x1 +SIM_RD = 0x82 +SIM_INT = 0x83 + +PHONE_WR = 0x4 +PHONE_RD = 0x85 +PHONE_INT = 0x86 + +def check_msg_phone(): + cmd = dev.read(PHONE_RD, 64, 1000) + if cmd: + print("Phone sent: " + cmd) + return cmd + cmd = dev.read(PHONE_INT, 64, 1000) + if cmd: + print("Phone sent int") + return cmd + +def write_phone(resp): + dev.write(PHONE_WR, resp, 1000) + +def write_sim(data): + return do_intercept(data, dwActiveProtocol) + +def mitm(): + dev = find_dev() + hcard, hcontext, dwActiveProtocol = init() + + while True: + if (cmd = check_msg_phone()): + resp = write_sim(cmd, dwActiveProtocol) + if (resp is not None): + write_phone(resp) + else: + + + exit(hcard, hcontext) + + except usb.USBError as e: + print e + pass