1#!/usr/local/bin/python3 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 7print("send with fragment and routing header type 0 to be source routed") 8 9import os 10from addr import * 11from scapy.all import * 12 13pid=os.getpid() 14eid=pid & 0xffff 15fid=pid & 0xffffffff 16payload=b"ABCDEFGHIJKLMNOP" 17packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/\ 18 IPv6ExtHdrFragment(id=fid)/\ 19 IPv6ExtHdrRouting(addresses=[OTHER_FAKE1_ADDR6, OTHER_FAKE2_ADDR6], \ 20 segleft=2)/\ 21 ICMPv6EchoRequest(id=eid, data=payload) 22eth=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/packet 23 24if os.fork() == 0: 25 time.sleep(1) 26 sendp(eth, iface=LOCAL_IF) 27 os._exit(0) 28 29ans=sniff(iface=LOCAL_IF, timeout=3, filter= 30 "ip6 and dst "+LOCAL_ADDR6+" and icmp6") 31for a in ans: 32 if a and a.type == ETH_P_IPV6 and \ 33 ipv6nh[a.payload.nh] == 'ICMPv6' and \ 34 icmp6types[a.payload.payload.type] == 'Parameter problem': 35 pprob=a.payload.payload 36 code=pprob.code 37 print("code=%#d" % (code)) 38 if code != 0: 39 print("WRONG PARAMETER PROBLEM CODE") 40 exit(2) 41 ptr=pprob.ptr 42 print("ptr=%#d" % (ptr)) 43 if ptr != 50: 44 print("WRONG PARAMETER PROBLEM POINTER") 45 exit(2) 46 exit(0) 47print("NO ICMP6 PARAMETER PROBLEM") 48exit(1) 49