KrishSingh06/vuln-scanner
GitHub: KrishSingh06/vuln-scanner
一个基于 Python 的命令行 Web 应用漏洞扫描器,集成端口、SSL、安全标头、敏感路径和软件版本五项检测并自动生成风险报告。
Stars: 0 | Forks: 0
# VulnScan — 漏洞扫描器
一个基于 Python 的命令行工具,用于检测 Web 应用程序和网络中常见的安全漏洞。作为一个微型渗透测试项目构建。
## 目录
- [功能](#features)
- [项目结构](#project-structure)
- [安装](#installation)
- [使用方法](#usage)
- [示例输出](#sample-output)
- [示例报告](#sample-report)
- [检测内容](#what-it-detects)
- [使用技术](#technologies-used)
- [学习成果](#learning-outcomes)
- [免责声明](#disclaimer)
## 功能
- **端口扫描器** — 扫描 20 个常见端口,并标记危险端口(Telnet、RDP、Redis、MongoDB 等)
- **SSL/TLS 检查器** — 检测过期证书、即将过期的证书以及弱协议(TLS 1.0/1.1)
- **HTTP 安全标头** — 检查缺失的 HSTS、CSP、X-Frame-Options、cookie 标志以及信息泄露标头
- **敏感路径发现** — 探测 21 个路径,如 `.env`、`.git/config`、`phpMyAdmin`、SQL 转储文件、备份文件
- **软件版本检测** — 识别过时的 Apache、nginx、PHP、jQuery、WordPress 版本
- **漏洞报告** — 生成带有风险评分的报告,支持 `.txt` 和 `.json` 格式
## 项目结构
```
vuln-scanner/
├── scanner.py # Main scanner with all 5 modules
├── demo.py # Demo script (scans httpbin.org)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
```
## 安装
**第 1 步 — 克隆仓库**
```
git clone https://github.com/KrishSingh06/vuln-scanner.git
cd vuln-scanner
```
**第 2 步 — 安装依赖**
```
pip install -r requirements.txt
```
就这些。不需要其他设置。
## 使用方法
**基本扫描:**
```
python3 scanner.py --target example.com
```
**使用自定义报告文件扫描:**
```
python3 scanner.py --target https://example.com --output report.txt
```
**运行演示(扫描 httpbin.org):**
```
python3 demo.py
```
**参数:**
| 参数 | 简写 | 描述 |
|---|---|---|
| `--target` | `-t` | 目标主机名或 URL(必填) |
| `--output` | `-o` | 输出报告文件名(默认:vuln_report.txt) |
## 示例输出
运行扫描器时,您将在终端看到以下内容:
╦ ╦╦ ╦╦ ╔╗╔╔═╗╔═╗╔═╗╔╗╔
╚╗╔╝║ ║║ ║║║╚═╗║ ╠═╣║║║
╚╝ ╚═╝╩═╝╝╚╝╚═╝╚═╝╩ ╩╝╚╝
简单漏洞扫描器 v1.0
目标: https://httpbin.org
主机 : httpbin.org
[1/5] 端口扫描器
→ 正在扫描 httpbin.org 上的 20 个端口
✓ 端口 443/tcp 开放 (HTTPS)
✓ 端口 80/tcp 开放 (HTTP)
[2/5] SSL/TLS 配置
⚠ 证书将在 23 天后过期
✓ 协议: TLSv1.3
ℹ 密码套件: TLS_AES_256_GCM_SHA384
[3/5] HTTP 安全标头
ℹ 响应: HTTP 200
⚠ 缺失: Strict-Transport-Security
⚠ 缺失: X-Frame-Options
⚠ 缺失: Content-Security-Policy
⚠ 缺失: X-Content-Type-Options
⚠ 缺失: Referrer-Policy
⚠ 缺失: Permissions-Policy
[4/5] 敏感路径发现
→ 正在探测 21 个常见敏感路径...
⚠ 环境文件暴露 (.env)
⚠ Git 仓库暴露 (.git/config)
⚠ SQL 转储文件暴露 (/dump.sql)
[5/5] 软件版本检测
ℹ 检测到 Apache 2.4.51
✗ EOL 版本: PHP 7.2 (生命周期结束)
══════════════════════════════════════════════════
扫描完成
══════════════════════════════════════════════════
风险评分 : 100/100 [严重]
耗时 : 2.3秒
发现 : 5 严重 6 高危 9 中危 6 低危 2 信息
报告 : vuln_report.txt
JSON : vuln_report.json
══════════════════════════════════════════════════
```
---
## 示例 Report
The scanner generates a `vuln_report.txt` file automatically:
```
# =================================================================
VULNSCAN — 漏洞评估报告
## 目标 : https://httpbin.org
扫描日期: 2026-06-16 10:30:00
工具 : VulnScan v1.0
## 风险摘要
# 总体风险评分 : 100/100 [严重]
严重 : 5
高危 : 6
中危 : 9
低危 : 6
信息 : 2
总计 : 28 个发现
# 发现详情
[01] 环境文件暴露 (.env)
严重程度 : 严重
描述 : 路径 /.env 返回了 HTTP 403。
建议: 限制或移除对 /.env 的访问。
[02] Git 仓库暴露 (.git/config)
严重程度 : 严重
描述 : 路径 /.git/config 返回了 HTTP 403。
建议: 限制或移除对 /.git/config 的访问。
[03] SSL 证书即将过期
严重程度 : 高危
描述 : 证书将在 23 天后过期。
建议: 在证书过期前续订 SSL 证书。
[04] 缺失安全标头: Strict-Transport-Security
严重程度 : 中危
描述 : 未设置 HSTS。浏览器将不会强制使用 HTTPS。
建议: 添加 Strict-Transport-Security 标头。
# ... 以及另外 24 个发现
## 开放端口
```
443/tcp HTTPS
80/tcp HTTP
```
# =================================================================
报告结束
```
A `vuln_report.json` is also generated for programmatic use.
---
## 它检测什么
| Category | What is checked |
|---|---|
| **Open Ports** | FTP, SSH, Telnet, HTTP, HTTPS, MySQL, RDP, Redis, MongoDB, Elasticsearch and 10 more |
| **Dangerous Ports** | Telnet (23), FTP (21), RDP (3389), VNC (5900), Redis (6379), MongoDB (27017) |
| **SSL/TLS** | Expired certs, expiring soon (<30 days), weak protocols (TLS 1.0, 1.1) |
| **HTTP Headers** | HSTS, CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy |
| **Sensitive Paths** | .env, .git/config, phpMyAdmin, /actuator/env, backup.zip, dump.sql, /admin, error_log |
| **Outdated Software** | Apache, nginx, PHP, jQuery, WordPress, OpenSSL, Drupal, Express.js |
| **Cookies** | Missing Secure flag, missing HttpOnly flag |
| **Info Leaks** | Server, X-Powered-By, X-AspNet-Version headers |
---
## 使用的 Technologies
- **Python 3** — Core language
- **socket** — Raw TCP port scanning
- **ssl** — Certificate and protocol inspection
- **requests** — HTTP header and path analysis
- **threading / ThreadPoolExecutor** — Parallel scanning for speed
- **json** — Structured report output
- **re (regex)** — Software version detection from page source
---
## 学习成果
- Basics of penetration testing and vulnerability assessment
- Network programming using raw TCP sockets
- SSL/TLS certificate inspection in Python
- HTTP security header analysis
- Concurrent scanning using Python threads
- Risk scoring and report generation
---
## Disclaimer
This tool is built for **educational purposes only**.
Only scan systems you **own** or have **explicit written permission** to test.
Unauthorized scanning is **illegal** in most countries.
The author is not responsible for any misuse of this tool.
---
## 作者
**Krish Singh**
GitHub: [@KrishSingh06](https://github.com/KrishSingh06)
```
标签:Python, Web安全, 云存储安全, 加密, 实时处理, 密码管理, 插件系统, 无后门, 漏洞扫描器, 网络扫描, 蓝队分析, 逆向工具