mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-18 14:28:33 +03:00
replace.py: Moved replace func,mitm: addr book replace
Moved the replace function from mitm.py to replace.py. This implementation is context insensitive for now. It would be better, to have a mitm class or to pass state information to the function. Because how else can the MITM code know, whether it gets passed data to or from the sim card, to or from the phone?
This commit is contained in:
@@ -12,6 +12,8 @@ from util import HEX
|
||||
from constants import *
|
||||
from apdu_split import Apdu_splitter, apdu_states
|
||||
|
||||
from replace import replace
|
||||
|
||||
def pattern_match(inpt):
|
||||
print("Matching inpt", inpt)
|
||||
if (inpt == ATR_SYSMOCOM1) or (inpt == ATR_STRANGE_SIM):
|
||||
@@ -38,24 +40,6 @@ def write_phone(dev, resp):
|
||||
print("WR: ", HEX(resp))
|
||||
dev.write(PHONE_WR, resp, 10)
|
||||
|
||||
def replace(data):
|
||||
if data is None:
|
||||
raise MITMReplaceError
|
||||
else:
|
||||
try:
|
||||
if data[0] == 0x3B:
|
||||
print("*** Replace ATR")
|
||||
return array('B', NEW_ATR)
|
||||
elif data[0] == 0x9F:
|
||||
print("*** Replace return val")
|
||||
# return array('B', [0x60, 0x00])
|
||||
elif data == PHONE_BOOK_RESP:
|
||||
print("*** Replace phone book")
|
||||
return PHONE_BOOK_RESP_MITM
|
||||
except ValueError:
|
||||
print("*** Value error! ")
|
||||
return data
|
||||
|
||||
def do_mitm(dev, sim_emul=True):
|
||||
if sim_emul == True:
|
||||
my_class = SmartCardEmulator
|
||||
|
||||
Reference in New Issue
Block a user