terrillhilliard/netrecon

GitHub: terrillhilliard/netrecon

一款纯 Python 实现的局域网资产侦察与监控 CLI,无需管理员权限即可发现主机、扫描端口并构建持久化资产清单。

Stars: 0 | Forks: 0

# netrecon [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/terrillhilliard/netrecon/actions/workflows/ci.yml) ![Python](https://img.shields.io/badge/python-3.9%2B-blue) ![License](https://img.shields.io/badge/license-MIT-green) **网络侦察、资产清查与监控 —— 一个快速、轻依赖的 Python CLI,配备实时 Web 控制台。** `netrecon` 可发现子网上的存活主机,扫描其端口,通过 MAC-厂商 / 主机名 / 服务数据 丰富每台主机的信息,被动捕获 flows + DNS, 并将所有内容累积到本地 SQLite **资产清单** 中,随着多次运行不断增长。 其核心 **不需要管理员权限、不需要 Npcap、不需要第三方包** — 它 使用并发的 ping sweep、OS ARP cache 以及异步 TCP-connect 扫描器。 可选的 `serve` 命令可在同一引擎之上托管实时 Web 仪表板。 ## 功能 - **`scan`** — 并发 ping + ARP 主机发现,异步 TCP 端口扫描,厂商/主机名/服务/banner 信息丰富。 - **`monitor`** — 通过 raw sockets 进行被动 flow + DNS 捕获(纯标准库;需要管理员权限)。 - **`serve`** — 由 netrecon 引擎提供的实时 Web 控制台(雷达、主机详情下钻、端口扫描器、流量遥测)。 - **`interfaces`** — 列出适配器并选择要使用的适配器;自动优先选择有线连接,跳过 VPN/虚拟网络,使用 `--iface` 切换。 - **`hosts`** — 累积的 SQLite 资产清单(`first_seen` / `last_seen` / `times_seen`)。 - 简洁的 [rich](https://github.com/Textualize/rich) 表格,在不支持时优雅降级为纯文本,或使用 `--json` 用于 pipelines。 ## 安装 ``` git clone https://github.com/terrillhilliard/netrecon cd netrecon python -m venv .venv .venv\Scripts\activate # Windows (source .venv/bin/activate on *nix) pip install -e . # optional extras: rich (color) + mac-vendor-lookup (vendor names) ``` 即使没有可选包,核心也完全基于纯标准库运行。 ## 用法 ``` netrecon interfaces # see adapters + the auto-selected default netrecon scan # scan the selected interface's /24 netrecon scan --iface Wi-Fi # pick a specific interface (name or IP) netrecon scan 192.168.1.0/24 --banners # explicit target + banner grabbing netrecon scan 10.0.0.1 --full --json # all 65535 ports, JSON out netrecon monitor --duration 30 # 30s passive flow + DNS capture (admin) netrecon serve # open the live web dashboard (http://127.0.0.1:8081) netrecon serve --iface eth0 --monitor # bind an interface + live traffic capture netrecon hosts # review the accumulated inventory ``` ### 示例 ``` $ netrecon scan [*] interface Wi-Fi (192.168.88.145) [*] discovering 254 address(es) on 192.168.88.0/24 ... [*] 4 host(s) up - scanning 82 ports each ... IP MAC Vendor Hostname Open Ports 192.168.88.1 b8:29:03:66:e6:3e — VNPT.lan 22/ssh, 53/domain, 80/http, 443/https 192.168.88.145 — — XYZ-ULG.lan 135/msrpc, 139/netbios-ssn, 445/microsoft-ds 192.168.88.165 cc:98:8b:13:ce:c5 — — 80/http, 8008/tcp, 8443/https-alt, 9000/tcp 192.168.88.174 ae:56:bc:24:6a:4e — Galaxy-A20.lan — [+] 4 hosts up | 11 open ports | 8.9s | target 192.168.88.0/24 ``` ## Web 仪表板 `netrecon serve` 托管着一个自包含的 Web 控制台(声纳雷达、主机详情下钻、 WiFi/流量面板、Zenmap 风格的端口视图以及设备端分析器),由 兼容 bettercap 的 REST API 提供支持 — 因此 UI 完全运行在 netrecon 引擎上。它会按设定间隔重新扫描,并在使用 `--monitor` 时,串流实时流量和 DNS 事件。数据持久化保存到 `~/.netrecon/netrecon.db`。 ## 路线图 | 阶段 | 功能 | 状态 | |-------|-----------|--------| | 0.1 | 发现 + 端口扫描 + SQLite 清单 | ✅ 完成 | | 0.2 | `monitor` — 被动 flow/DNS 捕获 | ✅ 完成 | | 0.4 | `serve` — 基于 netrecon 引擎的 Web 控制台 | ✅ 完成 | | 0.3 | `watch` — 新设备 / 新端口告警 → ntfy | 计划中 | | 0.5 | Zeek/Suricata 接入 → 家庭 SIEM(flow 搜索、威胁情报、异常评分) | 计划中 | ## 法律声明 仅扫描或监控您拥有或获得明确授权测试的网络。 未经授权的扫描在您所在的司法管辖区可能是非法的。此工具仅供 防御性安全、资产管理以及授权评估使用。 MIT © 2026 Terrill Hilliard
标签:Python, 占用监测, 后端开发, 插件系统, 数据统计, 无后门, 端口扫描, 资产管理, 运维监控, 逆向工具