Sniffer with ringbuf, works SOMETIMES

* Sniffer uses phone endpoints for communication and the ringbuffer
    routines the phone communication uses
* Most times the Usart1 interrupt is not triggered, and therefore
    no values are recorded
This commit is contained in:
Christina Quast
2015-04-12 09:31:36 +02:00
parent 5c6a299c71
commit 2b8a18bf3a
11 changed files with 80 additions and 72 deletions

View File

@@ -1,5 +1,14 @@
from array import array
SIM_WR = 0x1
SIM_RD = 0x82
SIM_INT = 0x83
PHONE_WR = 0x4
PHONE_RD = 0x85
PHONE_INT = 0x86
CMD_SEL_ROOT = array('B', [0xA0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00])
CMD_SEL_FILE = array('B', [0xA0, 0xA4, 0x00, 0x00, 0x02, 0x7F, 0x20])
CMD_GET_DATA = array('B', [0xA0, 0xC0, 0x00, 0x00, 0x16])
@@ -10,4 +19,4 @@ atr_supersim= array('B', [0x3B, 0x9A, 0x94, 0x00, 0x92, 0x02, 0x75, 0x93, 0x11,
ATR_SYSMOCOM1 = array('B', [0x3B, 0x99, 0x18, 0x00, 0x11, 0x88, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x60])
ATR_SYSMOCOM2 = array('B', [0x3B, 0x99, 0x11, 0x00, 0x11, 0x88, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x60])
NEW_ATR = ATR_SYSMOCOM2
ATR_STRANGE_SIM = array('B', [0x3B 0x0B 0x00 0x20 0x00 0x00 0x00 0x00 0x68 0x2E 0x00 0x20 0x68])
ATR_STRANGE_SIM = array('B', [0x3B, 0x0B, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x68, 0x2E, 0x00, 0x20, 0x68])

View File

@@ -7,6 +7,7 @@ import phone
from contextlib import closing
from util import HEX
from constants import PHONE_WR, PHONE_RD, PHONE_INT, SIM_WR, SIM_RD, SIM_INT
def find_dev():
dev = usb.core.find(idVendor=0x03eb, idProduct=0x6004)
@@ -30,14 +31,6 @@ def pattern_match(inpt):
else:
return inpt
SIM_WR = 0x1
SIM_RD = 0x82
SIM_INT = 0x83
PHONE_WR = 0x4
PHONE_RD = 0x85
PHONE_INT = 0x86
ERR_TIMEOUT = 110
def poll_ep(dev, ep):

View File

@@ -3,7 +3,9 @@
import usb.core
import usb.util
import sys
import array
from constants import PHONE_RD
def find_dev():
dev = usb.core.find(idVendor=0x03eb, idProduct=0x6004)
@@ -46,14 +48,18 @@ def find_eps(dev):
# main code
def sniff():
dev = find_dev()
ans = array.array('B', [])
while True:
#ep_out.write("Hello")
try:
ans = dev.read(0x82, 64, 1000)
print("".join("%02x " % b for b in ans))
ans += dev.read(PHONE_RD, 64, 1000)
except KeyboardInterrupt:
print("Bye")
sys.exit()
except:
print("Timeout")
except Exception as e:
print e
if len(ans) >= 15:
print("".join("%02x " % b for b in ans))
ans = array.array('B', [])