diff options
author | Christina Quast <chrysh.ng+git@gmail.com> | 2015-05-12 19:31:00 +0200 |
---|---|---|
committer | Christina Quast <chrysh.ng+git@gmail.com> | 2015-05-12 19:31:04 +0200 |
commit | 2a9c063d6bd669463c5934ac5efbdf3635398d05 (patch) | |
tree | 9c3f95c46e386d8ef2cc23efa0298337fdaa6703 | |
parent | b89469184140ab44895fb43b519f70e42343d033 (diff) |
gsmtap.py: gsmtap_send_apdu and test main function
ATRs should probably be treated differently?
Also, is there a performance penalty when using scapy instead of holding a connection open?
-rw-r--r-- | usb_application/gsmtap.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/usb_application/gsmtap.py b/usb_application/gsmtap.py index e10faf2..32977a4 100644 --- a/usb_application/gsmtap.py +++ b/usb_application/gsmtap.py @@ -5,13 +5,24 @@ from scapy.all import IP, UDP, sr1 ip="127.0.0.1" port=4729 sp=58621 -data=("\x02\x04\x04"+"\x00"*13+"\x9f\x16\xa0\xc0\x00\x00\x16", "\x9f\x16\xa0\xc0\x00\x00\x16") +gsmtap_hdr="\x02\x04\x04"+"\x00"*13 -p=IP(dst=ip, src=ip)/UDP(sport=sp, dport=port)/data[0] +# FIXME: Is ATR something special? -if p: - p.show() +def gsmtap_send_apdu(data): +# Do we have performance penalty because the socket stays open? + p=IP(dst=ip, src=ip)/UDP(sport=sp, dport=port)/(gsmtap_hdr+data) +# FIXME: remove show and ans + if p: + p.show() -ans = sr1(p, timeout=2) -if ans: - print(a) + ans = sr1(p, timeout=2) + if ans: + print(ans) + +if __name__ == '__main__': + cmds = ("\xa0\xa4\x00\x00\x02\x6f\x7e\x9f\x0f", + "\xa0\xd6\x00\x00\x0b\xff\xff\xff\xff\x09\xf1\x07\xff\xfe\x00\x03\x90\x00", + ); + for cmd in cmds: + gsmtap_send_apdu(cmd) |