Network Intrusion Detection System (IDS) is a professional-grade cybersecurity tool designed to monitor real-time network traffic, detect suspicious activities, and generate security alerts. Built with Python and Scapy, this project demonstrates intermediate cybersecurity concepts including packet analysis, threat detection, and security monitoring—ideal for cybersecurity internships and professional portfolios.
Develop a real-time network monitoring system that captures live packets, analyzes traffic patterns, identifies intrusion attempts, and logs security events professionally.
- 🔍 Port Scanning Detection - Identifies systematic port scanning behavior
⚠️ Suspicious Traffic Analysis - Detects abnormal protocol usage and behavior- 🔄 Repeated Request Monitoring - Tracks DoS/DDoS attack patterns
- 📊 Protocol Anomaly Detection - Identifies unusual TCP/UDP/ICMP patterns
- 🚨 Real-time Alert System - Instant notification of security events
- 🎨 Colored Terminal Output - Color-coded alerts for different severity levels
- 📝 Professional Logging - Structured logging to
alerts.log - ⏰ Timestamp Tracking - Every alert includes precise timestamps
- 📈 Statistics Dashboard - Real-time monitoring metrics
- 🛡️ Suspicious IP Tracking - Maintains list of potentially malicious IPs
- 💾 Persistent Alerting - Logs maintained for audit trails
- Modular Architecture - Separated concerns (alerts, analysis, main app)
- Exception Handling - Graceful error management
- Comprehensive Comments - Beginner-friendly explanations
- Professional Documentation - Detailed docstrings and guides
| Technology | Purpose | Version |
|---|---|---|
| Python | Programming language | 3.8+ |
| Scapy | Packet capture & analysis | 2.5.0 |
| Colorama | Cross-platform colored output | 0.4.6 |
| Logging | Professional log management | Built-in |
- Scapy: Industry-standard for network packet manipulation and analysis
- Colorama: Cross-platform color output (Windows/Linux/Mac)
- Python: Rapid development, extensive library support, industry standard
- Logging: Professional, structured alert management
Network Intrusion Detection System
│
├── ids.py (Main Application)
│ └─ Orchestrates packet capture and monitoring
│
├── packet_analyzer.py (Analysis Engine)
│ └─ Detects suspicious patterns and attacks
│
├── alert_system.py (Alert Manager)
│ └─ Handles logging and notifications
│
└── alerts.log (Audit Trail)
└─ Persistent record of all security events
- Initializes network packet capture
- Manages user interface and CLI arguments
- Coordinates packet analysis workflow
- Displays real-time statistics
- Analyzes individual packets
- Identifies port scanning patterns
- Detects protocol anomalies
- Tracks repeated connections
- Identifies DoS attack signatures
- Generates colored terminal alerts
- Logs events to persistent file
- Tracks suspicious IPs
- Maintains alert statistics
- Python 3.8 or higher
- Administrator/Root privileges (required for packet capture)
- Scapy dependencies (may require WinPcap on Windows)
git clone https://github.com/Pratikshaprabhakarbande/CodeAlpha_NetworkIntrusionDetectionSystem.git
cd CodeAlpha_NetworkIntrusionDetectionSystem# On Windows
python -m venv venv
venv\Scripts\activate
# On Linux/Mac
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtpython ids.py --list-interfaces# Run with auto-detected network interface
python ids.py
# Run with specific interface
python ids.py -i Ethernet
# Capture limited number of packets
python ids.py -i Ethernet -c 1000
# Enable verbose mode (detailed packet information)
python ids.py -v
# List available network interfaces
python ids.py --list-interfaces| Argument | Short | Purpose | Example |
|---|---|---|---|
--interface |
-i |
Specify network interface | -i eth0 |
--count |
-c |
Number of packets (0=infinite) | -c 5000 |
--verbose |
-v |
Enable detailed output | -v |
--list-interfaces |
- | Show available interfaces | - |
# List interfaces first
python ids.py --list-interfaces
# Start monitoring on specific interface
python ids.py -i "Ethernet" -v╔══════════════════════════════════════════════════════════════════════╗
║ Network Intrusion Detection System (IDS) v1.0 ║
║ Professional Cybersecurity Monitoring ║
╚══════════════════════════════════════════════════════════════════════╝
Features:
✓ Real-time network packet capture and analysis
✓ Port scanning detection
✓ Suspicious traffic pattern identification
✓ DoS/DDoS attack detection
✓ Protocol anomaly detection
✓ Colored alert notifications
✓ Professional logging system
======================================================================
NETWORK INTERFACE INFORMATION
======================================================================
Listening on Interface: Ethernet
Packet capture mode: PROMISCUOUS
Filter: All traffic (TCP/UDP/ICMP)
======================================================================
Starting packet capture...
[ALERT #1] PORT SCAN DETECTED
Timestamp: 2024-01-15 14:32:45
Source IP: 192.168.1.100
Target IP: 192.168.1.1
Port: 22 | Protocol: TCP
======================================================================
[ALERT #2] SUSPICIOUS TRAFFIC DETECTED
Timestamp: 2024-01-15 14:32:47
Source IP: 192.168.1.105
Target IP: 10.0.0.5
Protocol: TCP
Reason: Multiple attempts on suspicious port 3306 (MySQL)
======================================================================
2024-01-15 14:32:45 - WARNING - [PORT SCAN DETECTED] 192.168.1.100 → 192.168.1.1:22/TCP
2024-01-15 14:32:47 - WARNING - [SUSPICIOUS TRAFFIC] 192.168.1.105 → 10.0.0.5 | Protocol: TCP | Reason: Multiple attempts on suspicious port 3306 (MySQL)
2024-01-15 14:32:49 - WARNING - [REPEATED REQUESTS] 192.168.1.110 → 10.0.0.10:80 (15 requests detected)
What it is: Systematic probing of network ports to find open services Why it matters: Often the first step in network reconnaissance How we detect it: Multiple SYN packets to different ports from same source
What it is: Overwhelming a service with traffic to cause unavailability Why it matters: Common attack vector causing service disruption How we detect it: High packet count, repeated requests from single source
What it is: Unusual usage of network protocols (TCP/UDP/ICMP) Why it matters: Can indicate malware communication or network attacks How we detect it: Unexpected port usage, unusual flag combinations
What it is: Connections to known vulnerable or admin ports Why it matters: These ports are frequent attack targets How we detect it: Monitoring connections to ports like 3306 (MySQL), 5432 (PostgreSQL), 3389 (RDP)
CodeAlpha_NetworkIntrusionDetectionSystem/
│
├── ids.py # Main application entry point
├── packet_analyzer.py # Packet analysis and detection logic
├── alert_system.py # Alert generation and logging
├── requirements.txt # Python dependencies
├── alerts.log # Persistent alert log (generated)
│
├── README.md # This file
├── PROJECT_SUMMARY.md # Detailed project documentation
├── DEPLOYMENT_SUMMARY.md # Deployment and setup guide
├── interview_notes.md # Interview explanation guide
├── video_demo_guide.md # Screen recording guide
├── review_notes.md # Code review comments
├── .gitignore # Git ignore rules
└── LICENSE # MIT License
| Level | Color | Type | Example |
|---|---|---|---|
| CRITICAL | 🔴 RED | Port Scans, Active Attacks | SYN flood detection |
| WARNING | 🟡 YELLOW | Suspicious Patterns | Multiple failed login attempts |
| INFO | 🟢 GREEN | System Status | Monitoring started/stopped |
- ✅ Detects common attack signatures
- ✅ Identifies suspicious traffic patterns
- ✅ Provides educational cybersecurity insight
- ✅ Demonstrates packet analysis techniques
- ❌ Replace enterprise security solutions
- ❌ Guarantee detection of advanced threats
- ❌ Perform deep packet inspection (DPI)
- ❌ Implement complex ML models
This tool is designed for:
- 📚 Educational purposes
- 🔍 Network monitoring in authorized environments
- 💼 Cybersecurity skill demonstration
- 🧪 Home lab experimentation
# 1. Create virtual environment
python -m venv venv
venv\Scripts\activate
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run with administrator privileges
# Right-click Command Prompt → Run as Administrator
python ids.py# 1. Create virtual environment
python3 -m venv venv
source venv/bin/activate
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run with sudo (root privileges required)
sudo python3 ids.py# 1. Create virtual environment
python3 -m venv venv
source venv/bin/activate
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run with sudo
sudo python3 ids.py- Machine Learning-based anomaly detection
- Geographic IP mapping and visualization
- Web-based dashboard interface
- Email/Slack alert notifications
- Packet payload inspection
- Integration with threat intelligence feeds
- Advanced pattern recognition algorithms
- Real-time network visualization
- Automated response system
- Multi-interface monitoring
- Real-time Processing: System processes packets in real-time without storage overhead
- Modular Design: Separated concerns for maintainability and scalability
- Professional Logging: Audit trails for security compliance
- Cross-platform: Works on Windows, Linux, and macOS
-
Q: How does your IDS detect port scans? A: By tracking multiple connection attempts to different ports from the same source IP
-
Q: Why use Scapy over other libraries? A: Scapy is the industry standard for network packet manipulation with extensive protocol support
-
Q: How would you scale this to production? A: Migrate to distributed architecture with message queues, add ML models, integrate with SIEM systems
-
Q: What are false positives in your system? A: Traffic from VPN clients or network scanners can trigger false alerts; filtering helps
This is an educational project. Contributions welcome for:
- Bug fixes and improvements
- Additional detection algorithms
- Better documentation
- Code optimization
This project is licensed under the MIT License - see LICENSE file for details.
Project: Network Intrusion Detection System (IDS)
Created for: CodeAlpha Cyber Security Internship
GitHub: Pratikshaprabhakarbande
Repository: CodeAlpha_NetworkIntrusionDetectionSystem
| Metric | Value |
|---|---|
| Lines of Code | 500+ |
| Number of Modules | 3 |
| Detection Algorithms | 5+ |
| Supported Protocols | TCP/UDP/ICMP |
| Alert Types | 3+ |
- Port Scanning Techniques
- DoS/DDoS Attack Vectors
- Network Traffic Analysis
- Intrusion Detection Systems
This project demonstrates:
- Industry-standard packet capture using Scapy
- Professional Python development practices
- Real-world cybersecurity monitoring concepts
- Best practices in security logging and alerting
For issues, questions, or suggestions:
- Check existing documentation
- Review code comments
- Consult cybersecurity references
- Open GitHub issues
Last Updated: January 2024
Project Status: Complete and Production-Ready
Difficulty Level: Beginner to Intermediate
Time to Complete: 2-3 hours of setup and familiarization