A Python-based network packet sniffer developed as part of the CodeAlpha Cyber Security Internship.
The application captures live network traffic, analyzes packet information using Scapy, displays useful network details, and saves captured packets in PCAP format for further analysis.
- Live network packet capture.
- IPv4 and IPv6 address identification.
- Ethernet MAC address extraction.
- ARP, ICMP, TCP and UDP protocol identification.
- TCP source and destination port extraction.
- TCP flag identification.
- DNS query and response analysis.
- Extraction of DNS A and AAAA records.
- Basic HTTP/TLS identification based on port numbers.
- Payload extraction in hexadecimal format.
- BPF packet filtering.
- Save captured packets as PCAP files.
- Configurable interface and packet count.
- Python 3
- Scapy
- Kali Linux
- Wireshark (for PCAP inspection)
CodeAlpha_NetworkSniffer/
│
├── captures/
├── logs/
├── packet_analyzer.py
├── sniffer.py
├── test_analyzer.py
├── requirements.txt
├── README.md
└── .gitignore
git clone https://github.com/psycho-champ/CodeAlpha_NetworkSniffer.git
cd CodeAlpha_NetworkSnifferpip install -r requirements.txtRoot privileges are required for live packet capture.
sudo python3 sniffer.pysudo python3 sniffer.py -i eth0sudo python3 sniffer.py -i eth0 -c 20sudo python3 sniffer.py -i eth0 -c 20 -f "tcp"sudo python3 sniffer.py -i eth0 -c 20 -f "udp"sudo python3 sniffer.py -i eth0 -c 20 -f "icmp"sudo python3 sniffer.py -i eth0 -c 0Press CTRL+C to stop the capture. Captured packets are saved automatically.
sudo python3 sniffer.py -i eth0 -c 20 -o captures/my_capture.pcapThe analyzer extracts information including:
- Timestamp
- Packet size
- Source and destination MAC addresses
- Source and destination IP addresses
- Network and transport protocols
- Source and destination ports
- TCP flags
- DNS queries and answers
- Raw payload data in hexadecimal format
TLS identification is based on port 443 and is not a guarantee that the traffic is encrypted TLS.
Captured PCAP files can be opened using Wireshark:
wireshark captures/your_capture.pcapThis tool is intended for educational purposes and authorized network analysis.
Only capture traffic on networks and devices for which you have permission.
Avoid sharing PCAP files publicly because they may contain sensitive network information.
Program: CodeAlpha Cyber Security Internship
Project: Task 1 - Basic Network Sniffer
Language: Python
Domain: Cyber Security / Network Security