pranav2885/website-vulnerability-scanner
GitHub: pranav2885/website-vulnerability-scanner
一款全栈 Web 漏洞扫描器,通过并行执行六种安全检测引擎对网站进行自动化风险评级的可视化工具。
Stars: 0 | Forks: 0
# VulnScan - 网站漏洞扫描器



## 📋 目录
- [功能](#features)
- [项目概述](#project-overview)
- [架构](#architecture)
- [技术栈](#tech-stack)
- [项目结构](#project-structure)
- [快速开始](#getting-started)
- [开发](#development)
- [部署](#deployment)
- [工作原理](#how-it-works)
## ✨ 功能
- **6 种安全扫描器**
- 🔐 SSL/TLS 证书分析
- 🛡️ 安全标头验证
- ✖️ XSS (跨站脚本攻击) 检测
- 💾 SQL 注入测试
- 🔗 开放重定向扫描
- 📁 暴露文件检测
- **实时扫描** - 立即执行扫描并获取实时进度更新
- **风险评分** - 自动风险评估(低/中/高/严重)
- **扫描历史** - 跟踪所有之前的扫描并重访过往报告
- **Firebase 身份验证** - 安全的用户账户和数据持久化
- **响应式仪表盘** - 美观、现代的 UI,支持暗黑模式
- **详细报告** - 全面的漏洞发现及修复指南
## 🏗️ 项目概述
VulnScan 是一个全栈漏洞扫描器,旨在帮助安全研究员、开发者和 DevOps 工程师识别并跟踪 Web 应用程序中的安全问题。
### 扫描流程
```
User Input (URL)
↓
Frontend Validation (SSRF Protection)
↓
Backend Receives Request
↓
Python Scanners Run in Parallel
├─ headerCheck.py
├─ sslCheck.py
├─ xssCheck.py
├─ sqlCheck.py
├─ redirectCheck.py
└─ exposedFilesCheck.py
↓
Risk Scoring Algorithm
↓
Firebase Firestore Storage
↓
Results Sent to Frontend
↓
Beautiful Report Display
```
## 🏛️ 架构
### 高层系统设计
```
┌─────────────────────┐
│ Web Browser │
│ (React + Vite) │
└──────────┬──────────┘
│ HTTPS
↓
┌─────────────────────┐
│ Vercel (Frontend) │
│ client/ folder │
└──────────┬──────────┘
│ API Calls
↓
┌─────────────────────┐
│ Railway/Production │
│ (Node.js + Python) │
│ server/ folder │
└──────────┬──────────┘
│
┌───┴────────────┐
↓ ↓
Python Firebase
Scanners Firestore
(Security) (Database)
```
### 数据流
1. **用户提交 URL** → 前端验证并发送至后端
2. **后端接收请求** → 验证 URL(拦截私有 IP/SSRF)
3. **Python 扫描器执行** → 并行运行安全检查
4. **聚合结果** → 风险评分算法计算严重程度
5. **存储到 Firebase** → 持久化扫描结果以用于历史记录跟踪
6. **发送至前端** → 在交互式报告中展示结果
## 🛠️ 技术栈
### 前端
- **React 19** - UI 框架
- **TypeScript** - 类型安全的代码
- **Vite** - 构建工具(极速)
- **Tailwind CSS** - 样式设计
- **Framer Motion** - 动画
- **Firebase SDK** - 身份验证与 Firestore
### 后端
- **Node.js 20+** - 运行时
- **Express.js** - Web 服务器
- **Python 3.9+** - 安全扫描器
- **Firebase Admin SDK** - 数据库与身份验证
- **Helmet.js** - 安全标头
### 部署
- **Vercel** - 前端托管
- **Railway** - 后端托管
- **Firebase** - 身份验证与数据库
- **GitHub** - 版本控制
## 📁 项目结构
```
website-vulnerability-scanner/
├── client/ # Frontend (React + TypeScript)
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ │ └── scanner/ # Scanner-specific components
│ │ ├── contexts/ # React contexts (Auth)
│ │ ├── lib/
│ │ │ ├── api-client.ts # Backend API calls
│ │ │ └── firebase.ts # Firebase config
│ │ ├── pages/ # Page components
│ │ ├── types/ # TypeScript type definitions
│ │ └── App.tsx # Root component
│ ├── .env.example # Environment template
│ └── package.json
│
├── server/ # Backend (Node.js + Python)
│ ├── services/
│ │ ├── scanner/ # Python security scanners
│ │ │ ├── headerCheck.py # HTTP header validation
│ │ │ ├── sslCheck.py # SSL/TLS analysis
│ │ │ ├── xssCheck.py # XSS vulnerability detection
│ │ │ ├── sqlCheck.py # SQL injection testing
│ │ │ ├── redirectCheck.py # Open redirect scanning
│ │ │ ├── exposedFilesCheck.py # Sensitive file discovery
│ │ │ └── common.py # Shared utilities
│ │ ├── riskScorer.js # Risk calculation algorithm
│ │ └── techStackDetection.js # (Optional) Tech detection
│ ├── controllers/
│ │ ├── scanController.js # Scan logic
│ │ └── historyController.js # History management
│ ├── routes/
│ │ ├── scan.js # /api/scan endpoints
│ │ └── history.js # /api/history endpoints
│ ├── middleware/
│ │ ├── rateLimiter.js # Rate limiting
│ │ └── validateUrl.js # URL validation & SSRF protection
│ ├── firebase.js # Firebase config
│ ├── server.js # Express server entry point
│ ├── .env.example # Environment template
│ └── package.json
│
├── vercel.json # Vercel deployment config
├── .gitignore # Git ignore rules
└── README.md # This file
```
## 🚀 快速开始
### 前置条件
- **Node.js** 20 或更高版本
- **Python** 3.9 或更高版本
- **npm** 或 **yarn**
- **Firebase 项目**(用于身份验证和数据库)
- **GitHub 账户**(用于 git)
### 1. 克隆仓库
```
git clone https://github.com/pranav2885/website-vulnerability-scanner.git
cd website-vulnerability-scanner
```
### 2. 前端设置
```
cd client
npm install
cp .env.example .env
```
使用您的 Firebase 凭据编辑 `client/.env`:
```
VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.firebasestorage.app
VITE_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
VITE_FIREBASE_APP_ID=your-app-id
VITE_FIREBASE_MEASUREMENT_ID=your-measurement-id
VITE_API_URL=http://localhost:5000/api
```
### 3. 后端设置
```
cd ../server
npm install
cp .env.example .env
```
编辑 `server/.env`:
```
PORT=5000
ALLOWED_ORIGIN=http://localhost:3000
GOOGLE_APPLICATION_CREDENTIALS=./serviceAccountKey.json
PYTHON_BIN=python
```
获取您的 Firebase 服务账号密钥:
1. 前往 [Firebase 控制台](https://console.firebase.google.com)
2. 项目设置 → 服务账号
3. 点击“生成新的私钥”
4. 保存为 `server/serviceAccountKey.json`
### 4. 安装 Python 依赖
```
# 安装系统依赖 (Windows/macOS/Linux)
pip install requests beautifulsoup4 cryptography
```
## 💻 开发
### 在开发模式下启动所有服务
**终端 1 - 前端:**
```
cd client
npm run dev
```
在 `http://localhost:3000` 打开
**终端 2 - 后端:**
```
cd server
npm run dev
```
在 `http://localhost:5000` 运行
### 可用命令
**前端:**
```
npm run dev # Start dev server with hot reload
npm run build # Production build
npm run typecheck # TypeScript validation
```
**后端:**
```
npm run dev # Start with file watching
npm start # Production start
npm test # Run tests
```
## 🌐 部署
### 将前端部署到 Vercel
1. **推送到 GitHub**
git add .
git commit -m "Your message"
git push
2. **连接到 Vercel**
- 前往 [vercel.com](https://vercel.com)
- 导入您的 GitHub 仓库
- 设置环境变量(参考 `client/.env`)
- 部署!
### 将后端部署到 Railway
1. 在 [railway.app](https://railway.app) **创建账户**
2. **部署**
railway login
railway init
railway up
3. 在 Railway 仪表盘中**设置环境变量**
- `PORT=5000`
- `ALLOWED_ORIGIN=your-vercel-url`
- `GOOGLE_APPLICATION_CREDENTIALS`(上传 serviceAccountKey.json)
4. 从 Railway **获取后端 URL** → 复制部署 URL
5. 在 Vercel 环境变量中使用后端 URL **更新前端**
## 🔍 工作原理
### 分步详解
#### 1. 用户发起扫描
```
Frontend (LandingPage)
↓
User enters URL (e.g., https://example.com)
↓
Frontend validates URL format
↓
ScanLoadingPage shows progress
↓
POST /api/scan { url: "https://example.com" }
```
#### 2. 后端验证
```
Backend (server.js)
↓
validateUrl middleware checks:
✓ URL format is valid
✓ Not a private IP (SSRF protection)
✓ Protocol is HTTP/HTTPS
↓
Request passes to scanController
```
#### 3. Python 扫描器执行
```
scanController.js
↓
Spawn 6 Python processes in parallel:
├─ python headerCheck.py https://example.com
├─ python sslCheck.py https://example.com
├─ python xssCheck.py https://example.com
├─ python sqlCheck.py https://example.com
├─ python redirectCheck.py https://example.com
└─ python exposedFilesCheck.py https://example.com
↓
Each scanner outputs JSON findings:
[
{
"category": "Security Headers",
"severity": "High",
"description": "Missing Content-Security-Policy",
"recommendation": "Add CSP header"
}
]
```
#### 4. 风险评分
```
riskScorer.js
↓
Count vulnerabilities by severity:
Critical = 40 points
High = 20 points
Medium = 10 points
Low = 5 points
↓
Total Score → Risk Level:
0-20 points → Low (Grade A)
20-40 points → Medium (Grade B)
40-60 points → High (Grade C)
60+ points → Critical (Grade F)
```
#### 5. 存储并展示结果
```
Firebase Firestore
↓
Save scan document:
{
id: "8r8rY4K6jbFspQ6qXDlt",
url: "https://example.com",
scannedAt: "2026-06-19T10:30:00Z",
riskScore: "High",
riskPoints: 45,
findings: [...],
metrics: { critical: 0, high: 2, medium: 4, low: 1 }
}
↓
Return to Frontend
↓
ScanResultsPage displays:
✓ Risk score & grade
✓ Vulnerability breakdown
✓ Detailed findings with recommendations
```
#### 6. 历史记录跟踪
```
User can later:
✓ View scan history (/api/history)
✓ Click to view previous reports
✓ Delete old scans (/api/history/:id DELETE)
✓ Track changes over time
```
## 🔐 安全特性
### SSRF 防护
后端验证 URL 以防止:
- 扫描私有 IP(10.0.0.0/8、192.168.0.0/16 等)
- Localhost 访问(127.0.0.1、localhost)
- 内部网络(172.16.0.0/12)
### 速率限制
- 每个 IP 每小时 5 次扫描
- 防止滥用和资源耗尽
### 身份验证
- 用于用户账户的 Firebase Auth
- API 调用时的 ID 令牌验证
- 安全的 Firestore 规则
## 📊 API 端点
### 扫描端点
```
POST /api/scan
Request: { url: "https://example.com" }
Response: { id, url, findings, riskScore, ... }
GET /api/scan/:id
Response: Complete scan report
```
### 历史记录端点
```
GET /api/history
Response: Array of previous scans
DELETE /api/history/:id
Removes a scan from history
```
### 健康检查
```
GET /api/health
Response: { status: "ok" }
```
## 🤝 贡献
欢迎贡献!请:
1. Fork 该仓库
2. 创建一个功能分支 (`git checkout -b feature/amazing-feature`)
3. 进行您的更改
4. 提交 (`git commit -m 'Add amazing feature'`)
5. 推送 (`git push origin feature/amazing-feature`)
6. 发起一个 Pull Request
## 📝 许可证
该项目基于 MIT 许可证授权 - 详情请参阅 LICENSE 文件。
## 🆘 支持与问题
- 在 [GitHub Issues](https://github.com/pranav2885/website-vulnerability-scanner/issues) 报告漏洞
- 请先查看现有文档
- 包含重现问题的步骤
## 🎯 未来增强
- [ ] Web 应用程序防火墙 (WAF) 规则测试
- [ ] 子域名枚举
- [ ] API 端点扫描
- [ ] 定时扫描
- [ ] Slack/电子邮件通知
- [ ] 导出报告(PDF, JSON)
- [ ] 团队协作功能
- [ ] 自定义扫描器插件
由 [Pranav Mudigonda](https://github.com/pranav2885) 用 ❤️ 制作
标签:CISA项目, GNU通用公共许可证, MITM代理, Node.js, Python, URL发现, 安全检测, 无后门, 网站漏洞扫描, 自动化攻击, 逆向工具