blob: 32977a4aa2409fb93fd781a6ab5d07cad94953be [file] [log] [blame]
Christina Quastb8946912015-05-12 16:02:48 +02001#!/usr/bin/env python
2
3from scapy.all import IP, UDP, sr1
4
5ip="127.0.0.1"
6port=4729
7sp=58621
Christina Quast2a9c0632015-05-12 19:31:00 +02008gsmtap_hdr="\x02\x04\x04"+"\x00"*13
Christina Quastb8946912015-05-12 16:02:48 +02009
Christina Quast2a9c0632015-05-12 19:31:00 +020010# FIXME: Is ATR something special?
Christina Quastb8946912015-05-12 16:02:48 +020011
Christina Quast2a9c0632015-05-12 19:31:00 +020012def gsmtap_send_apdu(data):
13# Do we have performance penalty because the socket stays open?
14 p=IP(dst=ip, src=ip)/UDP(sport=sp, dport=port)/(gsmtap_hdr+data)
15# FIXME: remove show and ans
16 if p:
17 p.show()
Christina Quastb8946912015-05-12 16:02:48 +020018
Christina Quast2a9c0632015-05-12 19:31:00 +020019 ans = sr1(p, timeout=2)
20 if ans:
21 print(ans)
22
23if __name__ == '__main__':
24 cmds = ("\xa0\xa4\x00\x00\x02\x6f\x7e\x9f\x0f",
25 "\xa0\xd6\x00\x00\x0b\xff\xff\xff\xff\x09\xf1\x07\xff\xfe\x00\x03\x90\x00",
26 );
27 for cmd in cmds:
28 gsmtap_send_apdu(cmd)