dhruvshah-cyber/network-vulnerability-scanner
GitHub: dhruvshah-cyber/network-vulnerability-scanner
一款基于Python和nmap的轻量级网络漏洞扫描器,提供端口扫描、服务识别、漏洞标记和专业报告生成功能。
Stars: 0 | Forks: 0
# 网络漏洞扫描器





## 目录
- [功能特性](#features)
- [安装说明](#installation)
- [使用方法](#usage)
- [输出示例](#sample-output)
- [MITRE ATT&CK 映射](#mitre-attck-mapping)
- [展示技能](#skills-demonstrated)
- [免责声明](#disclaimer)
- [作者](#author)
## 功能特性
- **多线程端口扫描器** — 使用并发线程扫描常用端口 1-1024 以及 30 多个知名高位端口,提升扫描速度
- **服务检测** — 利用内置端口到服务的映射和 Banner 抓取技术,识别每个开放端口上运行的服务
- **版本指纹识别** — 通过 python-nmap 集成 nmap,检测精确的软件版本(Apache、OpenSSH、MySQL、nginx 等)
- **漏洞标记** — 自动标记危险、过时或配置错误的服务,包括 SMB、Telnet、FTP、Redis、MongoDB、RDP 等
- **操作系统检测** — 利用 nmap 的操作系统指纹识别引擎猜测目标操作系统
- **CIDR 范围支持** — 支持扫描整个子网(例如 `192.168.1.0/24`),自动进行主机扩展
- **彩色终端输出** — 使用 colorama 实现基于严重性级别的颜色编码(红色=严重,黄色=中等,青色=低)
- **报告生成器** — 将包含完整发现和建议的专业纯文本报告保存到 `reports/` 文件夹
- **MITRE ATT&CK 映射** — 每个标记的漏洞都包含其对应的 MITRE 技术 ID
## 安装说明
### 前置条件
- Python 3.8 或更高版本
- 系统中已安装 nmap(用于操作系统检测和版本指纹识别)
**安装 nmap:**
```
# Debian/Ubuntu
sudo apt-get install nmap
# macOS
brew install nmap
# Windows
# 从 https://nmap.org/download.html 下载
```
### 克隆仓库
```
git clone https://github.com/dhruvshah-cyber/network-vulnerability-scanner.git
cd network-vulnerability-scanner
```
### 安装 Python 依赖
```
pip install -r requirements.txt
```
## 使用方法
### 基础扫描
```
python scanner.py --target 192.168.1.1
```
### 扫描常用端口
```
python scanner.py --target 192.168.1.1 --ports common
```
### 扫描自定义端口范围
```
python scanner.py --target 192.168.1.1 --ports 1-1024
```
### 扫描指定端口
```
python scanner.py --target 10.0.0.5 --ports 22,80,443,3306,8080
```
### 扫描整个子网
```
python scanner.py --target 192.168.1.0/24 --ports common
```
### 保存报告到文件
```
python scanner.py --target 192.168.1.1 --output reports/my_scan.txt
```
### 使用所有选项的完整扫描
```
python scanner.py --target 192.168.1.1 --ports 1-65535 --threads 200 --timeout 0.5 --verbose --output reports/full_scan.txt
```
### 禁用 Nmap(更快,细节较少)
```
python scanner.py --target 192.168.1.1 --no-nmap
```
### 命令行参数
| 标志 | 描述 | 默认值 |
|------|-------------|---------|
| `--target` | 目标 IP、主机名或 CIDR 范围 | 必填 |
| `--ports` | 要扫描的端口:`common`、`1-1024`、`22,80,443` | `common` |
| `--output` | 保存报告的文件路径 | 自动生成 |
| `--threads` | 并发扫描线程数 | 100 |
| `--timeout` | TCP 连接超时时间(秒) | 1.0 |
| `--verbose` | 每发现一个开放端口即打印输出 | False |
| `--no-nmap` | 禁用 nmap 集成 | False |
## 输出示例
```
_ _ _ _ __ __ _
| \ | | ___| |___ _____ _ __| | __\ \ / / | |
| \| |/ _ \ __\ \ /\ / / _ \| '__| |/ / \ \ / / | |
| |\ | __/ |_ \ V V / (_) | | | < \ V / | |
|_| \_|\___|\__| \_/\_/ \___/|_| |_|\_\ \_/ |_|
Network Vulnerability Scanner v1.0 -- by Dhruv Shah
github.com/dhruvshah-cyber | For authorized use only
[*] Target : 192.168.1.1
[*] Ports : common
[*] Threads : 100
[*] Timeout : 1.0s
[*] Nmap : enabled (requires nmap)
[*] Report : reports/scan_192_168_1_1_20260321_143207.txt
[*] Resolved 1 host(s) to scan
============================================================
[*] Starting scan of 192.168.1.1
============================================================
[*] Scanning 192.168.1.1 -- 1054 ports (100 threads)
Progress: 1054/1054 (100%)
[+] Found 6 open port(s): [22, 80, 443, 445, 3306, 8080]
[*] Running nmap OS + version detection...
[+] OS Guess : Linux 4.15 - 5.6 (accuracy: 90%)
[*] Grabbing banners and detecting services...
======================================================================
NETWORK VULNERABILITY SCANNER -- SCAN REPORT
======================================================================
Date/Time : 2026-03-21 14:32:07
Tool : Network Vulnerability Scanner v1.0
Author : Dhruv Shah (github.com/dhruvshah-cyber)
Target(s) : 192.168.1.1
======================================================================
----------------------------------------------------------------------
HOST: 192.168.1.1
----------------------------------------------------------------------
OS Detection : Linux 4.15 - 5.6 (accuracy: 90%)
Open Ports : 6
PORT SCAN RESULTS:
PORT STATE SERVICE VERSION/BANNER
----------------------------------------------------------------
22 open SSH OpenSSH 7.9p1 Debian 10+deb10u2
80 open HTTP Apache httpd 2.4.38 (Debian)
443 open HTTPS Apache httpd 2.4.38 (Debian)
445 open SMB
3306 open MySQL MySQL 5.7.32-log
8080 open HTTP-Alt nginx/1.14.2
VULNERABILITY FINDINGS:
----------------------------------------------------------------
[CRITICAL] Port 445 (SMB)
SMB: EternalBlue (MS17-010), ransomware propagation vector
MITRE ATT&CK: T1021.002, T1210
[HIGH] Port 22 (SSH)
Old OpenSSH version (7.9p1) -- upgrade to 9.x
MITRE ATT&CK: T1210
[HIGH] Port 3306 (MySQL)
MySQL: database direct exposure, brute-force target
MITRE ATT&CK: T1190
[HIGH] Port 80 (HTTP)
Apache 2.4.38 -- ensure patched to latest
MITRE ATT&CK: T1190
[HIGH] Port 443 (HTTPS)
Apache 2.4.38 -- ensure patched to latest
MITRE ATT&CK: T1190
======================================================================
THREAT SUMMARY
======================================================================
CRITICAL : 1
HIGH : 4
MEDIUM : 0
LOW : 0
TOTAL : 5
RECOMMENDATIONS:
* Patch or disable CRITICAL/HIGH severity services immediately.
* Apply network segmentation for exposed database ports.
* Enforce firewall rules to restrict access to sensitive ports.
* Upgrade OpenSSH to latest version (9.x).
* Restrict MySQL (port 3306) to localhost or trusted IPs only.
======================================================================
END OF REPORT
======================================================================
[+] Report saved to: reports/scan_192_168_1_1_20260321_143207.txt
```
## MITRE ATT&CK 映射
此工具将发现的漏洞映射到 MITRE ATT&CK 框架,用于威胁情报和报告。
| 技术 ID | 技术名称 | 关联性 |
|-------------|----------------|-----------|
| **T1046** | 网络服务发现 | 核心端口扫描功能 |
| **T1595** | 主动扫描 | 对目标的主动 TCP 连接扫描 |
| **T1592** | 收集受害者主机信息 | 操作系统检测、服务指纹识别 |
| **T1021.001** | 远程服务:RDP | 检测暴露的 RDP(端口 3389) |
| **T1021.002** | 远程服务:SMB | 检测 SMB 暴露 + EternalBlue |
| **T1021.005** | 远程服务:VNC | 检测暴露的 VNC(端口 5900) |
| **T1078** | 有效账户 | 标记易受暴力破解攻击的服务 |
| **T1110** | 暴力破解 | FTP、SSH、RDP 暴力破解风险识别 |
| **T1190** | 利用面向公众的应用程序 | Web 服务器、数据库、暴露的 API |
| **T1210** | 利用远程服务 | SMB EternalBlue、旧版 SSH、WebLogic CVE |
| **T1040** | 网络嗅探 | SNMP 团体字符串暴露 |
| **T1602** | 来自配置存储库的数据 | SNMP MIB 数据泄露 |
## 展示技能
- **Python 3** — 面向对象设计、argparse CLI、concurrent.futures 线程处理
- **网络编程** — 原始 TCP 套接字连接、Banner 抓取、CIDR 扩展
- **安全工具集成** — python-nmap 库用于 nmap 自动化、操作系统检测
- **漏洞研究** — MITRE ATT&CK 框架映射、CVE 意识
- **软件工程** — 模块化架构、错误处理、跨平台支持
- **技术写作** — 专业报告生成、发现文档编写
- **网络安全概念** — 端口扫描、服务枚举、操作系统指纹识别、威胁建模
## 项目结构
```
network-vulnerability-scanner/
├── scanner.py # Main scanner tool (CLI entry point)
├── sample_reports/ # Example scan outputs
│ └── sample_report.txt # Sample scan of 192.168.1.1
├── requirements.txt # Python dependencies
├── .gitignore # Ignore sensitive reports and caches
└── README.md # Full project documentation
```
## 免责声明
## 作者
**Dhruv Shah**
- GitHub: [@dhruvshah-cyber](https://github.com/dhruvshah-cyber)
- 仓库:[network-vulnerability-scanner](https://github.com/dhruvshah-cyber/network-vulnerability-scanner)
*构建此项目作为展示网络安全评估技能的网络安全作品集项目。*
标签:Nmap, Python, Qt框架, 安全合规, 安全存储, 局域网扫描, 开源安全工具, 插件系统, 操作系统检测, 数据统计, 无后门, 无线安全, 服务器安全, 服务识别, 横幅抓取, 版本指纹, 白帽工具, 端口扫描, 网络代理, 网络安全, 网络安全审计, 虚拟驱动器, 逆向工具, 逆向工程平台, 隐私保护