1*a8307021Sbluhm#!/usr/local/bin/python3 228050b02Sbluhm# send Unsolicited Neighbor Advertisement 328050b02Sbluhm 4*a8307021Sbluhmprint("send unsolicited neighbor advertisement packet") 57b3475a7Sbluhm 628050b02Sbluhmimport os 728050b02Sbluhmfrom addr import * 828050b02Sbluhmfrom scapy.all import * 928050b02Sbluhm 1028050b02Sbluhm# link-local solicited-node multicast address 1128050b02Sbluhmdef nsma(a): 1228050b02Sbluhm n = inet_pton(socket.AF_INET6, a) 1328050b02Sbluhm return inet_ntop(socket.AF_INET6, in6_getnsma(n)) 1428050b02Sbluhm 1528050b02Sbluhm# ethernet multicast address of multicast address 1628050b02Sbluhmdef nsmac(a): 1728050b02Sbluhm n = inet_pton(socket.AF_INET6, a) 1828050b02Sbluhm return in6_getnsmac(n) 1928050b02Sbluhm 2028050b02Sbluhm# ethernet multicast address of solicited-node multicast address 2128050b02Sbluhmdef nsmamac(a): 2228050b02Sbluhm return nsmac(nsma(a)) 2328050b02Sbluhm 2428050b02Sbluhm# link-local address 2528050b02Sbluhmdef lla(m): 2628050b02Sbluhm return "fe80::"+in6_mactoifaceid(m) 2728050b02Sbluhm 287b3475a7Sbluhmip=IPv6(src=lla(LOCAL_MAC), dst="ff02::1")/ICMPv6ND_NA(tgt=LOCAL_ADDR6) 297b3475a7Sbluhmeth=Ether(src=LOCAL_MAC, dst=nsmac("ff02::1"))/ip 3028050b02Sbluhm 317b3475a7Sbluhmsendp(eth, iface=LOCAL_IF) 3228050b02Sbluhmtime.sleep(1) 3328050b02Sbluhm 3428050b02Sbluhmexit(0) 35