๐ Network Packet Sniffer
CodeAlpha Cybersecurity Internship - Task 1
A comprehensive Python-based network packet sniffer that captures and analyzes network traffic in real-time
๐ฏ Educational โข ๐ Security Analysis โข ๐ Network Protocol Understanding
โจ Overview
This tool helps understand network protocols, data flow, and packet structure for educational and security analysis purposes. Built as part of the CodeAlpha Cybersecurity Internship program, it provides comprehensive packet analysis capabilities with an intuitive interface.
๐ Key Features
๐ Protocol Support
- Ethernet - MAC addresses & frame types
- IP - Source/destination IPs, TTL analysis
- TCP - Port numbers, flags, sequences
- UDP - Port numbers, length, payloads
- ICMP - Type and code analysis
- ARP - Address resolution monitoring
- DNS - Query and response analysis
|
โก Advanced Capabilities
- Real-time Analysis - Instant packet display
- Service Recognition - HTTP, HTTPS, SSH, DNS
- Flexible Filtering - Berkeley Packet Filter (BPF)
- Data Export - JSON format for analysis
- Detailed Information - Comprehensive packet data
- User-friendly Interface - Clean, organized output
|
๐ Requirements
| Requirement |
Version |
Purpose |
| ๐ Python |
3.6+ |
Core runtime |
| ๐ฆ Scapy |
Latest |
Packet manipulation |
| ๐ Root Access |
Required |
Packet capture |
| ๐ Network Interface |
Active |
Traffic monitoring |
๐ฆ Quick Start Installation
1๏ธโฃ Clone Repository
git clone https://github.com/musagithub1/CodeAlpha_NetworkSniffer.git
cd CodeAlpha_NetworkSniffer
2๏ธโฃ Install Dependencies
# Using Makefile (recommended)
make install
# Or manually
pip install -r requirements.txt
๐ฏ Usage Examples
Basic Operations
# ๐ Capture all packets
sudo python3 packet_sniffer.py
# ๐ฏ Capture specific count
sudo python3 packet_sniffer.py -c 10
# ๐ง Apply traffic filter
sudo python3 packet_sniffer.py -f "tcp port 80"
Advanced Scenarios
# ๐ HTTP traffic with file save
sudo python3 packet_sniffer.py -f "tcp port 80" --save
# โ๏ธ Specific interface with timeout
sudo python3 packet_sniffer.py -i eth0 --timeout 30
# ๐ DNS queries monitoring
sudo python3 packet_sniffer.py -f "port 53"
# ๐ฏ Target specific host
sudo python3 packet_sniffer.py -f "host google.com"
Makefile Commands
| Command |
Action |
Description |
make install |
๐ฆ |
Install all dependencies |
make run |
โถ๏ธ |
Run with default settings |
make run-count |
๐ข |
Run with packet limit |
make run-filter |
๐ง |
Run with HTTP filter |
make clean |
๐งน |
Clean temporary files |
โ๏ธ Configuration Options
| Option |
Description |
Example Usage |
-c, --count |
Number of packets to capture (0 = infinite) |
-c 50 |
-f, --filter |
Berkeley Packet Filter (BPF) string |
-f "tcp port 443" |
--save |
Save captured packets to JSON file |
--save |
-i, --interface |
Specify network interface to monitor |
-i eth0 |
--timeout |
Stop capture after specified seconds |
--timeout 60 |
๐ Sample Output
๐ Enhanced Network Packet Sniffer
๐ก CodeAlpha Cybersecurity Internship Project
==================================================
============================================================
Packet #1 - 2024-01-15 14:30:25
============================================================
๐ Ethernet Frame:
Source MAC: aa:bb:cc:dd:ee:ff
Destination MAC: 11:22:33:44:55:66
Type: 0x800
๐ IP Packet:
Source IP: 192.168.1.100
Destination IP: 8.8.8.8
Protocol: UDP
TTL: 64
Total Length: 76 bytes
๐ฆ UDP Datagram:
Source Port: 12345 (12345)
Dest Port: 53 (DNS)
Length: 56 bytes
DNS Query: Query for www.google.com
============================================================
๐๏ธ Project Architecture
CodeAlpha_NetworkSniffer/
โโโ ๐ packet_sniffer.py # Main application core
โโโ ๐ requirements.txt # Python dependencies
โโโ โ๏ธ Makefile # Build automation
โโโ ๐ซ .gitignore # Version control rules
โโโ ๐ README.md # Project documentation
โโโ ๐ captured_packets.json # Generated output (--save)
๐ Learning Outcomes
Core Concepts Mastered
๐ Network Fundamentals
- TCP/IP Protocol Stack
- Ethernet Frame Analysis
- Address Resolution Protocol (ARP)
- Network Layer Understanding
๐ Security Principles
- Traffic Monitoring Techniques
- Intrusion Detection Basics
- Network Vulnerability Assessment
- Ethical Security Testing
|
๐ป Technical Skills
- Python Network Programming
- Scapy Library Mastery
- Command-Line Interface Design
- System-Level Programming
๐ Analysis Capabilities
- Packet Header Examination
- Protocol Identification
- Payload Content Analysis
- Real-time Data Processing
|
๐ Security & Ethics
โ ๏ธ Important Guidelines
| Principle |
Description |
| ๐ฏ Ethical Use Only |
Tool designed for educational and authorized security testing |
| ๐ก๏ธ Privacy Respect |
Only monitor networks you own or have explicit permission |
| โ๏ธ Legal Compliance |
Ensure adherence to local laws and regulations |
| ๐ค Responsible Disclosure |
Report discovered vulnerabilities through proper channels |
๐ค Contributing
This project welcomes educational improvements and bug fixes
- ๐ด Fork the repository
- ๐ Create a feature branch
- โจ Make your improvements
- ๐ค Submit a pull request
๐ License
This project is developed for educational purposes as part of the CodeAlpha Cybersecurity Internship program.
๐จโ๐ป Author
Mussa Khan
CodeAlpha Cybersecurity Intern
๐ Acknowledgments
Special Thanks To:
- ๐ CodeAlpha - For the incredible internship opportunity
- ๐ Scapy Developers - For the outstanding packet manipulation library
- ๐ฅ Python Community - For comprehensive networking tools and support
โ ๏ธ Legal Disclaimer
This tool is intended exclusively for educational and authorized security testing purposes. Users assume full responsibility for ensuring compliance with applicable laws and obtaining proper authorization before monitoring any network traffic.
Built with โค๏ธ for cybersecurity education