amithvarma703/Vapt-scanner
GitHub: amithvarma703/Vapt-scanner
一款基于 Python Flask 的轻量级 Web 漏洞扫描器,支持 XSS、SQL 注入、端口扫描等基础检测并生成 PDF 报告,适合安全入门学习和小规模资产自查。
Stars: 0 | Forks: 0
# 🔍 Web VAPT 扫描器与 PDF 报告生成器
一款使用 Python (Flask) 和原生 JavaScript 构建的适合初学者的 Web 漏洞评估工具。
## 📁 项目结构
```
vapt_scanner/
├── app.py ← Flask API server (2 endpoints)
├── scanner.py ← All vulnerability detection logic
├── report_generator.py ← PDF report builder (ReportLab)
├── index.html ← Frontend UI
├── requirements.txt ← Python dependencies
└── README.md
```
## ⚡ 快速开始
### 1. 安装依赖
```
pip install -r requirements.txt
```
### 2. 启动后端
```
python app.py
```
API 将在以下地址启动:`http://localhost:5000`
### 3. 打开前端
在浏览器中直接打开 `index.html` —— 前端**无需服务器**。
## 🔌 API 端点
### POST /scan
运行完整的漏洞扫描。
**请求:**
```
{ "url": "https://example.com" }
```
**响应 (JSON):**
```
{
"target_url": "https://example.com",
"scan_date": "2024-01-15 10:30:00",
"ip_info": { "ip": "93.184.216.34", "hostname": "example.com" },
"port_scan": { "open_ports": [...], "closed_ports": [...] },
"security_headers": { "missing_headers": {...}, "present_headers": {...} },
"xss_test": { "vulnerable": false, "vulnerabilities": [] },
"sqli_test": { "vulnerable": false, "vulnerabilities": [] },
"findings": [...],
"summary": { "total_findings": 3, "critical": 0, "high": 0, "medium": 1, "low": 2 }
}
```
### GET /generate-report
返回上次扫描的可下载 PDF 报告。
## 🔐 各项检查原理
### 1. IP 解析
使用 Python 的 `socket.gethostbyname()` 将域名解析为 IP。
告知您服务器的物理位置。
### 2. 端口扫描
使用 1 秒超时向每个常用端口打开 TCP socket。
`connect_ex()` 返回 0 = 开放,其他值 = 关闭。
危险端口:21 (FTP)、23 (Telnet)、3306 (MySQL) 等。
### 3. 安全头
发送 GET 请求并检查响应头。
检查项:CSP、X-Frame-Options、HSTS、X-XSS-Protection、Referrer-Policy、Permissions-Policy。
### 4. XSS (跨站脚本攻击)
向 URL 参数中注入 `` 及类似 payload。
如果 payload **原样**出现在 HTML 响应中 → 发现反射型 XSS。
### 5. SQL 注入
发送 SQL 元字符(`'`、`' OR 1=1--` 等)作为参数值。
在响应中搜索已知的数据库错误模式(MySQL、PostgreSQL、MSSQL、Oracle)。
## ⚠️ 严重程度等级
| 严重程度 | 示例 | 操作 |
|----------|----------|--------|
| **Critical** | SQL Injection | 立即修复 |
| **High** | XSS | 48 小时内修复 |
| **Medium** | 危险端口开放 | 1 周内修复 |
| **Low** | 缺失安全头 | 1 个月内修复 |
## ⚠️ 法律免责声明
**仅扫描您拥有或获得明确书面授权测试的系统。**
未经授权的扫描在大多数司法管辖区均属违法。
## 🛠️ 扩展扫描器
通过以下方式添加新检查:
1. 在 `scanner.py` 中编写新函数
2. 在 `run_full_scan()` 中调用它
3. 将结果添加到 `build_findings()`
可添加的检查示例:
- 目录遍历 (`../../etc/passwd`)
- 开放重定向
- 子域名枚举
- SSL/TLS 证书过期检查
- CORS 配置错误
标签:AES-256, CISA项目, DevSecOps, DOE合作, Flask, PDF, Python, VAPT, Web安全, Web应用防火墙辅助, XML 请求, XSS检测, 上游代理, 安全头分析, 安全开发, 对称加密, 开源安全工具, 数据可视化, 数据统计, 无后门, 漏洞评估, 白盒测试, 端口扫描, 网络安全, 自动化审计, 蓝队分析, 逆向工具, 逆向工程平台, 隐私保护