Rajasekharreddy-12/NETRA-webvuln-Scanner
GitHub: Rajasekharreddy-12/NETRA-webvuln-Scanner
NETRA 是一个基于 OWASP ZAP 引擎的全栈 Web 漏洞扫描平台,提供从自动化扫描、风险评分到报告导出的完整安全审计能力。
Stars: 0 | Forks: 0
# 🛡️ NETRA — 基于 AI 的 Web 漏洞扫描器
一个专业的全栈 Web 漏洞扫描平台,由 OWASP ZAP 驱动,配备现代化的 React 仪表板和 Python Flask 后端。
## ✨ 功能
- **自动化爬取** — ZAP Spider 可发现页面、表单和 endpoint
- **主动漏洞扫描** — 检测 SQLi、XSS、CSRF、Open Redirect 等
- **严重性分类** — 严重 / 高危 / 中危 / 低危 / 信息
- **风险评分** — 基于等级的风险评估(A–F)
- **实时进度** — 实时扫描进度仪表板
- **扫描历史** — 基于 MongoDB 的历史记录,包含完整详细信息
- **导出报告** — 下载 PDF、JSON 或 CSV 格式的报告
- **URL 验证** — 阻止对私有/本地网络的扫描
## 🏗️ 架构
```
User → React Dashboard (port 3000)
↓
Flask API (port 5000)
↓
OWASP ZAP Daemon (port 8080)
↓
MongoDB (port 27017)
```
## 📋 环境要求
| 工具 | 版本 | 用途 |
|------------|----------|------------------------|
| Python | 3.9+ | 后端 runtime |
| Node.js | 18+ | 前端 runtime |
| MongoDB | 6.0+ | 扫描数据存储 |
| OWASP ZAP | 2.14+ | 扫描引擎 |
## 🚀 快速开始(单条命令)
```
bash run.sh
```
此脚本会自动执行以下操作:
1. 启动 MongoDB
2. 启动 OWASP ZAP daemon
3. 安装并启动 Flask 后端
4. 安装并启动 React 前端
## 🔧 手动设置
### 1. 安装 OWASP ZAP
从此处下载:https://www.zaproxy.org/download/
**Linux/macOS:**
```
# 提取并运行
./zap.sh -daemon -port 8080 -config api.key=hho3e6g94etdom5dor855hf6fv
```
**Windows:**
```
zap.bat -daemon -port 8080 -config api.key=hho3e6g94etdom5dor855hf6fv
```
等待约 30 秒以便 ZAP 完全启动。
### 2. 启动 MongoDB
```
# 默认启动
mongod --dbpath ./data/db
```
### 3. 后端设置
```
cd backend
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python app.py
```
### 4. 前端设置
```
cd frontend
npm install
npm start
```
打开 **http://localhost:3000**
## ⚙️ 环境变量
在 `backend/` 目录下创建 `.env` 文件:
```
ZAP_HOST=http://localhost
ZAP_PORT=8080
ZAP_API_KEY=hho3e6g94etdom5dor855hf6fv
MONGO_URI=mongodb://localhost:27017/
MONGO_DB=netra_db
PORT=5000
FLASK_DEBUG=false
SPIDER_TIMEOUT=180
ACTIVE_SCAN_TIMEOUT=600
```
## 📡 API 参考
### 启动扫描
```
POST /api/scan
Content-Type: application/json
{ "url": "https://example.com" }
```
**响应:**
```
{
"scan_id": "65a1b2c3d4e5f6a7b8c9d0e1",
"message": "Scan started.",
"target_url": "https://example.com"
}
```
### 获取扫描状态
```
GET /api/scan/{id}
```
**响应:**
```
{
"id": "65a1b2c3d4e5f6a7b8c9d0e1",
"target_url": "https://example.com",
"status": "completed",
"progress": 100,
"phase": "completed",
"risk": {
"grade": "B",
"raw_score": 18,
"counts": { "Critical": 0, "High": 1, "Medium": 2, "Low": 3, "Informational": 5 }
},
"vulnerabilities": [...],
"urls_found": 24,
"duration_secs": 187
}
```
### 获取扫描历史
```
GET /api/history?limit=50
```
### 删除扫描记录
```
DELETE /api/scan/{id}
```
### 下载报告
```
GET /api/scan/{id}/report/pdf
GET /api/scan/{id}/report/json
GET /api/scan/{id}/report/csv
```
### 健康检查
```
GET /api/health
```
## 🔒 安全说明
- **私有 IP 拦截** — 扫描器将拒绝扫描 `localhost`、`127.x.x.x`、`10.x.x.x`、`172.16.x.x`、`192.168.x.x`
- **速率限制** — 每个 IP 每分钟 60 次请求;每分钟 10 次扫描启动
- **输入验证** — 所有 URL 在扫描前均经过验证
- **仅供教育使用** — 仅扫描您拥有或获得明确测试权限的目标
## 📁 项目结构
```
NETRA/
├── backend/
│ ├── app.py # Flask API server
│ ├── scanner.py # Scan orchestration
│ ├── zap_client.py # OWASP ZAP REST client
│ ├── risk_calculator.py # Severity classification & scoring
│ ├── url_validator.py # URL validation & private IP blocking
│ ├── database.py # MongoDB CRUD operations
│ ├── report_generator.py # PDF/JSON/CSV report generation
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Navbar.jsx
│ │ │ ├── ScanForm.jsx
│ │ │ ├── VulnerabilityTable.jsx
│ │ │ └── SeverityChart.jsx
│ │ ├── pages/
│ │ │ ├── Dashboard.jsx
│ │ │ ├── ScanDetails.jsx
│ │ │ └── History.jsx
│ │ └── services/api.js
│ ├── package.json
│ └── tailwind.config.js
├── run.sh
└── README.md
```
## 🧪 演示目标(可安全扫描)
这些是用于测试的故意存在漏洞的应用程序:
- `https://testphp.vulnweb.com` — PHP 漏洞应用程序
- `https://demo.testfire.net` — IBM AltoroMutual 演示
- `http://juice-shop.herokuapp.com` — OWASP Juice Shop
## 🐛 故障排除
| 问题 | 解决方案 |
|-------|----------|
| ZAP 无法连接 | 确保 ZAP 正在运行:`curl http://localhost:8080` |
| MongoDB 连接失败 | 运行 `mongod --dbpath ./data/db` |
| 前端白屏 | 检查 `npm start` 输出;确保端口 3000 未被占用 |
| 扫描卡在 0% | 检查 ZAP API key 是否与环境变量 `ZAP_API_KEY` 匹配 |
| PDF 导出失败 | 运行 `pip install fpdf2` |
## 📄 许可证
仅供教育和网络安全研究目的使用。
标签:CTI, 逆向工具