jmsperu/netscan

GitHub: jmsperu/netscan

一款快速跨平台的单一二进制网络扫描器,解决多场景下的主机发现、端口服务探测与设备监控问题。

Stars: 0 | Forks: 0

# netscan 快速跨平台网络扫描器。发现主机、扫描端口、识别服务并解析 MAC 厂商。单一二进制文件,无依赖。 适用于 **Windows**、**macOS** 和 **Linux**。 ## 功能 - **局域网发现** — 通过 ping 扫描查找网络中的所有设备 - **端口扫描** — 扫描特定端口、范围或全部 65535 个端口 - **服务检测** — 识别服务并抓取横幅 - **MAC 厂商查询** — 内置 OUI 数据库(500+ 厂商) - **ARP 表集成** — 读取系统 ARP 缓存获取 MAC 地址 - **主机名解析** — 反向 DNS 查找 - **监听模式** — 持续监控并提示新设备或消失设备 - **Wake-on-LAN** — 发送魔术包唤醒设备 - **mDNS/Bonjour 发现** — 通过服务发现 AppleTV、Chromecast、打印机、HomeKit 设备 - **SNMP v1/v2c/v3** — 查询交换机、路由器、打印机;遍历 OID;列出接口 - **IPv6 邻居发现** — 列出 NDP 缓存中的 IPv6 邻居 - **Prometheus 指标导出** — 在监听模式下导出扫描结果供 Grafana 使用 - **嵌入式 Web UI** — 干净的仪表盘,运行于 http://localhost:8080,无需单独安装 - **多种输出格式** — 表格、宽列、JSON、CSV ## netscan 的与众不同 | 功能 | nmap | Angry IP | Fing | netscan | |------|------|----------|------|---------| | 单一静态二进制文件(无依赖) | ❌ | ❌(JVM) | ❌ | ✅ | | 跨平台支持 | ✅ | ✅ | 部分 | ✅ | | 体积 | 20+ MB | 120 MB JVM | App bundle | **约 3.5 MB** | | 内置 mDNS 发现 | ❌ | ❌ | ✅(付费) | ✅ | | 内置 SNMP 遍历 | ❌ | ❌ | ❌ | ✅ | | Prometheus 导出 | ❌ | ❌ | ❌ | ✅ | | 内置 Web UI | ❌ | ✅(GUI) | ✅(应用) | ✅(嵌入式) | | Wake-on-LAN | ❌ | ❌ | ✅(付费) | ✅ | | JSON/CSV 输出 | 仅 XML | ✅ | ❌ | ✅ | | 可在任何机器上通过 curl 安装 | ❌ | ❌ | ❌ | ✅ | ## 安装 ### 一键安装(Mac 和 Linux) ``` curl -fsSL https://raw.githubusercontent.com/jmsperu/netscan/main/install.sh | sudo bash ``` 该脚本会自动检测操作系统和架构(amd64/arm64),从最新版本下载正确的二进制文件,并安装到 `/usr/local/bin/netscan`。 **安装指定版本:** ``` curl -fsSL https://raw.githubusercontent.com/jmsperu/netscan/main/install.sh | sudo bash -s -- --version v0.1.1 ``` **安装到自定义目录(无需 sudo):** ``` curl -fsSL https://raw.githubusercontent.com/jmsperu/netscan/main/install.sh | INSTALL_DIR=~/.local/bin bash ``` ### 手动下载 从 [Releases](https://github.com/jmsperu/netscan/releases) 获取对应二进制文件: | 平台 | 文件 | |------|------| | macOS(M 系列) | `netscan-darwin-arm64` | | macOS(Intel) | `netscan-darwin-amd64` | | Linux(x86_64) | `netscan-linux-amd64` | | Linux(ARM64) | `netscan-linux-arm64` | | Windows(x64) | `netscan-windows-amd64.exe` | | Windows(ARM64) | `netscan-windows-arm64.exe` | ``` # macOS M-series example sudo curl -L https://github.com/jmsperu/netscan/releases/latest/download/netscan-darwin-arm64 -o /usr/local/bin/netscan sudo chmod +x /usr/local/bin/netscan sudo xattr -d com.apple.quarantine /usr/local/bin/netscan # macOS Gatekeeper ``` ### Go 安装 ``` go install github.com/jmsperu/netscan@latest ``` ### 从源码构建 ``` git clone https://github.com/jmsperu/netscan.git cd netscan make build ``` 跨平台编译: ``` make build-all # outputs to dist/ ``` ## 快速开始 ``` netscan # scan current subnet (auto-detect) netscan 192.168.1.0/24 # scan a specific subnet ``` ## 用法 ### 默认扫描 ``` netscan # auto-detect subnet, scan common ports netscan 10.0.0.0/24 # scan specific subnet netscan -p 22,80,443 # scan specific ports netscan -p 1-1024 # scan port range netscan --all # scan all 65535 ports netscan --fast # ping sweep only (no port scan) ``` ### 输出格式 ``` netscan -o table # default table output netscan -o wide # wide table with all fields netscan -o json # JSON output netscan -o csv # CSV output ``` ### 深度端口扫描 ``` netscan ports 192.168.1.1 # scan common ports on a single host netscan ports 192.168.1.1 -p 1-65535 # scan all ports netscan ports 192.168.1.1 --all # same as above netscan ports 192.168.1.1 -t 1000 # 1000ms timeout netscan ports 192.168.1.1 -c 2000 # 2000 concurrent connections ``` ### 监听模式 ``` netscan watch # monitor current subnet (every 60s) netscan watch 192.168.1.0/24 # monitor specific subnet netscan watch -n 30 # scan every 30 seconds ``` ### Wake-on-LAN ``` netscan wake AA:BB:CC:DD:EE:FF # send magic packet netscan wake AA:BB:CC:DD:EE:FF -b 192.168.1.255 # specify broadcast address ``` ### mDNS / Bonjour 发现 ``` netscan mdns # browse common service types netscan mdns --timeout 10 # longer discovery window netscan mdns --service _googlecast._tcp # specific service ``` 可发现 AirPlay 扬声器、Chromecast、HomeKit 设备、网络打印机、SMB 共享等。 ### SNMP ``` netscan snmp 192.168.1.1 # quick summary (v2c, "public") netscan snmp 10.0.0.1 -c private # custom community netscan snmp 192.168.1.1 --interfaces # list interfaces netscan snmp 192.168.1.1 --walk 1.3.6.1.2.1.1 # walk a subtree netscan snmp 192.168.1.1 --oid 1.3.6.1.2.1.1.5.0 # single OID netscan snmp 10.0.0.1 -v 3 -u admin --authkey PASS --privkey PRIV # SNMPv3 ``` ### IPv6 邻居发现 ``` netscan ipv6 # list discovered IPv6 neighbors netscan ipv6 --reachable # only reachable neighbors netscan ipv6 --refresh -i en0 # send multicast ping to refresh cache ``` ### Prometheus 指标导出 导出扫描结果供 Prometheus 抓取(适用于监听模式 + Grafana): ``` netscan watch 10.0.0.0/24 --prometheus-port :9100 ``` 然后在 Prometheus 中配置: ``` scrape_configs: - job_name: netscan static_configs: - targets: ['netscan-host:9100'] ``` 暴露的指标:`netscan_hosts_up`、`netscan_scan_count`、`netscan_scan_duration_ms`、`netscan_port_open{ip,port}`。 ### Web UI ``` netscan web # http://localhost:8080 netscan web --addr 0.0.0.0:8080 # expose to LAN ``` 终端风格的简洁仪表盘 — 可触发扫描、查看主机、端口和厂商信息。指标端点位于 `/metrics`。 ## 参数参考 | 参数 | 简写 | 默认值 | 描述 | |------|------|--------|------| | `--ports` | `-p` | `22,80,443,...` | 要扫描的端口(逗号分隔或范围) | | `--fast` | `-f` | `false` | 仅执行 ping 扫描,跳过端口扫描 | | `--all` | | `false` | 扫描全部 65535 个端口 | | `--output` | `-o` | `table` | 输出格式:table、json、csv、wide | | `--timeout` | `-t` | `500` | 连接超时(毫秒) | | `--concurrency` | `-c` | `256` | 最大并发连接数 | | `--verbose` | `-v` | `false` | 显示详细输出 | | `--no-resolve` | | `false` | 跳过主机名解析 | | `--no-vendor` | | `false` | 跳过 MAC 厂商查询 | | `--interface` | `-i` | | 使用的网络接口 | ## 许可证 Apache License 2.0 — 参见 [LICENSE](LICENSE)。署名要求请参考 [NOTICE](NOTICE)。商标使用说明:[TRADEMARK.md](TRADEMARK.md)。 基于 XcoBean 开源技术构建 — https://xcobean.co.ke
标签:ARP, Banner抓取, Bonjour, CSV, curl安装, EVTX分析, Grafana, IPv6, JSON, Linux安全, MAC厂商查询, Maven构建, mDNS, NDP, OUI, Ping扫, PowerShell, Qt框架, TCP SYN 扫描, Wake-on-LAN, Web UI, 云存储安全, 单二进制, 反向DNS, 局域网发现, 嵌入式仪表盘, 持续监控, 数据统计, 日志审计, 服务识别, 端口扫描, 网络发现, 网络扫描, 自定义请求头, 设备告警, 零依赖