A network packet sniffer built in Go, inspired by Wireshark, that captures, analyzes, and saves network packets in real-time. Ideal for learning network protocols, traffic analysis, and debugging network applications.
- Automatically detects available network interfaces.
- Captures packets in promiscuous mode (TCP, UDP, ICMP, ARP, and more).
- Apply BPF filters to capture only specific traffic.
- Displays detailed packet info:
- Source and destination IP addresses
- Network and transport protocol details
- TCP flags (SYN, ACK, FIN, RST, etc.)
- TCP sequence numbers
- Payload in hexadecimal format
- Real-time counters for each protocol.
- Saves all captured packets in
.pcapformat for Wireshark analysis.
-
Install Go (1.20+) if not installed. You can download it from https://golang.org/dl/.
-
Clone the repository:
git clone https://github.com/Facelless/gopacket-sniffer.git
cd gopacket-sniffergo get github.com/google/gopacket
go get github.com/google/gopacket/pcap
go get github.com/google/gopacket/pcapgo
Run directly with go run:
sudo go run main.gosudo ./sniffer "tcp" # Only TCP packets
sudo ./sniffer "udp" # Only UDP packets
sudo ./sniffer "icmp" # Only ICMP packets
sudo ./sniffer "tcp port 80" # Only HTTP traffic
sudo ./sniffer "tcp or udp" # Capture TCP and UDP packets