Gniffer
is a lightweight Go tool that passively monitors incoming TCP connections to specific ports on your system without interfering with the actual services. Think of it as a simple packet sniffer that listens silently, logging connection attempts like SSH, HTTP, or any custom port you choose.
- ✅ Passive sniffing using
gopacket
andpcap
- 🎯 Monitor only specified TCP ports
- 📋 Logs source IP, destination IP, port, and TCP flags (SYN/ACK)
- 🧩 Modular structure with separate
sniffer
andlogger
packages - 🧠 Designed for learning, showcasing Go skills, or real-world usage
portsniffer/
├── main.go # CLI interface and app entrypoint
├── sniffer/
│ └── sniffer.go # Packet capturing and filtering logic
├── logger/
│ └── logger.go # Connection logging logic
├── go.mod # Go module definition
go mod tidy
Use the following command to list your network interfaces:
ip link
Common examples: eth0
, wlan0
, ens33
, etc.
sudo go run Gniffer -ports=22,80,443 -iface=eth0 --log=log.txt
Sniffing on eth0 | Ports: 22,80,443
[12:35:19] 192.168.1.20 ➜ 192.168.1.5:22 | SYN=true ACK=false
[12:35:21] 192.168.1.11 ➜ 192.168.1.5:443 | SYN=true ACK=false
...
go build -o gniffer
sudo ./gniffer -ports=22,80,443 -iface=eth0 --log=log.txt
- Only monitors TCP traffic
- Focuses on incoming packets, not outbound
- Doesn’t block or interfere with existing services