This project implements a basic network packet sniffer built in Go.
Core Features
- Capturing raw network packets from specified network interfaces.
- Parsing Ethernet, ARP, and IP packets.
- Layered packet analysis using a
PacketLayer
interface. - Implementations for Ethernet, ARP, and IP layers.
Warning
This library is unfinished. Keep your expectations low.
- Init
go mod init github.com/your/repo
- Get
go get -u github.com/nikolaycc/sniff
- Clone Repo
git clone [email protected]:Nikolaycc/Sniff.git
- Build
make
- Run (might require root/administrator privileges)
./sniff -h
- Run Tests (might require root/administrator privileges)
./tests
import "github.com/nikolaycc/Sniff/sniffer"
func handlePacket(p sniff.EthLayer, sptr, size uintptr) {
....
}
func main() {
s := sniff.Capture{}
s.CreateCap("wlp2s0")
defer s.Destroy()
s.Cap(handlePacket)
}
$ sudo sniff -h
Usage of ./sniff:
-i string
Network Interface (default "lo")
-l int
Loop quantity (default 1)
-ls
List of Network Interface
-o string
Output log file
Contributing
Feel free to contribute by adding support for more protocols (TCP, UDP, ICMP, etc.), improving parsing logic, and enhancing the output format.
Future Improvements
- Implement TCP, UDP, and ICMP parsing.
- Add more sophisticated error handling.
- Create a user-friendly output with filtering options.
- Explore integration with packet analysis libraries like gopacket.
- Fork it (https://github.com/nikolaycc/sniff/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Nikolaycc - creator and maintainer