ramonvermeulen/whosthere
GitHub: ramonvermeulen/whosthere
一款无需提权的局域网设备发现工具,通过 mDNS、SSDP 和 ARP 缓存技术,以交互式 TUI 或 API 方式快速识别网络中的设备及其厂商信息。
Stars: 2033 | Forks: 50
# Whosthere
[](https://goreportcard.com/report/github.com/ramonvermeulen/whosthere)
[](https://go.dev/doc/devel/release)
[](LICENSE)
[](https://github.com/ramonvermeulen/whosthere/releases)
[](https://github.com/ramonvermeulen/whosthere)
使用 Go 编写的带有交互式终端用户界面 (TUI) 的局域网发现工具。
以直观的方式发现、探索和了解你的局域网。
Whosthere 使用 [**mDNS**](https://en.wikipedia.org/wiki/Multicast_DNS) 和 [**SSDP**](https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol) 扫描器执行**非特权、并发扫描**。此外,它通过尝试 TCP/UDP 连接触发 ARP 解析来扫描本地子网,然后读取 [**ARP 缓存**](https://en.wikipedia.org/wiki/Address_Resolution_Protocol) 以识别局域网上的设备。
此技术无需提升权限即可填充 ARP 缓存。所有发现的设备都会通过 [**OUI**](https://standards-oui.ieee.org/) 查询来显示制造商信息(如果可用)。
Whosthere 提供了一种友好、直观的方式来回答每位网络管理员都会问的问题:“谁在我的网络上?”

## 功能特性
- **交互式 TUI:** 直观地导航和探索发现的设备。
- **快速并发:** 同时利用多种发现方法。
- **无需提升权限:** 完全在用户空间运行。
- **设备增强:** 使用 [**OUI**](https://standards-oui.ieee.org/) 查找显示设备制造商。
- **集成端口扫描器:** 可选的对已发现主机进行服务发现(请仅在获得许可的情况下扫描设备!)。
- **Daemon 模式与 HTTP API:** 在后台运行并与其他工具集成。
- **主题与配置:** 通过 YAML 配置个性化外观和行为。
## 安装
通过 [**Homebrew**](https://brew.sh/) 使用 `brew` 安装:
```
brew install whosthere
```
在 [**NixOS**](https://nixos.org/) 上使用 `nix` 安装:
```
nix profile install nixpkgs#whosthere
```
在 [**Arch Linux**](https://archlinux.org/) 上使用 `yay` 安装:
```
yay -S whosthere-bin
```
如果你的包管理器未列出,你可以随时使用 [**Go**](https://go.dev/) 安装:
```
go install github.com/ramonvermeulen/whosthere@latest
```
或者**从源码构建**:
```
git clone https://github.com/ramonvermeulen/whosthere.git
cd whosthere
make build
```
此外,你可以从 [**Releases 页面**](https://github.com/ramonvermeulen/whosthere/releases) 下载预编译的二进制文件。
## 用法
运行 TUI 进行交互式发现:
```
whosthere
```
作为 CLI 运行以进行单次扫描并输出结果:
```
whosthere scan -t 5
```
将结果输出到 JSON 文件:
```
whosthere scan -t 5 --json --pretty > devices.json
```
作为带 HTTP API 的 Daemon 运行:
```
whosthere daemon --port=8080
```
可以通过运行以下命令找到其他命令行选项:
```
whosthere --help
```
## 按键绑定 (TUI)
| 按键 | 动作 |
| ------------------ | ------------------------ |
| `/` | 开始正则搜索 |
| `k` | 向上 |
| `j` | 向下 |
| `g` | 跳转到顶部 |
| `G` | 跳转到底部 |
| `y` | 复制选中设备的 IP |
| `Y` | 复制选中设备的 MAC |
| `enter` | 显示设备详情 |
| `CTRL+t` | 切换主题选择器 |
| `CTRL+c`/`q` | 停止应用程序 |
| `ESC` | 清除搜索 / 返回 |
| `p` (详情视图) | 开始对设备进行端口扫描 |
| `tab` (模态视图) | 切换按钮选择 |
## 配置
Whosthere 支持多种配置方法,优先级(从高到低)如下:
1. **命令行标志** - 最高优先级。请参阅 `whosthere --help` 获取可用标志。
2. **环境变量** - 以 `WHOSTHERE__` 为前缀。请参阅 [**通过环境变量配置**](#configuration-via-environment-variables)。
3. **配置文件** - YAML 配置文件。请参阅 [**配置文件**](#configuration-file)。
4. **默认值** - 后备默认值。请参阅 [**config.go**](https://github.com/ramonvermeulen/whosthere/blob/main/internal/core/config/config.go) 中的 `DefaultConfig()`。
### 配置文件
Whosthere 按以下顺序查找配置文件,并使用找到的第一个:
1. 通过 `--config` 标志或 `WHOSTHERE_CONFIG` 环境变量指定的路径
2. `$XDG_CONFIG_HOME/whosthere/config.yaml`(如果设置了 `XDG_CONFIG_HOME`)
3. `~/.config/whosthere/config.yaml`(默认位置)
**配置示例:**
```
# 取消注释下一行以配置特定网络接口 - 如果未设置则使用 OS 默认值
# network_interface: eth0
# 运行发现扫描的频率
scan_interval: 20s
# 每次扫描的最大超时时间,建议小于扫描间隔
scan_timeout: 10s
scanners:
mdns:
enabled: true
ssdp:
enabled: true
arp:
enabled: true
sweeper:
enabled: true
interval: 5m
timeout: 20s
port_scanner:
timeout: 5s
# List of TCP ports to scan on discovered devices
tcp: [21, 22, 23, 25, 80, 110, 135, 139, 143, 389, 443, 445, 993, 995, 1433, 1521, 3306, 3389, 5432, 5900, 8080, 8443, 9000, 9090, 9200, 9300, 10000, 27017]
splash:
enabled: true
delay: 1s
theme:
# When disabled, the TUI will use the terminal it's default ANSI colors
# Also see the NO_COLOR environment variable to completely disable ANSI colors
enabled: true
# See the complete list of available themes at https://github.com/ramonvermeulen/whosthere/tree/main/internal/ui/theme/theme.go
# Set name to "custom" to use the custom colors below
# For any color that is not configured it will take the default theme value as fallback
name: default
# Disable ANSI colors completely, overrides theme.enabled
# Can also be set via NO_COLOR or WHOSTHERE__THEME__NO_COLOR environment variables
# no_color: false
# Custom theme colors (uncomment and set name: custom to use)
# primitive_background_color: "#000a1a"
# contrast_background_color: "#001a33"
# more_contrast_background_color: "#003366"
# border_color: "#0088ff"
# title_color: "#00ffff"
# graphics_color: "#00ffaa"
# primary_text_color: "#cceeff"
# secondary_text_color: "#6699ff"
# tertiary_text_color: "#ffaa00"
# inverse_text_color: "#000a1a"
# contrast_secondary_text_color: "#88ddff"
```
## 环境变量
### 通用环境变量
| 变量 | 描述 |
| ------------------ | -------------------------------------------------------------- |
| `WHOSTHERE_CONFIG` | 配置文件的路径,用于覆盖默认位置。 |
| `WHOSTHERE_LOG` | 设置日志级别(例如 `debug`, `info`, `warn`, `error`)。默认为 `info`。 |
| `NO_COLOR` | 在 TUI 中禁用 ANSI 颜色。 |
### 通过环境变量配置
YAML 配置中可用的任何配置选项,都可以通过使用 `WHOSTHERE__` 前缀(注意双下划线)的环境变量进行设置。嵌套的配置键由双下划线分隔,键不区分大小写。
示例:
- `WHOSTHERE__SPLASH__ENABLED=false` - 禁用启动画面,相当于 YAML 配置中的 `splash.enabled: false`
- `WHOSTHERE__SPLASH__DELAY=2s` - 将启动画面延迟设置为 2 秒,相当于 YAML 配置中的 `splash.delay: 2s`
- `WHOSTHERE__SCAN_INTERVAL=30s` - 将扫描间隔设置为 30 秒,相当于 YAML 配置中的 `scan_interval: 30s`
- `WHOSTHERE__SCANNERS__MDNS__ENABLED=false` - 禁用 mDNS 扫描器,相当于 YAML 配置中的 `scanners.mdns.enabled: false`
- `WHOSTHERE__PORT_SCANNER__TCP=80,443,8080` - 设置自定义 TCP 扫描端口,相当于 YAML 配置中的 `port_scanner.tcp: [80, 443, 8080]`
- `WHOSTHERE__THEME__NAME=cyberpunk` - 将主题设置为 cyberpunk,相当于 YAML 配置中的 `theme.name: cyberpunk`
## Daemon 模式 HTTP API
当 Whosthere 以 Daemon 模式运行时,它会暴露一个非常简单的 HTTP API,包含以下端点:
| Method | Endpoint | 描述 |
| ------ | -------------- | ---------------------------- |
| GET | `/devices` | 获取所有已发现设备的列表 |
| GET | `/device/{ip}` | 获取特定设备的详情 |
| GET | `/health` | 健康检查 |
## 主题
主题可以通过配置文件进行配置,也可以在运行时通过 `CTRL+t` 按键绑定进行配置。
可用主题的完整列表可以在 [**这里**](https://github.com/ramonvermeulen/whosthere/blob/main/internal/ui/theme/theme.go) 找到,欢迎提交 PR 来添加你自己的主题!
主题配置示例:
```
theme:
enabled: true
name: cyberpunk
```
当 `name` 设置为 `custom` 时,其他颜色选项可用于创建你自己的自定义主题。
当 `enabled` 选项设置为 `false` 时,TUI 将使用终端的默认 ANSI 颜色。
当设置了 `NO_COLOR` 环境变量时,所有 ANSI 颜色将被禁用。
## 日志
日志写入应用程序的状态目录:
- `$XDG_STATE_HOME/whosthere/app.log`(如果设置了 `XDG_STATE_HOME`)
- `~/.local/state/whosthere/app.log`(Linux/MacOS 后备)
- `%LOCALAPPDATA%/whosthere/app.log`(Windows 后备)
当不在 TUI 模式下运行时,日志也会写入控制台。
## 平台
Whosthere 支持以下平台:
- [x] Linux
- [x] macOS
- [x] Windows
## 已知问题
为了使剪贴板功能正常工作,使用了一个 [**go-clipboard 的 fork**](https://github.com/dece2183/go-clipboard)。
请确保你的操作系统安装了相应的复制工具:
| 操作系统 | 支持的复制工具 |
| -------------------------------------- | ------------------------------------------- |
| Darwin | `pbcopy` |
| Windows | `clip.exe` |
| Linux/FreeBSD/NetBSD/OpenBSD/Dragonfly | X11: `xsel`, `xclip`
Wayland: `wl-copy` | ## 免责声明 Whosthere 旨在用于你有权执行网络发现和扫描的网络,例如你自己的家庭网络。未经授权扫描网络可能是非法和不道德的。 在任何网络上使用此工具之前,请务必获得适当的授权。 该工具主要是为了教育目的和家庭网络探索而创建的。虽然功能完备且有用,但不应将其视为专业级的网络监控解决方案。结果基于非特权扫描技术,可能并不全面。对于关键的网络分析或安全评估,请考虑使用具有正式支持的成熟专业工具。 ## 贡献 欢迎贡献和建议,例如功能请求、错误报告或改进! 欢迎在 GitHub 仓库提交 Issue 或 Pull Request。 请务必在实施任何重大更改之前在 Github issue 上进行讨论。
Wayland: `wl-copy` | ## 免责声明 Whosthere 旨在用于你有权执行网络发现和扫描的网络,例如你自己的家庭网络。未经授权扫描网络可能是非法和不道德的。 在任何网络上使用此工具之前,请务必获得适当的授权。 该工具主要是为了教育目的和家庭网络探索而创建的。虽然功能完备且有用,但不应将其视为专业级的网络监控解决方案。结果基于非特权扫描技术,可能并不全面。对于关键的网络分析或安全评估,请考虑使用具有正式支持的成熟专业工具。 ## 贡献 欢迎贡献和建议,例如功能请求、错误报告或改进! 欢迎在 GitHub 仓库提交 Issue 或 Pull Request。 请务必在实施任何重大更改之前在 Github issue 上进行讨论。
标签:ARP缓存, DNS枚举, EVTX分析, EVTX分析, Go语言, mDNS, OUI查询, Python脚本, SSDP, TUI, 占用监测, 后渗透, 子网扫描, 局域网发现, 并发扫描, 插件系统, 无需Root, 日志审计, 程序破解, 终端用户界面, 网络安全工具, 网络扫描工具, 设备识别, 资产管理