Skip to content

About

CodeAlpha Cyber Security Internship Task 4 - Suricata-based Network Intrusion Detection System with custom detection rules, EVE JSON analysis, and automated testing.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

CodeAlpha Network Intrusion Detection System

CodeAlpha Network Intrusion Detection System - Task 4

CodeAlpha Cyber Security Internship · Task 4
Suricata-based Network Intrusion Detection System with custom detection rules, EVE JSON analysis, and automated testing.

Suricata 8.0.6 Python 3 12 tests passed 4 of 4 checks passed

Overview • Architecture • Features • Quick Start • Detection Rules • Evidence • Security & Privacy

Authorized-use notice: This project is a defensive, educational NIDS demonstration. Use it only on systems, interfaces, traffic, and networks that you own or have explicit permission to monitor.


Overview

The CodeAlpha Network Intrusion Detection System (NIDS) is a lightweight, defensive security project built around Suricata and Python.

It demonstrates an end-to-end intrusion-detection workflow:

Authorized Lab Traffic
        │
        ▼
    Suricata IDS
        │
        ▼
 Custom Detection Rules
   rules/local.rules
        │
        ▼
     Alert Match
        │
    ┌───┴──────────────┐
    │                  │
    ▼                  ▼
fast.log           EVE JSON
                       │
                       ▼
              Python Alert Analyzer
                       │
                       ▼
             Sanitized Alert Summary
                       │
                       ▼
                Reports / Evidence

The project is intentionally scoped for an educational laboratory environment. It focuses on transparent rule logic, structured alert output, repeatable analysis, and evidence-based verification rather than enterprise-scale deployment.


Objectives

This project was developed to demonstrate that a small NIDS workflow can:

  • monitor authorized network traffic with Suricata
  • detect selected network activity with custom signatures
  • generate structured alerts in EVE JSON
  • analyze alert metadata programmatically with Python
  • validate the analysis component with automated tests
  • document security considerations and limitations
  • preserve evidence while keeping sensitive runtime telemetry out of the public repository

Architecture

Detection Pipeline

┌──────────────────────────────┐
│      Authorized Lab          │
│      Network Traffic         │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│          Npcap / PCAP        │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│          Suricata            │
│          IDS Engine          │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│      rules/local.rules       │
│      Custom Signatures       │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│       Detection Alert        │
└──────────────┬───────────────┘
               │
        ┌──────┴──────┐
        ▼             ▼
   fast.log       EVE JSON
                       │
                       ▼
             ┌──────────────────┐
             │ Python Analyzer  │
             │ analyze_alerts.py│
             └────────┬─────────┘
                      │
                      ▼
             reports/alert_summary.json

Project Workflow

Configure HOME_NET
        ↓
Load custom rules
        ↓
Validate Suricata configuration
        ↓
Start IDS monitoring
        ↓
Generate authorized test traffic
        ↓
Confirm detection alert
        ↓
Inspect EVE JSON / fast.log
        ↓
Analyze alerts with Python
        ↓
Run automated tests
        ↓
Capture and sanitize evidence

Features

Network Intrusion Detection

  • Suricata-based signature detection
  • $HOME_NET-scoped custom rules
  • IDS/passive monitoring workflow
  • Live Npcap/PCAP capture support
  • Offline authorized PCAP analysis

Custom Detection Coverage

The current rule set demonstrates detection of:

  • ICMP echo-request activity
  • repeated TCP SYN activity as a reconnaissance indicator
  • TCP SYN activity toward ports 22 and 3389
  • TCP NULL-scan indicators

Structured Alerting

Suricata can produce:

  • EVE JSON for machine-readable processing
  • fast.log for human-readable alert review
  • runtime statistics and engine logs

Python Analysis

analysis/analyze_alerts.py provides:

  • total alert counts
  • signature frequency
  • severity distribution
  • alert categories
  • top source IPs
  • top destination IPs
  • protocol distribution
  • optional JSON summary generation

Verification

The project includes:

  • automated pytest coverage
  • Suricata configuration validation
  • custom-rule validation
  • analyzer import validation
  • EVE JSON analysis
  • controlled alert-generation evidence

Technology Stack

Component Technology
NIDS Engine Suricata 8.0.6
Packet Capture Npcap / PCAP
Detection Rules Suricata rule syntax
Alert Format EVE JSON
Alert Analysis Python
Testing pytest
Configuration YAML
Version Control Git / GitHub
Documentation Markdown

Project Structure

CodeAlpha_NetworkIntrusionDetectionSystem/
│
├── analysis/
│   ├── analyze_alerts.py
│   └── README.md
│
├── config/
│   └── suricata.yaml
│
├── logs/
│   └── README.md
│
├── reports/
│   ├── alert_summary.json
│   ├── DETECTION_RULES.md
│   ├── SECURITY_REVIEW.md
│   └── TEST_RESULTS.md
│
├── rules/
│   └── local.rules
│
├── screenshots/
│   ├── 00_project_banner.png
│   ├── 01_suricata_setup.png
│   ├── 02_rule_loaded.png
│   ├── 03_alert_generated.png
│   ├── 04_eve_analysis.png
│   ├── 05_tests_passed.png
│   └── README.md
│
├── tests/
│   └── test_alert_analysis.py
│
├── tools/
│   └── run_nids_test.py
│
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt

Directory Responsibilities

Directory Responsibility
analysis/ Python-based EVE JSON alert analysis
config/ Project-specific Suricata configuration
logs/ Local runtime output guidance
reports/ Detection, security, and test documentation
rules/ Custom Suricata signatures
screenshots/ Visual execution evidence
tests/ Automated tests
tools/ Project-level validation helper

Generated runtime telemetry, packet captures, Python caches, and temporary files are intentionally excluded from the public repository.


Quick Start

Prerequisites

Install:

  • Python 3.x
  • Suricata 8.0.6 for the validated demonstration environment
  • Npcap on Windows when using live packet capture
  • pytest
  • Git

1. Open the project

cd CodeAlpha_NetworkIntrusionDetectionSystem

2. Install Python dependencies

python -m pip install -r requirements.txt

3. Verify Python testing

python -m pytest --version

4. Verify Suricata

suricata --build-info

5. Validate the installed Suricata configuration

For the validated Windows environment:

suricata -T -c "C:\Program Files\Suricata\suricata.yaml"

A successful validation ends with:

Configuration provided was successfully loaded. Exiting.

Suricata Configuration

The project-specific configuration is:

config/suricata.yaml

Network Variables

Set HOME_NET to the CIDR of the authorized lab network.

Example:

vars:
  address-groups:
    HOME_NET: "[192.168.56.0/24]"
    EXTERNAL_NET: "!$HOME_NET"

The example is documentation-only. Replace it with the correct range for your authorized environment.

Custom Rule Loading

The project rule file is:

rules/local.rules

The configuration is designed to load it through:

default-rule-path: ./rules

rule-files:
  - local.rules

EVE JSON Output

Structured alerts are consumed from:

logs/eve.json

Raw runtime files are intended to remain local.


Detection Rules

The project reserves the local SID range:

1000000-1000999

Current signatures:

SID Detection Classification Revision
1000001 ICMP echo request misc-activity 1
1000002 Repeated TCP SYN activity attempted-recon 1
1000003 TCP SYN activity toward ports 22/3389 misc-activity 2
1000004 TCP NULL-scan indicator attempted-recon 1

SID 1000003 is currently revision 2 and uses explicit to_server direction.

Full rule documentation is available in reports/DETECTION_RULES.md.

Important Interpretation

These signatures are detection indicators, not automatic proof of malicious activity.

ICMP alert
    ≠
confirmed attack
SYN-scan indicator
    ≠
confirmed compromise

Context, host behavior, timing, and additional telemetry are required for meaningful investigation.


Running the NIDS

Validate Configuration

suricata -T -c "C:\Program Files\Suricata\suricata.yaml"

Start Live IDS Monitoring

Use the actual authorized Npcap/PCAP device identifier accepted by the installed Suricata build:

suricata -c "C:\Program Files\Suricata\suricata.yaml" -l ".\logs" -i "<AUTHORIZED_NPCAP_DEVICE>"

Do not assume that a Windows InterfaceIndex such as 7 is a valid Suricata capture identifier.

Analyze an Authorized PCAP

suricata -c "C:\Program Files\Suricata\suricata.yaml" -l ".\logs" -r "<AUTHORIZED_CAPTURE.pcap>"

Runtime Outputs

Depending on the active configuration, local runtime files can include:

logs/eve.json
logs/fast.log
logs/stats.log
logs/suricata.log

These are generated telemetry and should remain local unless deliberately reviewed and sanitized.


Alert Analysis

The Python analyzer is:

analysis/analyze_alerts.py

Analyze EVE JSON

python analysis\analyze_alerts.py "logs\eve.json"

Write a Structured Summary

python analysis\analyze_alerts.py "logs\eve.json" --output "reports\alert_summary.json"

The analyzer reports:

Total alerts
Alerts by signature
Alerts by severity
Alerts by category
Top source IPs
Top destination IPs
Alerts by protocol

It processes alert metadata and does not execute commands represented in the input data or modify the source EVE JSON.


Testing and Verification

Python Test Suite

Run:

python -m pytest -q

Validated project result:

12 passed

Project Validation Helper

Run:

python tools\run_nids_test.py

Validated result:

[PASS] Project structure
[PASS] Custom rule file
[PASS] Python analyzer import
[PASS] Automated tests

Validation summary: 4/4 checks passed
All selected validation checks passed.

Optional Validation Modes

python tools\run_nids_test.py --validate-suricata
python tools\run_nids_test.py --eve "logs\eve.json"
python tools\run_nids_test.py --validate-suricata --eve "logs\eve.json"

Use actual runtime output when documenting results. Do not replace real execution results with fabricated output.


Evidence

The project includes a complete visual evidence chain.

01 · Suricata Setup

Suricata Setup

Shows the validated Suricata installation/build information and live-capture environment.

02 · Rule Loaded

Rule Loaded

Shows successful Suricata configuration/rule validation.

03 · Alert Generated

Alert Generated

Shows authorized ICMP traffic triggering the project signature:

SID 1000001
CODEALPHA NIDS - ICMP echo request observed

The evidence also shows the alert being recorded in Suricata output and EVE JSON.

04 · EVE JSON Analysis

EVE JSON Analysis

Shows Python processing Suricata EVE JSON.

The demonstrated analysis includes:

Total alerts: 4
Signature: CODEALPHA NIDS - ICMP echo request observed
Severity: 3
Category: Misc activity
Protocol: ICMP

05 · Automated Tests Passed

Automated Tests Passed

Shows the validated automated test and project-verification results:

12 passed
4/4 validation checks passed

Evidence Integrity

These screenshots are intended to document actual execution in an authorized lab environment.

Do not fabricate:

  • terminal output
  • alert records
  • test results
  • screenshots
  • runtime metrics

Reports

Detection Rules

reports/DETECTION_RULES.md

Detailed documentation for all custom SIDs, rule logic, revisions, classification, tuning considerations, and limitations.

Security Review

reports/SECURITY_REVIEW.md

Documents the security review scope, configuration review, detection coverage, privacy considerations, findings, and final assessment.

Test Results

reports/TEST_RESULTS.md

Documents automated tests, Suricata validation, controlled detection testing, EVE JSON verification, and evidence requirements.

Sanitized Alert Summary

reports/alert_summary.json

Machine-readable summary of the demonstrated alert-analysis results.

The raw EVE JSON and raw Suricata logs from the live demonstration are not published.


Security & Privacy

This repository is intended for educational and portfolio use.

Never Publish

Do not commit:

  • raw production traffic
  • private packet captures
  • credentials
  • API keys
  • authentication tokens
  • sensitive payload data
  • unnecessary internal network details
  • raw EVE JSON
  • raw Suricata runtime logs
  • Python cache directories

Sanitized Public Report

The public file:

reports/alert_summary.json

uses documentation-safe IP addresses instead of the private LAN addresses used during the local demonstration.

Publication note: The structured alert report is sanitized for public release. The evidence screenshots were captured during an authorized local lab test and may contain the original lab addresses used during execution.

Repository Hygiene

Before committing:

git status --short

Verify generated runtime files are ignored:

git check-ignore -v `
".pytest_cache" `
"analysis\__pycache__" `
"tests\__pycache__" `
"tools\__pycache__" `
"logs\eve.json" `
"logs\fast.log" `
"logs\stats.log" `
"logs\suricata.log"

The sanitized reports/alert_summary.json should remain trackable and should not be listed as ignored.


CodeAlpha Task 4 Mapping

Task 4 Requirement Implementation
Build/configure a NIDS Suricata-based NIDS
Monitor authorized traffic Npcap/PCAP live capture or authorized PCAP
Configure detection rules rules/local.rules
Detect selected suspicious activity Four custom Suricata signatures
Generate alerts EVE JSON and fast.log
Analyze detected activity analysis/analyze_alerts.py
Produce structured results reports/alert_summary.json
Test the solution pytest + project validation helper
Validate Suricata suricata -T
Document rules reports/DETECTION_RULES.md
Document security review reports/SECURITY_REVIEW.md
Document testing reports/TEST_RESULTS.md
Provide evidence screenshots/
Apply responsible-use controls Authorization, privacy, and repository hygiene

Limitations

This project is an educational NIDS implementation, not an enterprise security platform.

It does not provide:

  • comprehensive attack coverage
  • endpoint detection and response
  • SIEM integration
  • automated incident response
  • complete threat-intelligence enrichment
  • high-availability sensor architecture
  • enterprise-scale performance benchmarking
  • production-grade rule tuning

Signature-based detection can produce false positives and false negatives. Real deployments require broader detection coverage, environment-specific baselines, threshold tuning, operational monitoring, and analyst investigation.

A detection alert should be treated as an investigation signal, not automatic proof of compromise.


Project Status

Project structure                   ✅
Suricata installation validation    ✅
Custom detection rules              ✅
Suricata rule loading               ✅
Live ICMP detection demonstration   ✅
EVE JSON alert generation           ✅
Python alert analysis               ✅
Automated tests                     ✅
Security documentation              ✅
Evidence screenshots                ✅
Public-report sanitization          ✅
GitHub repository                   ✅

Validated Results

Suricata version:       8.0.6
Custom signatures:      4
Demonstrated alerts:    4
Python tests:           12 passed
Project checks:         4/4 passed
Evidence screenshots:   5

Responsible Use

This project is intended for:

Owned systems
Authorized laboratory environments
Explicitly authorized networks

Do not use it to monitor third-party infrastructure without permission, intercept unauthorized traffic, conduct unauthorized reconnaissance, or expose confidential security telemetry.


Author

Subhadeep Adhikary

CodeAlpha Cyber Security Intern


License

This project is licensed under the MIT License.

See LICENSE for the complete license text.

About

CodeAlpha Cyber Security Internship Task 4 - Suricata-based Network Intrusion Detection System with custom detection rules, EVE JSON analysis, and automated testing.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages