Callback that reply to a NS with a spoofed NA
(req, reply_mac, router, iface)
| 3835 | return 1 |
| 3836 | |
| 3837 | def reply_callback(req, reply_mac, router, iface): |
| 3838 | """ |
| 3839 | Callback that reply to a NS with a spoofed NA |
| 3840 | """ |
| 3841 | |
| 3842 | # Let's build a reply (as defined in Section 7.2.4. of RFC 4861) and |
| 3843 | # send it back. |
| 3844 | mac = req[Ether].src |
| 3845 | pkt = req[IPv6] |
| 3846 | src = pkt.src |
| 3847 | tgt = req[ICMPv6ND_NS].tgt |
| 3848 | rep = Ether(src=reply_mac, dst=mac) / IPv6(src=tgt, dst=src) |
| 3849 | # Use the target field from the NS |
| 3850 | rep /= ICMPv6ND_NA(tgt=tgt, S=1, R=router, O=1) # noqa: E741 |
| 3851 | |
| 3852 | # "If the solicitation IP Destination Address is not a multicast |
| 3853 | # address, the Target Link-Layer Address option MAY be omitted" |
| 3854 | # Given our purpose, we always include it. |
| 3855 | rep /= ICMPv6NDOptDstLLAddr(lladdr=reply_mac) |
| 3856 | |
| 3857 | sendp(rep, iface=iface, verbose=0) |
| 3858 | |
| 3859 | print("Reply NA for target address %s (received from %s)" % (tgt, mac)) |
| 3860 | |
| 3861 | if not iface: |
| 3862 | iface = conf.iface |
no test coverage detected