.gitignore | ||
CMakeLists.txt | ||
main.c | ||
README.md |
Build IPv6 ICMP ECHO packet with Ethernet headers
Simple C code that builds a valid (ish) ethernet icmpv6 echo packet.
- https://en.wikipedia.org/wiki/Ethernet_frame
- https://en.wikipedia.org/wiki/IPv6_packet
- https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6
- https://www.pdbuchan.com/rawsock/icmp6_cooked.c
- https://stackoverflow.com/a/14937171
a1f999fb17/scapy/utils.py (L493-L501)
a1f999fb17/scapy/layers/inet6.py (L608-L624)
Scapy code samples
Writen in scapy
shell
# import hex as packet
e = Ether(bytes.fromhex('fc de ad be ef 05 fc de ad be ef 56 86 dd 60 00 00 00 00 08 3a 02 fe 80 00 00 00 00 00 00 00 00 00 00 00 00 00 01 fe 80 00 00 00 00 00 00 50 5d 18 fb 5e 52 ec c0 81 00 4e cd 00 00 00 00 ef be ad de'))
e.show()
# Write packet as pcap to open in Wireshark
wrpcap("test.pcap", e)
# Calculate icmpv6 checksum
i = e[IPv6][ICMPv6EchoReply]
i.cksum = 0
r = raw(i)
print(hex(in6_chksum(socket.IPPROTO_ICMPV6, e[IPv6], r)))