mdsalmantanveer/port-scanner-python
GitHub: mdsalmantanveer/port-scanner-python
一个轻量级、零依赖的 Python 多线程端口扫描工具,支持服务识别、Banner 抓取与结果导出,可快速探测目标的开放端口。
Stars: 0 | Forks: 0
# 端口扫描器
一个基于 Python 的快速高效端口扫描器,支持多线程和服务检测。
## 功能
- 扫描常见端口,如 `21`、`22`、`80`、`443` 和 `8080`
- 接受域名或 IP 地址
- 检测并显示目标 IP 地址
- 显示服务名称,如 `HTTP`、`SSH`、`FTP` 和 `DNS`
- 测量并显示总扫描时间
- 尝试对开放的服务进行基本的 banner grabbing
- 使用多线程以加快扫描速度
- 支持命令行使用,例如 `python port_scanner.py google.com --fast`
- 将扫描输出保存到 `scan_results.txt`
- 干净地处理无效目标
- 使用 socket timeout 以避免等待过长时间
## 环境要求
- Python 3
无需额外的 Python 包。
## 如何运行
在此文件夹中打开终端并运行:
```
python port_scanner.py
```
然后在提示时输入网站或 IP 地址:
```
Enter website or IP, e.g. google.com: google.com
```
您也可以直接从命令行传递目标:
```
python port_scanner.py google.com
```
快速扫描模式会检查数量较少的高价值端口列表:
```
python port_scanner.py google.com --fast
```
您还可以更改 timeout、线程数和输出文件:
```
python port_scanner.py google.com --timeout 2 --workers 30 --output scan_results.txt
```
输出示例:
```
Scanning google.com (142.250.190.14)
---------------------------------------------
Port 21 (FTP) is CLOSED
Port 22 (SSH) is CLOSED
Port 80 (HTTP) is OPEN
Server info: HTTP/1.1 301 Moved Permanently Location: http://www.google.com/
Port 443 (HTTPS) is OPEN
Server info: No banner received
Port 8080 (HTTP Alternate) is CLOSED
---------------------------------------------
Scan completed in 2.30 seconds
Results saved to scan_results.txt
```
## 扫描的常见端口
```
[21, 22, 23, 25, 53, 80, 110, 139, 143, 443, 445, 8080]
```
## 快速模式端口
当使用 `--fast` 时,扫描器会检查:
```
[21, 22, 25, 53, 80, 443, 8080]
```
## 保存的结果
每次扫描都会保存到:
```
scan_results.txt
```
要保存到不同的文件:
```
python port_scanner.py google.com --output my_scan.txt
```
## 服务名称
扫描器会在每个端口旁边显示常见的服务名称:
```
Port 80 (HTTP) is OPEN
Port 22 (SSH) is CLOSED
Port 443 (HTTPS) is OPEN
```
## 获取 Banner
当端口开放时,扫描器会尝试收集基本的服务信息:
```
Server info: SSH-2.0-OpenSSH_9.2
```
某些服务不会自动发送 banner,因此输出可能会显示:
```
Server info: No banner received
```
## 重要提示
仅扫描您拥有或已获授权测试的网站、服务器或网络。
标签:Banner Grabbing, IP扫描, Python, Qt框架, Socket编程, 开源安全项目, 插件系统, 攻击路径可视化, 数据统计, 无后门, 服务识别, 白帽子工具, 端口扫描, 系统独立性, 纯标准库, 网络安全, 逆向工具, 隐私保护, 黑客工具