Raw Socket Sniffing in Golang

笑着哭i 提交于 2019-12-04 00:45:51

You should be able to use the ipv4 package from go.net.

Package ipv4 implements IP-level socket options for the Internet Protocol version 4.

The ipv4.RawConn type and it's associated methods should work cross-platform.

A RawConn represents a packet network endpoint that uses the IPv4 transport. It is used to control several IP-level socket options including IPv4 header manipulation. It also provides datagram based network I/O methods specific to the IPv4 and higher layer protocols that handle IPv4 datagram directly such as OSPF, GRE.

There is also an equivalent package for ipv6.

Take a look at https://code.google.com/p/gopacket/ since it supports pcap (requires cgo for this) and can decode a number of protocols including tcp/ip.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!