SHAROZ221/SentinelShield-WAF

GitHub: SHAROZ221/SentinelShield-WAF

一款基于 Python Flask 的 Web 应用防火墙,通过特征匹配和速率限制实时检测并拦截恶意 HTTP 请求,同时提供可视化监控仪表盘。

Stars: 7 | Forks: 0

Typing SVG ### 高级入侵检测与 Web 防护系统 [![Python](https://img.shields.io/badge/Python-3.8+-3776AB?style=flat-square&logo=python&logoColor=white)](https://python.org) [![Flask](https://img.shields.io/badge/Flask-3.0-000000?style=flat-square&logo=flask&logoColor=white)](https://flask.palletsprojects.com) [![Status](https://img.shields.io/badge/Status-Active-00ff88?style=flat-square)]() [![Type](https://img.shields.io/badge/Type-WAF%20%2F%20IDS-red?style=flat-square)]() [![实时演示](https://img.shields.io/badge/🛡️_Live_Demo-Railway-blueviolet?style=flat-square)](https://web-production-41b62.up.railway.app) [![License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)]()

**[🚀实时演示](https://web-production-41b62.up.railway.app)** · **[📊仪表盘](https://web-production-41b62.up.railway.app/dashboard)** ·
## 🔍 什么是 SentinelShield? SentinelShield 充当 **Web Application Firewall (WAF)** — 它位于传入的 HTTP 请求和您的 Web 应用程序之间,在请求通过之前对每个请求进行检查。 - 🚫 检测到恶意 payload? → **拦截,返回 403 Forbidden** - ⏱️ 来自同一 IP 的请求过多? → **触发限流,返回 429** - ✅ 正常的请求? → **放行并记录日志** - 📊 一切可视化 → **实时仪表盘** 这与 **Cloudflare WAF**、**AWS WAF** 和 **ModSecurity** 等企业级工具使用的概念相同。 ## ⚙️ 工作原理 ``` Incoming HTTP Request │ ▼ ┌───────────────────┐ │ Rate Limit Check │──► Too many requests? ──► BLOCK 429 └───────────────────┘ │ ▼ ┌───────────────────┐ │ Signature Scan │──► Malicious payload? ──► BLOCK 403 └───────────────────┘ │ ▼ ALLOW ✅ + Log Event → Dashboard updates live ``` 每个事件——无论是被允许还是被拦截——都会保存到兼容 **SIEM 的 JSON 日志**中,并实时反映在仪表盘上。 ## 🚨 检测到的攻击 | 攻击类型 | 示例 Payload | 严重程度 | |---|---|:---:| | SQL Injection | `' OR '1'='1` | 🔴 高 | | Cross-Site Scripting (XSS) | `` | 🔴 高 | | Command Injection | `; cat /etc/passwd` | 🔴 高 | | Local File Inclusion (LFI) | `../../../../etc/passwd` | 🔴 高 | | 目录遍历 | `../../../windows/system32` | 🟡 中 | | XXE Injection | `` | 🟡 中 | | 扫描器检测 | User-Agent: `sqlmap/1.7` | 🟢 低 | | 暴力破解 | 15+ 次请求 / 30 秒 | 🟡 中 | ## 📊 实时仪表盘 仪表盘实时显示: - 🔢 **实时计数器** — 总请求数、被拦截的攻击数、正常请求数、被限流的 IP - 🥧 **攻击类型图表** — 检测到的攻击类别分布 - 📈 **严重程度细分** — 高 / 中 / 低及其检测率 % - 🌐 **主要攻击 IP** — 最活跃的威胁来源 - 📋 **实时事件日志** — 每个请求的时间戳、IP、状态和攻击类型 ## 🚀 快速入门 ### 前置条件 - Python 3.8+ - pip ### 安装说明 ``` # 克隆 repository git clone https://github.com/SHAROZ221/SentinelShield-WAF.git cd SentinelShield-WAF # 安装 dependencies pip install -r requirements.txt # 启动 WAF python app.py # 打开 dashboard # → http://localhost:5000/ ``` ### 运行攻击模拟器*(可选 — 在第二个终端中)* ``` python simulator.py ``` 观察仪表盘的实时更新,攻击将在实时检测并被拦截。 ## 📁 项目结构 ``` SentinelShield/ ├── app.py → Main WAF server & Flask routes ├── rules.py → Attack signature patterns (regex) ├── monitor.py → Rate limiting & IP tracking ├── logger.py → JSON event logging & statistics ├── simulator.py → Automated attack test suite ├── requirements.txt → Python dependencies ├── templates/ │ └── dashboard.html → Live web dashboard (Chart.js) └── logs/ └── sentinel.log → Auto-generated SIEM-compatible log ``` ## 🧰 技术栈 | 技术 | 用途 | |---|---| | **Python 3.8+** | 核心语言 | | **Flask** | Web 服务器和路由 | | **Python `re`** | 基于 Regex 的特征匹配 | | **Chart.js** | 仪表盘可视化 | | **JSON logging** | 兼容 SIEM 的结构化日志 | | **Flask-CORS** | 跨域请求处理 | ## 🌐 测试实时 WAF 尝试在浏览器中发送这些 URL — 观察它们被**拦截**: ``` # SQL Injection https://web-production-41b62.up.railway.app/search?q=' OR '1'='1 # XSS Attack https://web-production-41b62.up.railway.app/search?q= # Directory Traversal https://web-production-41b62.up.railway.app/search?q=../../../etc/passwd ``` ## 🎯 学习成果 构建此项目涵盖了真实的 SOC 技能: - ✅ 了解 WAF 架构和请求检查 - ✅ 编写攻击检测特征(Regex 模式) - ✅ 限流和基于 IP 的威胁追踪 - ✅ 兼容 SIEM 的结构化日志 - ✅ 具有实时数据的动态仪表盘 - ✅ 云端部署 (Railway)
由 **[Sharoz](https://github.com/SHAROZ221)** 使用 🔐 制作 BCA 三年级 · 网络安全 (SOC 方向) · 印度 [![GitHub](https://img.shields.io/badge/GitHub-SHAROZ221-181717?style=flat-square&logo=github)](https://github.com/SHAROZ221) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Sharoz_Mohd-0077B5?style=flat-square&logo=linkedin)](https://www.linkedin.com/in/sharoz-mohd-86057a408/) *"检测 • 分析 • 防御"*
标签:AppImage, Flask, Python, WAF, Web应用防火墙, 安全防护, 无后门, 逆向工具