Skip to content

About

AI-powered Network Intrusion Detection System using Machine Learning for Cybersecurity Threat Detection and Real-Time Monitoring.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Network Intrusion Detection System (IDS)

🎯 Project Overview

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.

Project Objective

Develop a real-time network monitoring system that captures live packets, analyzes traffic patterns, identifies intrusion attempts, and logs security events professionally.


✨ Key Features

Core Detection Capabilities

  • 🔍 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

Professional Features

  • 🎨 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

Code Quality

  • Modular Architecture - Separated concerns (alerts, analysis, main app)
  • Exception Handling - Graceful error management
  • Comprehensive Comments - Beginner-friendly explanations
  • Professional Documentation - Detailed docstrings and guides

🛠️ Technologies Used

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

Why These Technologies?

  • 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

🏗️ Architecture Overview

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

Component Responsibilities

1. ids.py - Main Entry Point

  • Initializes network packet capture
  • Manages user interface and CLI arguments
  • Coordinates packet analysis workflow
  • Displays real-time statistics

2. packet_analyzer.py - Detection Engine

  • Analyzes individual packets
  • Identifies port scanning patterns
  • Detects protocol anomalies
  • Tracks repeated connections
  • Identifies DoS attack signatures

3. alert_system.py - Alert Manager

  • Generates colored terminal alerts
  • Logs events to persistent file
  • Tracks suspicious IPs
  • Maintains alert statistics

🚀 Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • Administrator/Root privileges (required for packet capture)
  • Scapy dependencies (may require WinPcap on Windows)

Step 1: Clone the Repository

git clone https://github.com/Pratikshaprabhakarbande/CodeAlpha_NetworkIntrusionDetectionSystem.git
cd CodeAlpha_NetworkIntrusionDetectionSystem

Step 2: Create Virtual Environment (Recommended)

# On Windows
python -m venv venv
venv\Scripts\activate

# On Linux/Mac
python3 -m venv venv
source venv/bin/activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Verify Installation

python ids.py --list-interfaces

💻 Usage Instructions

Basic Usage

# 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

Command-Line Arguments

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 -

Example Session

# List interfaces first
python ids.py --list-interfaces

# Start monitoring on specific interface
python ids.py -i "Ethernet" -v

📊 Sample Output

Real-Time Terminal Output

╔══════════════════════════════════════════════════════════════════════╗
║         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)
======================================================================

alerts.log File

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)

🎓 Cybersecurity Concepts Explained

1. Port Scanning

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

2. DoS/DDoS Attacks

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

3. Protocol Anomalies

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

4. Suspicious Port Activity

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)


📚 Project Structure

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

🚨 Alert Types & Severity Levels

Alert Severity Levels

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

🔐 Security Considerations

What This Project DOES

  • ✅ Detects common attack signatures
  • ✅ Identifies suspicious traffic patterns
  • ✅ Provides educational cybersecurity insight
  • ✅ Demonstrates packet analysis techniques

What This Project DOES NOT

  • ❌ Replace enterprise security solutions
  • ❌ Guarantee detection of advanced threats
  • ❌ Perform deep packet inspection (DPI)
  • ❌ Implement complex ML models

Ethical Usage

This tool is designed for:

  • 📚 Educational purposes
  • 🔍 Network monitoring in authorized environments
  • 💼 Cybersecurity skill demonstration
  • 🧪 Home lab experimentation

🛠️ Installation on Different Platforms

Windows Installation

# 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

Linux Installation

# 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

macOS Installation

# 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

📈 Future Enhancements

Short-term Improvements

  • Machine Learning-based anomaly detection
  • Geographic IP mapping and visualization
  • Web-based dashboard interface
  • Email/Slack alert notifications
  • Packet payload inspection

Long-term Features

  • Integration with threat intelligence feeds
  • Advanced pattern recognition algorithms
  • Real-time network visualization
  • Automated response system
  • Multi-interface monitoring

🎯 Interview Preparation

Key Points to Highlight

  1. Real-time Processing: System processes packets in real-time without storage overhead
  2. Modular Design: Separated concerns for maintainability and scalability
  3. Professional Logging: Audit trails for security compliance
  4. Cross-platform: Works on Windows, Linux, and macOS

Common Interview Questions

  • 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


🤝 Contributing

This is an educational project. Contributions welcome for:

  • Bug fixes and improvements
  • Additional detection algorithms
  • Better documentation
  • Code optimization

📝 License

This project is licensed under the MIT License - see LICENSE file for details.


👨‍💻 Author & Contact

Project: Network Intrusion Detection System (IDS)
Created for: CodeAlpha Cyber Security Internship
GitHub: Pratikshaprabhakarbande
Repository: CodeAlpha_NetworkIntrusionDetectionSystem


📊 Project Statistics

Metric Value
Lines of Code 500+
Number of Modules 3
Detection Algorithms 5+
Supported Protocols TCP/UDP/ICMP
Alert Types 3+

🎓 Learning Resources

Understanding Network Security

Cybersecurity Concepts

  • Port Scanning Techniques
  • DoS/DDoS Attack Vectors
  • Network Traffic Analysis
  • Intrusion Detection Systems

🙏 Acknowledgments

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

📞 Support

For issues, questions, or suggestions:

  1. Check existing documentation
  2. Review code comments
  3. Consult cybersecurity references
  4. 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

About

AI-powered Network Intrusion Detection System using Machine Learning for Cybersecurity Threat Detection and Real-Time Monitoring.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages