Christina Quast | b894691 | 2015-05-12 16:02:48 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | from scapy.all import IP, UDP, sr1 |
| 4 | |
| 5 | ip="127.0.0.1" |
| 6 | port=4729 |
| 7 | sp=58621 |
Christina Quast | 2a9c063 | 2015-05-12 19:31:00 +0200 | [diff] [blame] | 8 | gsmtap_hdr="\x02\x04\x04"+"\x00"*13 |
Christina Quast | b894691 | 2015-05-12 16:02:48 +0200 | [diff] [blame] | 9 | |
Christina Quast | 2a9c063 | 2015-05-12 19:31:00 +0200 | [diff] [blame] | 10 | # FIXME: Is ATR something special? |
Christina Quast | b894691 | 2015-05-12 16:02:48 +0200 | [diff] [blame] | 11 | |
Christina Quast | 2a9c063 | 2015-05-12 19:31:00 +0200 | [diff] [blame] | 12 | def 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 Quast | b894691 | 2015-05-12 16:02:48 +0200 | [diff] [blame] | 18 | |
Christina Quast | 2a9c063 | 2015-05-12 19:31:00 +0200 | [diff] [blame] | 19 | ans = sr1(p, timeout=2) |
| 20 | if ans: |
| 21 | print(ans) |
| 22 | |
| 23 | if __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) |