nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #!/usr/bin/env python |
2 | |||
3 | import sys |
||
4 | from scapy import * |
||
5 | import pcapy |
||
6 | from impacket.ImpactDecoder import * |
||
7 | |||
8 | try: |
||
9 | conf.verb=0 |
||
10 | except NameError: |
||
11 | # Scapy v2 |
||
12 | from scapy.all import * |
||
13 | conf.verb=0 |
||
14 | |||
15 | if len(sys.argv) != 2: |
||
16 | print "Usage: ./replay.py <iface>" |
||
17 | sys.exit(1) |
||
18 | |||
19 | interface=sys.argv[1] |
||
20 | |||
21 | max_bytes = 2048 |
||
22 | promiscuous = False |
||
23 | read_timeout = 100 # in milliseconds |
||
24 | packet_limit = -1 # infinite |
||
25 | |||
26 | pc = pcapy.open_live(interface, max_bytes, promiscuous, read_timeout) |
||
27 | |||
28 | def recv_pkts(hdr, data): |
||
29 | replay = True |
||
30 | |||
31 | if data[11] == "\xFF": |
||
32 | return |
||
33 | |||
34 | # separate ethernet header and ieee80211 packet |
||
35 | raw_header = data[:11] + "\xFF" + data[12:14] |
||
36 | header = Ether(raw_header) |
||
37 | |||
38 | try: |
||
39 | # end of separation |
||
40 | packet = Dot11(data[14:]) |
||
41 | except struct.error: |
||
42 | # Ignore unpack errors on short packages |
||
43 | return |
||
44 | |||
45 | # manipulate/drop/insert dot11 packet |
||
46 | print packet.summary() |
||
47 | # end of manipulation |
||
48 | |||
49 | # construct packet and replay |
||
50 | if replay == True: |
||
51 | data = header/packet |
||
52 | sendp(data, iface=interface) |
||
53 | |||
54 | pc.loop(packet_limit, recv_pkts) # capture packets |
||
55 |