A lightweight and extensible packet parsing tool designed for Intrusion Detection System (IDS) training and network traffic analysis.
This script captures live traffic or processes PCAP files, extracts HTTP and DNS data, and applies simple heuristic-based IDS rules to detect suspicious activity.
- Extracts HTTP method, host, path, and User-Agent
- Logs HTTP request details
- Detects:
- SQL Injection patterns
- Directory Traversal attempts
- Suspicious User-Agent strings (e.g., scanners/tools)
- Extracts DNS query domains
- Detects:
- Known malicious domain patterns
- Possible DNS tunneling (based on subdomain depth)
The parser implements basic IDS logic:
- SQL Injection detection
- Directory Traversal detection
- Suspicious tools (sqlmap, nmap, hydra, metasploit)
- Malicious DNS queries
- DNS tunneling heuristics
- Logs stored in
packet_parser.log - Console output with timestamps
- Multi-level logging (INFO, WARNING, ERROR, DEBUG)
- Live Capture from a network interface
- Offline Analysis from PCAP files
- Custom packet count limit
- Verbose debugging option
pip install scapysudo python3 packet_parser.py -f traffic.pcapsudo python3 packet_parser.py -i eth0sudo python3 packet_parser.py -i eth0 -c 500sudo python3 packet_parser.py -i eth0 -v| Argument | Description |
|---|---|
-i, --interface |
Network interface for live capture |
-f, --file |
PCAP file for offline analysis |
-c, --count |
Number of packets to capture (default 100) |
-v, --verbose |
Enable verbose/debug output |
After analysis, the script prints:
- Total packets processed
- Number of detected threats
- Detailed list of:
- Threat type
- Timestamp
- Source IP
- Domain (DNS threats)
- Path (HTTP threats)
Example threats include:
- SQL Injection Attempt
- Directory Traversal Attempt
- Suspicious User-Agent
- Malicious Domain Query
- Possible DNS Tunneling
- Live packet sniffing requires root/administrator privileges
- Log files may contain sensitive network metadata
- Use this tool only on networks you own or have explicit permission to analyze
- Intended purely for educational and research purposes
MIT License
This project is designed for security research, IDS training, and educational use.
Misuse of packet sniffing tools on unauthorized networks is illegal.