robgonnella/r-lanscan
GitHub: robgonnella/r-lanscan
基于 Rust 的局域网扫描工具套件,提供 CLI、交互式 TUI 和可复用库三种形态,支持 ARP 设备发现与 SYN 端口探测。
Stars: 22 | Forks: 0
[](https://deepwiki.com/robgonnella/r-lanscan)
# r-lanscan
[](https://github.com/robgonnella/r-lanscan/actions/workflows/test.yml)



一套用于局域网的综合网络扫描工具,使用 Rust 编写。这是 [go-lanscan](https://github.com/robgonnella/go-lanscan) 项目的现代 Rust 实现,提供了更高的性能、安全性和易用性。

## 功能特性
- 🔍 **ARP 扫描** - 发现网络中的活跃设备
- 🔌 **SYN 端口扫描** - 检测已发现设备上的开放端口和服务
- 🖥️ **终端 UI** - 用于网络管理和设备交互的交互式界面
- 📚 **库 Crate** - 用于构建自定义网络扫描应用程序
- 🚀 **高性能** - 优化的 Rust 实现,支持并发扫描
- 🛡️ **内存安全** - Rust 的安全保证可防止常见的网络错误
## 组件
r-lanscan 被组织为一个 Cargo workspace,包含三个主要组件:
### 📚 [r-lanlib](./lib/README.md) - 网络扫描库
核心库,提供用于构建自定义应用程序的网络扫描功能。
```
use r_lanlib::{network, packet, scanners::*};
// Discover devices on your network
let interface = network::get_default_interface()?;
let scanner = ARPScanner::builder()
.interface(&interface)
// ... configure options
.build()?;
let handle = scanner.scan()?;
```
**主要特性:**
- ARP 和 SYN 扫描实现
- 灵活的目标指定(IP、范围、CIDR 块)
- 通过 channel 获取实时结果
- 厂商查询和主机名解析
- 跨平台网络接口检测
### 🖥️ [r-lancli](./cli/README.md) - 命令行界面
一个强大的 CLI 工具,用于网络侦察和分析。
```
# 扫描整个本地网络
sudo r-lancli
# 使用自定义端口扫描特定目标
sudo r-lancli --targets 192.168.1.0/24 --ports 22,80,443,8080
# 将结果导出为 JSON
sudo r-lancli --json --quiet > scan_results.json
```
**主要特性:**
- 具有可自定义选项的综合网络扫描
- 易读的表格和 JSON 输出
- 灵活的目标和端口指定
- 厂商查询和主机名解析
- 对脚本和自动化友好的集成
### 🎮 [r-lanterm](./term/README.md) - 终端 UI 应用程序
一个交互式终端用户界面,用于网络管理和设备交互。
```
# 启动交互式终端 UI
sudo r-lanterm
# 自定义端口扫描
sudo r-lanterm --ports 22,80,443,3389,5900
```
**主要特性:**
- 具有实时更新的实时网络监控
- SSH 集成,可直接访问设备
- 内置 traceroute 和 Web 浏览 (lynx)
- 持久化配置管理
- 多种颜色主题和可自定义界面
- 特定设备和全局 SSH 配置
## 快速开始
### 安装
#### 预编译二进制文件
从 [GitHub Releases](https://github.com/robgonnella/r-lanscan/releases) 页面下载适合您平台的预编译二进制文件。
可用目标:
| 平台 | 目标 |
| ------------------- | ---------------------------- |
| Linux x86_64 | `x86_64-unknown-linux-musl` |
| Linux ARM64 | `aarch64-unknown-linux-musl` |
| macOS Apple Silicon | `aarch64-apple-darwin` |
```
# 示例:Linux x86_64
curl -L https://github.com/robgonnella/r-lanscan/releases/latest/download/r-lancli--x86_64-unknown-linux-musl.tgz \
| tar -xz
sudo mv target/x86_64-unknown-linux-musl/release/r-lancli /usr/local/bin/
```
#### cargo-binstall (推荐)
[cargo-binstall](https://github.com/cargo-bins/cargo-binstall) 会自动为您的平台下载正确的预编译二进制文件:
```
cargo binstall r-lancli
cargo binstall r-lanterm
```
#### cargo install (从源码构建)
```
cargo install r-lancli
cargo install r-lanterm
```
#### 从源码构建
```
# 克隆仓库
git clone https://github.com/robgonnella/r-lanscan
cd r-lanscan
# 构建所有组件
cargo build --release
# 或构建单个组件
cargo build --release -p r-lancli
cargo build --release -p r-lanterm
```
### 使用 Justfile
该项目包含一个用于常见开发任务的全面 Justfile:
```
# 安装 just 命令运行器
cargo install just
# 查看所有可用命令
just
# CLI 操作
just scan --help # Show CLI help
just scan # Quick network scan
just scan --targets 192.168.1.0/24 # Scan specific network
just scan --arp-only --vendor # ARP scan with vendor lookup
# 终端 UI 操作
just term # Launch interactive terminal UI
just term --ports 22,80,443 # Custom port scanning
just term --debug # Run in debug mode
# 开发与测试
just test # Run all tests
just test-report # Generate test coverage report
just lint # Run clippy linting
# Docker 操作
just up # Start development containers
just exec-workspace # Access container shell
just exec-workspace-term # Run terminal UI in container
just down # Stop containers
just logs # View container logs
```
### 基本用法示例
**快速网络扫描:**
```
sudo r-lancli --arp-only --vendor --host-names
```
**全面端口分析:**
```
sudo r-lancli --ports 1-1000 --json > network_audit.json
```
**交互式网络管理:**
```
sudo r-lanterm # Launch terminal UI for full interactive experience
```
## 系统要求
- **Rust 1.90.0+** (支持 Rust 2024 edition) - 通过 [rustup.rs] 安装
- **Root/管理员权限** - 原始套接字操作所需
- **可选外部工具** (用于终端 UI):
- `ssh` - 用于设备连接
- `traceroute` - 用于网络路径分析
- `lynx` - 用于终端 Web 浏览
## 文档
- 📖 **[库文档](./lib/README.md)** - r-lanlib 的 API 参考和示例
- 💻 **[CLI 文档](./cli/README.md)** - 完整的命令行参考和用法示例
- 🖥️ **[终端 UI 文档](./term/README.md)** - 交互式界面指南和键盘快捷键
## 使用场景
### 网络管理
- 发现网段上的所有设备
- 监控网络变化和新设备连接
- 审计基础设施中的开放端口和服务
- 快速 SSH 访问多台服务器和设备
### 安全分析
- 识别网络上的未授权设备
- 检测意外的开放端口和服务
- 映射网络拓扑和设备关系
- 监控网段的安全合规性
### 开发与测试
- 在开发过程中验证服务可用性
- 测试网络连接和防火墙规则
- 使用集成诊断工具调试网络问题
- 在 CI/CD 流水线中自动化网络发现
## 开发
### 从源码构建
```
# 开发构建
cargo build
# 带优化的发布构建
cargo build --release
# 运行测试
cargo test
# 运行并生成覆盖率报告
cargo llvm-cov
# Lint 代码
cargo clippy --all-targets --all-features
```
### Docker 开发环境
该项目包含用于开发和测试的 Docker 设置:
```
# 构建并启动开发容器
just up
# 访问工作区 shell
just exec-workspace
# 在容器中运行终端 UI
just exec-workspace-term
# 查看容器日志
just logs
# 停止容器
just down
```
**注意**:Docker 网络限制可能会影响扫描功能和性能。为了获得完整的功能和最佳性能,请在本机系统上原生运行。
### 项目结构
```
r-lanscan/
├── lib/ # Core scanning library (r-lanlib)
├── cli/ # Command-line interface (r-lancli)
├── term/ # Terminal UI application (r-lanterm)
└── Cargo.toml # Workspace configuration
```
## 安全与道德
⚠️ **重要提示:** 此工具专为合法的网络管理和安全分析而设计。在扫描网络之前,请务必确保您已获得适当的授权。
- 仅扫描您拥有或明确获得测试许可的网络
- 请注意,网络扫描可能会触发安全监控系统
- 某些司法管辖区有规范网络扫描活动的法律
- 请负责任地使用,并遵守您组织的安全策略
## 贡献
我们欢迎贡献!
文档即将推出...
## 许可证
该项目采用双重许可,您可以选择以下任一许可:
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) 或 http://www.apache.org/licenses/LICENSE-2.0)
- MIT License ([LICENSE-MIT](LICENSE-MIT) 或 http://opensource.org/licenses/MIT)
## 相关项目
- [go-lanscan](https://github.com/robgonnella/go-lanscan) - 原始 Go 实现
- [ops](https://github.com/robgonnella/ops) - 原始终端 UI 概念
- [nmap](https://nmap.org/) - 综合网络发现和安全审计
标签:ARP扫描, DNS枚举, GitHub, Rust, Rust库, SYN扫描, TUI, 云存储安全, 占用监测, 可视化界面, 域名解析, 密码管理, 局域网扫描, 并发扫描, 开源安全工具, 插件系统, 数据泄露防护, 数据统计, 文档结构分析, 端口扫描, 网络安全, 网络安全工具, 网络扫描, 网络探测, 网络流量审计, 设备发现, 资产管理, 逆向工程平台, 通知系统, 通知系统, 隐私保护