siddhant3-cpu/CyberGuardian-AI
GitHub: siddhant3-cpu/CyberGuardian-AI
一款基于 AI 的浏览器安全分析与 Web 情报平台,通过 Chrome 扩展和 Web 仪表盘对网站进行实时的安全配置审计、风险评分和历史趋势追踪。
Stars: 0 | Forks: 0
# 🛡️ CyberGuardian AI
### 基于 AI 的浏览器安全分析与 Web 情报平台
[](LICENSE)
[](backend/)
[](backend/)
[](frontend/)
[](extension/)
[](Dockerfile)
## 📖 项目描述
## 📽️ 演示
### Chrome 扩展弹窗
*重新设计的浏览器扩展弹窗会在加载时对当前活动标签页执行即时的被动安全审计,并呈现动态评分和详细的安全检查清单:*
```
┌──────────────────────────────────────┐
│ 🛡️ CyberGuardian AI │
├──────────────────────────────────────┤
│ Host: github.com │
│ Security Level: Secure [ 90/100] │
├──────────────────────────────────────┤
│ Security Checklist: │
│ ✓ HTTPS Protocol: available │
│ ✓ SSL Certificate: valid │
│ ✓ HSTS: available │
│ ✓ CSP: strong │
│ ✓ X-Frame-Options: available │
│ ✓ X-Content-Type-Options: available │
│ ✓ Mixed Content: clear │
│ ✗ Security.txt: missing │
└──────────────────────────────────────┘
```
## ✨ 功能
- [x] **实时网站安全评分**:根据配置姿态进行动态计算。
- [x] **主动 SSL/TLS 证书分析**:验证证书过期时间和签名路径有效性。
- [x] **HTTP 安全标头审计**:评估 Strict-Transport-Security (HSTS)、Content-Security-Policy (CSP)、点击劫持防护 (X-Frame-Options) 以及 MIME 嗅探预防 (X-Content-Type-Options)。
- [x] **HTML 混合内容扫描**:分析网页中通过 HTTPS 加载的不安全 `http://` 元素。
- [x] **安全联系方式发现**:检查是否存在有效的 `/security.txt` 和 `/.well-known/security.txt` 配置。
- [x] **服务器端请求伪造 (SSRF) 防护**:拦截恶意的内部、私有或环回网络地址扫描。
- [x] **API 速率限制**:基于内存的 IP token 限制器,保护 `/analysis` endpoint 免遭滥用。
- [x] **交互式 Web 仪表盘**:精美的 React 分析图表、评分趋势、扫描历史记录以及报告导出。
- [x] **结构化报告导出**:将安全历史记录下载为格式化的 CSV 和 JSON 文件。
## 🏗️ 架构
```
graph TD
A[Chrome Extension popup.js] -->|POST /analysis| B[FastAPI Backend app.main]
C[React Frontend Dashboard] -->|REST API Requests| B
B -->|SSRF Validation| D[DNS & Socket IP Resolver]
B -->|Active Connection Scans| E[Target Public Server]
B -->|Local Analytics Engines| F[In-Memory/Local Storage]
B -->|Report Generators| G[CSV/JSON Exports]
subgraph Docker Hardening
B
end
```
## 📂 文件夹结构
```
CyberGuardian-AI/
├── extension/ # Manifest V3 Browser Extension Popup
│ ├── manifest.json # Extension permissions and configurations
│ ├── popup.html # Pop-up layout and stylesheet UI
│ ├── popup.js # Automated tab scanning logic
│ ├── settings.html # Backend API destination config UI
│ └── settings.js # Sync local storage configuration logic
├── frontend/ # Vite + React Web Application Dashboard
│ ├── src/
│ │ ├── App.jsx # Dashboard layout components & charts
│ │ ├── analysis.js # Local client analysis fallbacks
│ │ ├── securityChecks.js # Checklist state logic
│ │ ├── styles.css # Dark futuristic design systems
│ │ └── main.jsx
│ ├── package.json
│ └── vite.config.js
├── backend/ # FastAPI Backend Service
│ ├── app/
│ │ ├── main.py # API routing, rate limiting, and secure headers
│ │ ├── services.py # Active scanner, SSL verifier, and SSRF validator
│ │ ├── security_checks.py # Checklist structure dictionary
│ │ ├── analytics.py # History statistics processor
│ │ ├── healthcheck.py # Backend service health statuses
│ │ ├── history.py # Local JSON history storage
│ │ ├── reports.py # CSV and JSON report builders
│ │ └── schemas.py # Pydantic schemas
│ ├── requirements.txt # Backend project dependencies
│ └── tests/ # Tests suite
├── Dockerfile # Hardened non-root Python runtime deployment configuration
├── docker-compose.yml # Compose file orchestrating container services
└── README.md # Documentation
```
## 🛠️ 技术栈
### 后端
* **FastAPI**:现代的高性能 Web 框架。
* **Uvicorn**:轻量级 ASGI Web 服务器。
* **Python 标准库**:使用 `ssl` 进行 TLS 验证,`socket` 和 `ipaddress` 进行 SSRF 防护,`urllib` 进行扫描。
### 前端
* **React**:交互式组件 UI。
* **Vite**:高速构建工具链。
* **原生 CSS**:简洁、定制的暗色模式系统样式表。
### 浏览器扩展
* **Manifest V3**:现代 Google Chrome 扩展标准。
* **Chrome Storage API**:同步设置配置。
* **Chrome Tabs API**:动态解析活动的浏览器 URL。
### 部署与加固
* **Docker**:安全的容器化。
* **非 Root 用户执行**:在非特权用户 (`appuser:appgroup`) 下运行。
* **安全的 HTTP 标头**:已实现 `X-Frame-Options`、`X-Content-Type-Options` 和 `Content-Security-Policy`。
## 🚀 安装与设置
### 1. 克隆仓库
```
git clone https://github.com/siddhant3-cpu/CyberGuardian-AI.git
cd CyberGuardian-AI
```
### 2. 后端设置
请确保您已安装 Python 3.12+。
```
cd backend
# 创建虚拟环境
python -m venv .venv
# 激活虚拟环境 (Windows)
.venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
# 运行服务器
python -m uvicorn app.main:app --port 8000 --reload
```
### 3. 前端设置
请确保您已安装 Node.js。
```
cd ../frontend
npm install
npm run dev
```
React 仪表盘将在本地 [http://localhost:5173/](http://localhost:5173/) 运行。
### 4. 加载 Chrome 扩展
1. 打开 Google Chrome 并访问 `chrome://extensions/`。
2. 在右上角开启 **开发者模式**。
3. 点击左上角的 **加载已解压的扩展程序**。
4. 选择仓库根目录下的 `extension/` 文件夹。
## ⚙️ 配置
FastAPI 服务器使用标准的环境变量:
```
# 可选:允许的 CORS origins(以逗号分隔的列表,例如 "http://localhost:5173,http://127.0.0.1:5173")
ALLOWED_ORIGINS="*"
# 可选:Host port 设置
PORT=8000
```
## 🧭 使用工作流
```
Open Chrome Browser
↓
Install CyberGuardian Extension
↓
Navigate to a website (e.g. github.com)
↓
Click Extension Icon in Toolbar
↓
Live scan executes immediately (Score + Warnings render)
↓
Open Web Dashboard (http://localhost:5173)
↓
Analyze trends, scan history, and export PDF/CSV/JSON reports
```
## 🔌 API 文档
| Endpoint | Method | 描述 |
| :--- | :--- | :--- |
| `/health` | `GET` | 应用程序组件的轻量级状态检查。 |
| `/system-status` | `GET` | 报告微服务检查状态以供前端展示。 |
| `/analysis` | `POST` | 执行真实的 SSL 验证、标头分析、SSRF 评估和混合内容扫描。 |
| `/history` | `GET` | 返回最近扫描结果的列表。 |
| `/analytics` | `GET` | 汇总评分统计(扫描次数、平均值、最高分、最低分)。 |
| `/trends` | `GET` | 返回扫描事件之间的方向和变化点差异。 |
| `/security-checks` | `GET` | 返回检查清单格式的元数据。 |
| `/reports/csv` | `GET` | 将分析列表导出为符合 RFC 标准的 CSV 报告。 |
| `/reports/json` | `GET` | 将分析列表导出为结构化的 JSON 元数据。 |
## 🛡️ 安全检查明细
- **HTTPS 协议**:检查目标是否通过安全连接提供服务。
- **SSL 证书**:验证过期时间、签名、CA 链,并标记自签名证书。
- **Strict-Transport-Security (HSTS)**:审计服务器强制执行 HTTPS 的策略。
- **Content-Security-Policy (CSP)**:检测策略是否存在,并警告其是否允许不安全的选项(如 `'unsafe-inline'`)。
- **X-Frame-Options**:检查点击劫持框架防护。
- **X-Content-Type-Options**:确保浏览器的 MIME 嗅探防护处于激活状态。
- **混合内容扫描**:检查 HTML 页面主体元素,验证是否存在通过 HTTP 加载的不安全元素。
- **Security.txt**:验证站点在标准路径下是否公开了安全联系方式文件。
## 🗺️ 项目路线图
- [x] **v0.1**:初始的浏览器扩展结构和弹窗外壳。
- [x] **v0.2**:取代静态模拟指标的真实扫描后端。
- [x] **v0.3**:防御内部 SSRF 的 IP 验证规则。
- [x] **v0.4**:生产环境加固(安全标头、速率限制、非 Root Docker 运行时)。
- [x] **v0.5**:升级的仪表盘统计数据、检查清单视觉徽章以及自动化扩展扫描。
- [ ] **v1.0**:关系型数据库支持、威胁情报集成以及计划扫描任务。
## 🔮 未来改进
* 增加对 **Mozilla Firefox** 和 **Safari** 扩展打包的支持。
* 集成 **威胁情报 API**(如 VirusTotal、AbuseIPDB)以检查域名信誉。
* 实施持久化的 **PostgreSQL 数据库**,用于多用户分析跟踪。
* 配置 **计划扫描**,以定期审计关键业务资产。
* 集成 **基于 AI 的安全建议**,向非技术用户解释漏洞。
## 📄 许可证
基于 **MIT License** 分发。详情请参阅 `LICENSE`。
## ✉️ 联系方式与链接
- **GitHub**: [siddhant3-cpu](https://github.com/siddhant3-cpu)
- **LinkedIn**: [Siddhant Chauhan](https://www.linkedin.com/in/siddhant-chauhan)
## 🎓 鸣谢
* **OWASP Secure Headers Project** 提供的安全指南。
* **Mozilla Observatory** 提供的安全评分灵感。
* **FastAPI & React 社区** 提供的框架文档。
标签:AV绕过, FastAPI, Go语言工具, Python, React, Syscalls, Web安全, 威胁情报, 开发者工具, 无后门, 浏览器扩展, 蓝队分析, 请求拦截, 逆向工具