惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
博客园_首页
U
Unit 42
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
IT之家
IT之家
G
Google Developers Blog
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
爱范儿
爱范儿
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
Jina AI
Jina AI
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
小众软件
小众软件
H
Help Net Security

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Building a Proactive Network Guardian: Deep Dive into Sen...
Bhilal. Chitou · 2026-06-05 · via DEV Community

Bhilal. Chitou

Traditional network security often acts like a security camera: it records the "crime" (an intrusion) but doesn't stop it. By the time an administrator checks the logs, the data might already be exfiltrated.

In the context of the MIRAGE Defense Platform, I developed Sentinelle—a module designed to move from passive logging to Active Response.

What is Sentinelle?

Sentinelle is the "Guardian" of the MIRAGE ecosystem. It is a Python-based IDS/IPS (Intrusion Detection & Prevention System) that performs deep packet inspection (DPI) and implements a graduated response to threats.

The Tech Stack

  • Python 3.12: The core engine.
  • Scapy: For packet sniffing, analysis, and forging.
  • Suricata Rules: Leveraging the power of the Emerging Threats (ET) ruleset for signature matching.
  • IPTables/Netfilter: For real-time kernel-level isolation.

Technical Architecture

Sentinelle operates as a middleman between raw network traffic and the decision-making "Brain" (ORACLE).

graph TD
    Traffic[Raw Network Traffic] --> Sniffer[Scapy Sniffer]
    Sniffer --> SigEngine[Signature Engine]
    Sniffer --> DNSGuard[DNS Guard]

    SigEngine -- Alert --> Logic{Response Logic}
    DNSGuard -- Malware Domain --> Logic

    Logic -->|Block| IPTables[IPTables Isolation]
    Logic -->|Kill| TCPReset[TCP Reset Attack]
    Logic -->|Report| Oracle[Oracle Orchestrator]

Enter fullscreen mode Exit fullscreen mode


Key Features

1. Deep Packet Inspection (DPI)

Sentinelle doesn't just look at headers; it inspects the payload. Using Scapy, it can identify patterns characteristic of:

  • SQL Injection attempts.
  • SSH/FTP Brute-forcing.
  • Scanning tools signatures (Nmap, ZMap).

2. DNS Guard: Killing C2 Channels

One of the most effective ways to stop malware is to break its "phone home" capability. Sentinelle acts as a transparent watcher on DNS traffic. If a local machine attempts to resolve a domain flagged by Threat Intelligence (like URLhaus), Sentinelle intercepts the request and blocks the resolution before the connection can even start.

3. Tiered Mitigation (The Escalation Logic)

Not every alert requires a total shutdown. Sentinelle implements a graduated response:

  • Level 1 (Info): Log locally and monitor.
  • Level 2 (Warning): Throttling bandwidth for the suspicious IP.
  • Level 3 (Critical): Immediate isolation via IPTables and triggering the GHOST module (redirecting the attacker to a honeypot).

4. TCP Reset Counter-Attacks

For high-priority threats, Sentinelle can forge TCP RST packets. This effectively "kills" a connection on both ends without needing complex firewall rules, providing an instantaneous stop to an ongoing attack.


Code Spotlight: The Sniffer Loop

Here is a simplified look at how Sentinelle processes traffic. This loop is non-blocking and handles packets at high speed.

from scapy.all import sniff, IP, TCP
from sentinelle.logic import SignatureEngine

def guardian_loop(interface="eth0"):
    print(f"[*] Sentinelle active on {interface}...")

    # We use a BPF filter to capture only IP traffic
    sniff(iface=interface, 
          filter="ip", 
          prn=process_packet, 
          store=0)

def process_packet(pkt):
    if pkt.haslayer(IP):
        # Pass the packet to our signature engine
        threat = SignatureEngine.check(pkt)

        if threat.is_critical:
            # Drop the connection immediately
            mitigate_threat(pkt)
            print(f"[!] Blocked critical threat from {pkt[IP].src}")

def mitigate_threat(pkt):
    # Forging a TCP Reset packet
    if pkt.haslayer(TCP):
        rst_pkt = IP(src=pkt[IP].dst, dst=pkt[IP].src)/TCP(sport=pkt[TCP].dport, dport=pkt[TCP].sport, flags="R")
        send(rst_pkt, verbose=0)

Enter fullscreen mode Exit fullscreen mode


Lessons Learned

Building a real-time defense system in Python comes with challenges, primarily around performance. To overcome this, Sentinelle uses:

  1. Standardized Events: All modules communicate via MirageEvent (JSON), ensuring interoperability.
  2. Multiprocessing: Offloading heavy analysis to separate cores.
  3. Kernel Integration: Using Python to decide and IPTables to execute.

What's Next?

The next phase for Sentinelle involves eBPF integration to move packet filtering even deeper into the Linux kernel for near-zero latency.


Are you building security tools with Python? I'd love to hear your thoughts on automated mitigation vs. manual intervention in the comments!

Find the project on GitHub | Connect with me on LinkedIn

python #cybersecurity #networking #devops #opensourcepython, #7Bhil, #Bhildollars