mahirgul/ipscan-rust

GitHub: mahirgul/ipscan-rust

一款基于 Rust 和 Tokio 的高性能异步 IP 与端口扫描器,通过并发 TCP 检测和单套接字 UDP 探测实现快速网络发现与设备定位。

Stars: 0 | Forks: 0

# 🚀 ipscan [![GitHub Actions 构建状态](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/93012973b1195819.svg)](https://github.com/mahirgul/ipscan-rust/actions/workflows/release.yml) [![Crates.io 版本](https://img.shields.io/crates/v/ipscan?style=flat-square&color=orange)](https://crates.io/crates/ipscan) [![Crates.io 下载量](https://img.shields.io/crates/d/ipscan?style=flat-square&color=green)](https://crates.io/crates/ipscan) [![许可证](https://img.shields.io/crates/l/ipscan?style=flat-square&color=blue)](https://crates.io/crates/ipscan) [![平台](https://img.shields.io/badge/platform-windows%20%7C%20linux%20%7C%20macos-lightgray.svg?style=flat-square)](#) 一款使用 Rust 编写的高性能、异步 IP 和端口扫描器。旨在通过并发 TCP 检查、无冲突的单套接字 UDP 探测以及动态客户端 IP 注入,实现快速的网络发现。 ## ✨ 功能 - **⚡ 异步 TCP 扫描**:使用 Tokio 的工作窃取线程池进行高速、并发的三次握手检查。 - **📡 单套接字 UDP 扫描**:使用单个本地端口套接字并发探测数千个 UDP 目标,完全避免 `AddrInUse`(地址已被使用)冲突。 - **🏷️ 动态 IP 注入(NEC 模式)**:自动检测扫描机器的路由 IP,并将其动态修补到 UDP 数据包的负载中(解决设备发现时的目标路由问题)。 - **🔧 本地源端口绑定**:允许出站流量源自您选择的固定端口(例如 `-s 20111` 或 `-s 53` 用于 DNS 穿透)。 - **📥 自定义 UDP 负载**:发送任意十六进制编码的数据包以匹配自定义服务。 - **⏹️ 优雅的中断处理**:按下 `Ctrl+C` 可立即中断扫描,编译截至该时刻收集的结果,将其排序后写入输出文件,并干净地退出。 - **🎯 灵活的目标解析**:支持单个 IP、数字范围 (`192.168.1.1-100`)、CIDR 表示法 (`192.168.1.0/24`) 以及主机名/域名(例如 `localhost`、`example.com`)。 ## 📦 安装与设置 您可以直接从 **crates.io** 安装 `ipscan` 或从源码构建。 ### 选项 A:从 Crates.io 安装(推荐) ``` cargo install ipscan ``` ### 选项 B:从源码构建 ``` # Clone the repository git clone https://github.com/mahirgul/ipscan-rust.git cd ipscan-rust # Build optimized release binary cargo build --release ``` 编译后的二进制文件将放置在 `./target/release/ipscan`(或在 Windows 上为 `ipscan.exe`)。 ## 🛠️ 命令行界面 在不带参数的情况下运行二进制文件将回退到交互模式: ``` ipscan ``` ### 选项指南 | 标志 | 长标志 | 描述 | 默认值 | | :--- | :--- | :--- | :--- | | `-i` | `--ip` | 目标 IP、CIDR 块、范围或主机名(例如 `10.9.6.0/24`、`example.com`) | *如省略则提示输入* | | `-P` | `--protocol` | 要扫描的协议(`TCP` 或 `UDP`) | *如省略则提示输入* | | `-p` | `--port` | 目标端口号 (1-65535) | *如省略则提示输入* | | `-s` | `--source-port` | 出站本地源端口(0 表示由操作系统随机分配) | `0` | | `-t` | `--timeout` | 连接超时时间(毫秒) | `1000` | | `-c` | `--concurrency` | 最大同时连接数 / 数据包数 | `200` | | `-o` | `--output` | 用于保存活跃 IP 地址的输出文本文件路径 | `results.txt` | | `-d` | `--data` | 用于 UDP 扫描的自定义十六进制编码负载 | `""` | | | `--nec` | 启用带有动态本地 IP 注入的特殊 NEC UDP 负载 | `false` | ## 💡 实用示例 ### 1. NEC UDP 发现扫描 使用本地源端口 `20111` 和 2 秒超时扫描 C 类子网的 `3530` 端口: ``` ipscan -i 10.9.6.0/24 -P UDP -p 3530 -s 20111 --nec -t 2000 ``` *这将绑定到本地端口 `20111`,查询本地路由表,将您的主机 IP 动态注入到负载的最后 4 个字节中,将其发送到所有目标,并监听回复。* ### 2. 高速 TCP 端口扫描 以 `500` 的并发限制和快速的 `200ms` 超时扫描 IP 范围上的 `80` 端口: ``` ipscan -i 192.168.1.1-150 -P TCP -p 80 -c 500 -t 200 -o web_servers.txt ``` ### 3. 自定义 UDP 负载扫描 向端口 `5000` 发送自定义十六进制负载 (`AABBCCDD`): ``` ipscan -i 192.168.1.0/24 -P UDP -p 5000 -d "AA BB CC DD" ``` ### 4. 扫描域名/主机名 解析域名的 IP 地址并扫描端口 443: ``` ipscan -i example.com -P TCP -p 443 ``` ## 🤖 CI/CD 发布自动化 代码库在 `.github/workflows/release.yml` 中包含一个 GitHub Actions CI 工作流,用于为以下平台构建和打包二进制文件: - **Windows** (`x86_64-pc-windows-msvc`) - **Linux** (`x86_64-unknown-linux-gnu`) - **macOS** (`x86_64-apple-darwin` / Apple Silicon) ### 如何触发发布: 1. 标记您的提交:`git tag v1.0.0` 2. 推送标签:`git push origin v1.0.0` 3. GitHub Actions 将编译二进制文件,将其上传到新的 GitHub Release,并自动将更新的 crate 发布到 `crates.io`。(请确保您在代码库的 secrets 中配置了 `CRATES_IO_TOKEN`!)。
标签:Maven构建, Rust, TCP扫描, 云存储安全, 可视化界面, 插件系统, 数据统计, 端口扫描, 网络发现, 网络扫描, 网络流量审计, 通知系统