blob: d61d84761b807d2f3a1360e928ee024fc5db9dd6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/local/bin/python2.7
# check udp6 checksum in returned icmp packet
import os
from addr import *
from scapy.all import *
dstaddr=sys.argv[1]
pid=os.getpid()
payload="a" * 1452
p=(Ether(src=SRC_MAC, dst=PF_MAC)/IPv6(src=SRC_OUT6, dst=dstaddr)/
UDP(sport=pid,dport=9)/payload)
udpcksum=IPv6(str(p.payload)).payload.chksum
print "udpcksum=%#04x" % (udpcksum)
a=srp1(p, iface=SRC_IF, timeout=2)
if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \
ipv6nh[a.payload.nh] == 'ICMPv6' and \
icmp6types[a.payload.payload.type] == 'Packet too big':
outercksum=a.payload.payload.cksum
print "outercksum=%#04x" % (outercksum)
q=a.payload.payload.payload
if ipv6nh[q.nh] == 'UDP':
innercksum=q.payload.chksum
print "innercksum=%#04x" % (innercksum)
if innercksum == udpcksum:
exit(0)
print "INNERCKSUM!=UDPCKSUM"
exit(1)
print "NO INNER UDP PACKET"
exit(2)
print "NO PACKET TOO BIG"
exit(2)
|