PritiSikdar26/mini-web-vuln-scanner

GitHub: PritiSikdar26/mini-web-vuln-scanner

一款轻量级Python Web漏洞扫描器,支持SQL注入、XSS、安全头检测和目录爆破,适合安全学习与基础渗透测试。

Stars: 0 | Forks: 0

# 🛡 Mini Web 漏洞扫描器 [![Python](https://img.shields.io/badge/Python-3.8%2B-blue?style=flat-square&logo=python)](https://python.org) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE) [![Security Tool](https://img.shields.io/badge/Type-Security%20Tool-red?style=flat-square)](#) [![OWASP](https://img.shields.io/badge/OWASP-Top%2010-orange?style=flat-square)](https://owasp.org) ## ⚠️ 法律免责声明 ## 📋 功能特性 | 模块 | 功能描述 | OWASP 类别 | |---|---|---| | 🔍 **Header Scanner** | 检查缺失或配置错误的 HTTP 安全标头 | A05: Security Misconfiguration | | 📁 **Directory Bruteforce** | 发现隐藏文件、管理面板、备份路径 | A01: Broken Access Control | | 💉 **SQL Injection Tester** | 测试 URL 参数是否存在报错型与盲注 SQLi | A03: Injection | | ⚡ **XSS Tester** | 测试输入是否存在反射型 Cross-Site Scripting | A03: Injection | | 📊 **Report Generator** | 生成带有风险评分的 HTML + JSON 报告 | — | ## 🗂 项目结构 ``` mini-web-vuln-scanner/ │ ├── scanner.py ← Main CLI entry point │ ├── modules/ │ ├── __init__.py │ ├── header_scan.py ← Security header checker │ ├── dir_scan.py ← Multi-threaded directory bruteforcer │ ├── sqli_test.py ← SQL injection payload tester │ ├── xss_test.py ← XSS payload tester │ └── report_gen.py ← HTML/JSON report generator │ ├── wordlists/ │ └── directories.txt ← 100+ common paths/files to probe │ ├── reports/ ← Auto-generated scan reports land here ├── screenshots/ ← Demo screenshots │ ├── requirements.txt └── README.md ``` ## 🚀 快速开始 ### 1. 克隆仓库 ``` git clone https://github.com/yourusername/mini-web-vuln-scanner.git cd mini-web-vuln-scanner ``` ### 2. 安装依赖 ``` pip install -r requirements.txt ``` ### 3. 运行扫描 ``` # 对所有目标运行 ALL modules python scanner.py -u http://testphp.vulnweb.com --all # 运行特定 modules python scanner.py -u http://example.com --headers --sqli # 使用自定义 wordlist 进行目录 bruteforce python scanner.py -u http://example.com --dir --wordlist wordlists/directories.txt # Full options python scanner.py -u http://example.com --all --threads 20 --timeout 15 ``` ## 🖥 使用方法 & CLI 参考 ``` usage: scanner.py [-h] -u URL [--headers] [--dir] [--sqli] [--xss] [--all] [--wordlist WORDLIST] [--output OUTPUT] [--timeout TIMEOUT] [--threads THREADS] Mini Web Vulnerability Scanner — educational security testing tool required arguments: -u URL, --url URL Target URL (e.g. http://example.com) scanner modules: --headers Run Security Header Scanner --dir Run Directory Bruteforce Scanner --sqli Run SQL Injection Tester --xss Run XSS Payload Tester --all Run ALL scanner modules options: --wordlist WORDLIST Path to wordlist (default: wordlists/directories.txt) --output OUTPUT Custom report filename --timeout TIMEOUT HTTP timeout in seconds (default: 10) --threads THREADS Threads for directory scan (default: 10) ``` ## 📸 输出示例 ``` ███╗ ███╗██╗███╗ ██╗██╗ ██╗███████╗██████╗ ... Mini Web Vulnerability Scanner v1.0 For educational and authorized testing only [✔] Target : http://testphp.vulnweb.com [✔] Started : 2024-01-15 14:32:01 ────────────────────────────────────────────────────── ▶ Security Header Scanner ────────────────────────────────────────────────────── [✘] MISSING Content-Security-Policy Risk: HIGH [✘] MISSING Strict-Transport-Security Risk: HIGH [✔] PRESENT X-Content-Type-Options nosniff [!] INFO LEAK Server Apache/2.4.7 ────────────────────────────────────────────────────── ▶ SQL Injection Tester ────────────────────────────────────────────────────── [→] Testing parameter: 'id' [!] POSSIBLE SQLi! Param='id' → DB error: 'mysql_fetch' ``` ## 📊 HTML 报告示例 扫描器会在每次扫描后在 `reports/` 目录下自动生成一个颜色编码的 HTML 报告。报告内容包括: - **风险评分** (0–100) 以及 CRITICAL / HIGH / MEDIUM / LOW 分类 - 安全标头审计表 - 发现的目录表 - SQLi 和 XSS 发现结果 - 修复建议 ## 🧪 安全测试目标 **仅对您拥有或经授权测试的系统进行测试。以下是专为学习设计的合法练习目标:** | 目标 | URL | 备注 | |---|---|---| | DVWA | `http://localhost/dvwa` | 使用 Docker 在本地运行 | | Vulnweb | `http://testphp.vulnweb.com` | Acunetix 的测试站点 | | HackTheBox | `https://hackthebox.com` | 合法 CTF 环境 | | TryHackMe | `https://tryhackme.com` | 合法 CTF 环境 | | WebGoat | `http://localhost:8080/WebGoat` | OWASP 的培训应用 | ## 🏗 架构概览 ``` scanner.py (CLI Orchestrator) │ ├── SecurityHeaderScanner → requests → HTTP headers → compare vs allowlist ├── DirectoryScanner → Queue + ThreadPool → HTTP GET → status codes ├── SQLiTester → payload injection → error/time-based detection ├── XSSTester → payload injection → reflection detection └── ReportGenerator → aggregate results → HTML + JSON output ``` ## 🛠 技术栈 - **语言**: Python 3.8+ - **HTTP**: `requests` — 用于所有 Web 交互的 HTTP 客户端 - **解析**: `beautifulsoup4` — 用于表单发现的 HTML 解析 - **CLI 颜色**: `colorama` — 跨平台终端颜色支持 - **并发**: `threading` + `queue` — 多线程目录扫描 - **报告**: 纯 Python — HTML/JSON 报告生成 ## 🔒 各模块工作原理 ### Security Header Scanner 通过 GET 请求获取 HTTP 标头,并与 OWASP 安全标头项目定义的 8 个关键安全标头进行比对。报告缺失的标头及其风险等级(HIGH/MEDIUM/LOW),并检测 `Server` 和 `X-Powered-By` 等信息泄露标头。 ### Directory Bruteforce Scanner 加载字典,并使用线程安全的 `Queue` + 线程池并发探测每个路径。将状态码为 200、301、302、403、401 和 500 的响应标记为关注项。可通过 `--threads` 配置线程数。 ### SQL Injection Tester 提取 URL 查询参数(或通过 BeautifulSoup 发现表单输入)。对于每个参数,注入 10 多个基于错误的 payload,并根据 20 多种数据库错误签名检查响应体。同时通过测量响应延迟执行基于时间的盲注 SQLi 检测。 ### XSS Payload Tester 使用 12 个 XSS payload 测试 URL 参数和 HTML 表单字段,涵盖基本注入、事件处理器、属性转义和过滤器绕过。检查 payload 是否未转义地出现在响应 HTML 中(反射型 XSS 检测)。 ## 📈 路线图 / 未来功能 - [ ] 子域名枚举模块 - [ ] CSRF token 检测 - [ ] 开放重定向测试器 - [ ] 存储型 XSS 检测 - [ ] Cookie 安全分析器 (HttpOnly, Secure, SameSite) - [ ] SSL/TLS 证书检查器 - [ ] PDF 报告导出 - [ ] 速率限制 / 礼貌扫描延迟 ## 🤝 贡献 欢迎 Pull requests!请: 1. Fork 本仓库 2. 创建功能分支 (`git checkout -b feature/new-module`) 3. 添加测试或输出示例 4. 提交带有清晰描述的 PR ## 📄 许可证 MIT License — 详情见 [LICENSE](LICENSE)。 ## 👤 作者 **Priti Sikdar** - GitHub: [@PritiSikdar26](https://github.com/PritiSikdar26) - LinkedIn: [Priti Sikdar](https://www.linkedin.com/in/priti-sikdar-744399239/) *作为网络安全作品集项目的一部分,专为教育目的而构建。*
标签:AES-256, CISA项目, DOE合作, HTML报告生成, OWASP Top 10, Python, Splunk, SQL注入检测, Web安全, XSS检测, 加密, 安全头检测, 开源安全工具, 数据统计, 文件查看, 无后门, 漏洞扫描器, 漏洞评估, 白盒测试, 目录爆破, 端口扫描, 网络安全, 蓝队分析, 逆向工具, 逆向工程平台, 隐私保护