sarveshrp28-wq/SentinelAI.2o

GitHub: sarveshrp28-wq/SentinelAI.2o

一个基于 Python 的开源网络安全威胁检测平台,通过确定性规则引擎分析 URL、邮件、二维码和网站安全性并生成可解释的威胁情报报告。

Stars: 0 | Forks: 0

# SentinelAI (Python 版) 一个完全免费、开源、仅基于 Python 的钓鱼与威胁检测平台。 无需付费 API,无需外部服务——一切均运行在 确定性规则引擎以及 Python 标准库 / 免费包之上。 ## 功能 1. **AI 安全 Copilot** — 解释 URL、电子邮件/消息或 QR 码*为何*存在风险,并提供风险评分和置信度评分 (`modules/ai_copilot.py`)。 2. **AI 事件报告生成器** — 每次扫描后自动生成专业的 PDF (`modules/report_generator.py`,通过 `reportlab`)。 3. **QR 码钓鱼检测** — 解码 QR 图像 (`pyzbar`) 并 使用相同的规则引擎分析任何嵌入的 URL。 4. **网站安全分析器** — SSL 证书检查、安全 标头审计、域名信誉启发式分析、综合安全评分。 5. **密码强度分析器** — 基于熵的强度评分 + 加密安全的密码生成器 (`secrets` 标准库)。 密码永远不会被存储或记录。 6. **仪表板** — 扫描历史记录、威胁统计信息和图表 (前端使用 Chart.js,数据由 SQLite 提供)。 7. **现代暗色模式 UI** — 响应式、侧边栏导航,无需 外部 UI 框架。 ## 技术栈 - **后端:** Flask - **数据库:** SQLite (标准库 `sqlite3`,零设置) - **PDF 报告:** reportlab - **QR 解码:** pyzbar + Pillow - **图表:** Chart.js (CDN,免费) - **所有检测逻辑:** 基于规则的、确定性的 Python — 无需付费的 AI API ## 项目结构 ``` SentinelAI/ ├── app.py # Flask app factory / entrypoint ├── config.py # Central configuration ├── database.py # SQLite data layer ├── modules/ │ ├── url_analyzer.py # URL & email/message rule engine │ ├── ai_copilot.py # Natural-language explanation layer │ ├── qr_analyzer.py # QR code decoding + analysis │ ├── website_analyzer.py # SSL / headers / reputation / score │ ├── password_analyzer.py # Strength scoring + secure generator │ └── report_generator.py # PDF incident reports (reportlab) ├── routes/ │ ├── main.py # Page routes │ ├── scan.py # Scan API endpoints │ └── dashboard.py # Dashboard API endpoints ├── templates/ # Jinja2 HTML (dark cybersecurity theme) ├── static/ # CSS/JS ├── data/ # SQLite DB file (created automatically) ├── reports/ # Generated PDF reports ├── requirements.txt ├── vercel.json # Vercel serverless config └── Procfile # Heroku/Render style deployment ``` ## 本地设置 ``` python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt ``` **QR 码解码还需要系统级的 `zbar` 库**(pyzbar 是它的一个 Python 封装): - Debian/Ubuntu: `sudo apt-get install libzbar0` - macOS: `brew install zbar` - Windows: zbar DLL 已经包含在 `pyzbar` wheel 中。 运行应用: ``` python app.py # → http://localhost:5000 ``` ## 项目报告 此仓库包含两个 PDF 生成器,用于生成学术或可直接提交的文档: ``` python generate_synopsis.py # 生成 Synopsis_SentinelAI.pdf python generate_project_documentation.py # 生成 SentinelAI_Project_Documentation.pdf ``` 两个脚本均使用 ReportLab 创建可直接提交的项目摘要和完整文档报告。 ## 部署 ### Vercel `vercel.json` 已经为 Python serverless runtime 配置完毕。 只需运行 `vercel deploy`。注意:Vercel 的文件系统是只读的,除了 `/tmp`,因此 SQLite 数据库和生成的文件将存放在那里的 `/tmp` 中 — 在免费层级中,历史记录不会在冷启动后保留。为了在生产环境中 保留持久化历史记录,请将 `DATABASE_PATH` 指向托管的 兼容 Postgres/SQLite 的服务(应用正常运行并非必需)。 ### 任何 Python 主机 (Render, Railway, Heroku, VPS) 使用包含的 `Procfile`: ``` gunicorn app:app ``` ## API Endpoint | 方法 | Endpoint | 用途 | |---|---|---| | POST | `/api/scan/url` | 扫描 URL | | POST | `/api/scan/message` | 扫描电子邮件/消息文本 | | POST | `/api/scan/qr` | 扫描上传的 QR 图像 | | POST | `/api/scan/website` | 完整的网站安全分析 | | POST | `/api/scan/password` | 密码强度检查 | | GET | `/api/scan/password/generate` | 生成安全密码 | | GET | `/api/scan/report/` | 下载扫描的 PDF 报告 | | GET | `/api/dashboard/stats` | 用于图表的汇总统计信息 | | GET | `/api/dashboard/history` | 最近的扫描历史记录 | ## 安全说明 - 提交到 `/api/scan/password` 的密码仅在内存中进行分析 ,绝不会写入数据库或磁盘。 - 上传的 QR 图像在解码后会立即删除。 - 不使用或不需要任何第三方威胁情报或 AI API 密钥。
标签:Flask, Go语言工具, Python, 威胁情报, 开发者工具, 无后门, 网络安全, 逆向工具, 钓鱼检测, 隐私保护