mirror of https://gerrit.osmocom.org/simtrace2
simtrace.py: Use mitm.py in phone and mitm mode
This commit is contained in:
parent
4b8149363a
commit
158c1dd448
|
@ -2,6 +2,7 @@ import usb.core
|
|||
import usb.util
|
||||
|
||||
from ccid_raw import SmartcardConnection
|
||||
from smartcard_emulator import SmartCardEmulator
|
||||
|
||||
from contextlib import closing
|
||||
|
||||
|
@ -43,9 +44,13 @@ def write_phone(dev, resp):
|
|||
print("WR: ", HEX(resp))
|
||||
dev.write(PHONE_WR, resp, 10)
|
||||
|
||||
def do_mitm():
|
||||
def do_mitm(sim_emul=True):
|
||||
dev = find_dev()
|
||||
with closing(SmartcardConnection()) as sm_con:
|
||||
if sim_emul == True:
|
||||
my_class = SmartCardEmulator
|
||||
else:
|
||||
my_class = SmartcardConnection
|
||||
with closing(my_class()) as sm_con:
|
||||
atr = sm_con.getATR()
|
||||
|
||||
apdus = []
|
||||
|
|
|
@ -4,16 +4,11 @@ import argparse
|
|||
import sniffer
|
||||
import ccid
|
||||
import ccid_select
|
||||
import phone
|
||||
import mitm
|
||||
|
||||
import usb.core
|
||||
import usb.util
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
cmd1 = {0x00, 0x10, 0x00, 0x00}
|
||||
|
@ -91,9 +86,9 @@ def main():
|
|||
if args.select_file is True:
|
||||
ccid_select.select()
|
||||
if args.phone is True:
|
||||
phone.emulate_sim()
|
||||
mitm.do_mitm(sim_emul=True)
|
||||
if args.mitm is True:
|
||||
mitm.do_mitm()
|
||||
mitm.do_mitm(sim_emul=False)
|
||||
|
||||
return
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import constants
|
||||
import array
|
||||
|
||||
INS = 1
|
||||
CNT = 4
|
||||
|
||||
class SmartCardEmulator:
|
||||
def getATR(self):
|
||||
return array.array('B', constants.ATR_SYSMOCOM2)
|
||||
|
||||
def send_receive_cmd(self, cmd):
|
||||
if len(cmd) == 5: # Received cmd from phone
|
||||
if cmd[INS] == 0xA4:
|
||||
resp = [cmd[INS]] # Respond with INS byte
|
||||
elif cmd[INS] == 0xC0:
|
||||
data = [0x00, 0x00, 0x00, 0x00,
|
||||
0x7F, 0x20, 0x02, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x09, 0x91, 0x00, 0x17,
|
||||
0x04, 0x00, 0x83, 0x8A,
|
||||
0x83, 0x8A]
|
||||
SW = [0x90, 0x00]
|
||||
resp = [cmd[INS]] + data + SW # Respond with INS byte
|
||||
#state = WAIT_RST
|
||||
else:
|
||||
print("Unknown cmd")
|
||||
resp = [0x60, 0x00]
|
||||
elif len(cmd) == 2:
|
||||
resp = [0x9F, 0x16]
|
||||
else:
|
||||
resp = [0x60, 0x00]
|
||||
|
||||
print("Cmd, resp: ")
|
||||
print("".join("%02x " % b for b in cmd))
|
||||
print("".join("%02x " % b for b in resp))
|
||||
|
||||
return array.array('B', resp)
|
||||
|
||||
def reset_card():
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
pass
|
Loading…
Reference in New Issue