1#!/usr/local/bin/python2.7 2# send a ping6 packet with routing header type 0 3# try to source route 4# hide the routing header behind a fragment header to avoid header scan 5# we expect an ICMP6 error, as we do not support source routing 6 7import os 8from addr import * 9from scapy.all import * 10 11pid=os.getpid() 12payload="ABCDEFGHIJKLMNOP" 13packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ 14 IPv6ExtHdrFragment(id=pid)/\ 15 IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=2)/\ 16 ICMPv6EchoRequest(id=pid, data=payload) 17eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet 18 19if os.fork() == 0: 20 time.sleep(1) 21 sendp(eth, iface=SRC_IF) 22 os._exit(0) 23 24ans=sniff(iface=SRC_IF, timeout=3, filter= 25 "ip6 and dst "+SRC_OUT6+" and icmp6") 26for a in ans: 27 if a and a.type == ETH_P_IPV6 and \ 28 ipv6nh[a.payload.nh] == 'ICMPv6' and \ 29 icmp6types[a.payload.payload.type] == 'Parameter problem': 30 pprob=a.payload.payload 31 code=pprob.code 32 print "code=%#d" % (code) 33 if code != 0: 34 print "WRONG PARAMETER PROBLEM CODE" 35 exit(2) 36 ptr=pprob.ptr 37 print "ptr=%#d" % (ptr) 38 if ptr != 50: 39 print "WRONG PARAMETER PROBLEM POINTER" 40 exit(2) 41 exit(0) 42print "NO ICMP6 PARAMETER PROBLEM" 43exit(1) 44