mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-22 08:18:32 +03:00
simtrace.py: Use mitm.py in phone and mitm mode
This commit is contained in:
45
usb_application/smartcard_emulator.py
Normal file
45
usb_application/smartcard_emulator.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user