chud-lori/ngehe

GitHub: chud-lori/ngehe

ngehe 是一个一体化渗透测试 CLI 工具,从单一二进制文件中完成攻击面发现、Web 漏洞检测和非 HTTP 服务安全评估。

Stars: 0 | Forks: 0

# ngehe

ngehe icon

用于授权评估、HTB 靶机和 CTF 的渗透测试 CLI。ngehe 致力于发现目标的攻击面 —— Web 及非 HTTP 服务 —— 并从单一二进制文件中测试 OWASP Top 10 以及常见的 HTB 攻击向量(SSH、FTP、SMB、LDAP/AD、Kerberos、默认凭证)。 状态:alpha。在实际对抗中非常有用,但目前尚未成为成熟产品。 网站:[chud-lori.github.io/ngehe](https://chud-lori.github.io/ngehe/) ## ngehe 的功能 核心命令。 ### `ngehe box ` 全频段扫描。通过 shell 调用 nmap,然后针对所有 HTTP 端口分派各服务扫描器(SSH、FTP、SMB、LDAP、SNMP、DNS、DBs)以及 Web 侦察流程。这是针对“我刚刚拿到一个 HTB IP”时的首选入口。 ``` ngehe box --target 10.10.11.5 --domain target.htb --markdown box.md ``` 需要 PATH 中存在 `nmap`。对于带有 AD 特征的靶机,当检测到相关服务时,`ngehe box` 会通过其内置的 LDAP、Kerberos、BloodHound、SMB 和 NTLM 模块进行处理。 ### `ngehe recon ` 将其指向一个你从未见过的 URL —— 一个 HTB IP、一个新发现的子域,或一台预发布服务器。ngehe 将会: - 识别技术指纹(服务器、框架、CMS、会话 cookie 名称、正文标记) - 使用 SecLists 的 `quickhits` 字典探测敏感文件,并结合内容指纹识别(.git、.env、AWS 凭证、server-status、phpinfo) - 遍历 SecLists 的 `common.txt` 目录暴破字典 - 根据 HTTP 状态码和可利用性对发现结果进行分类 ``` ngehe recon --target http://10.10.11.5 --markdown recon.md ``` ### `ngehe surface ` 使用成熟的开源扫描器进行子域枚举和存活主机探测:**amass**(OWASP,全面被动扫描)、**subfinder**(projectdiscovery,快速被动扫描)和 **httpx**(projectdiscovery,探测 + 技术指纹识别)。配合 `--nuclei` 使用时,还会对存活主机运行 projectdiscovery 的模板扫描器。 ``` ngehe surface --domain target.htb # prints colored summary to terminal ngehe surface --domain target.htb --markdown surface.md # save markdown report ngehe surface --domain target.htb --out s.jsonl # save JSONL for jq ngehe surface --domain target.htb --nuclei # add CVE / misconfig templates ``` 输出模式为可选启用:默认为终端打印(带有 ANSI 颜色,并针对严重/高危发现结果提供“建议的攻击链”标题);传入 `--out` 或 `--markdown` 可将结果写入文件。`recon`、`scan` 和 `box` 的行为相同。 每个工具均可通过 `--no-amass` / `--no-subfinder` / `--no-httpx` 禁用;如果缺少二进制文件,则会自动跳过(不会导致严重报错)。使用 `./install.sh --with-extras` 进行安装。存活的 URL 会在最后打印到 stdout —— 可通过管道链式传递给 `ngehe recon` / `ngehe scan` / `ngehe box`: ``` ngehe surface -d target.htb | while read url; do ngehe scan --target "$url" --config ngehe.yaml done ``` ### `ngehe scan` 三种输入模式 —— 根据你的现有条件任选其一。 ``` # 模式 1 — HAR(信号最强)。在 Burp / DevTools 中捕获真实流量。 ngehe scan --har capture.har --config ngehe.yaml --markdown findings.md # 模式 2 — OpenAPI。根据 spec 合成请求。 ngehe scan --openapi openapi.yaml --base https://api.example.com --config ngehe.yaml # 模式 3 — 仅 URL。ngehe 爬取常见路径并使用 # 常见参数名(id, q, file, path, url, cmd, host, msg, ...)合成请求。 # 信号强度低于 HAR(我们在猜测参数),但仅需一个 URL 即可工作。 ngehe scan --target http://10.10.11.5 --config ngehe.yaml --markdown findings.md # 在原生 detectors 之上添加 nuclei templates(CVEs, default-config, exposures): ngehe scan --har capture.har --config ngehe.yaml --nuclei --markdown findings.md ``` ## 外部扫描器集成 当 PATH 中存在以下四个成熟的开源扫描器时,ngehe 会通过 shell 调用它们。每次集成都会将发现的结果输出到同一个 JSONL 文件中,并设置 `source:` 字段,以便你区分原生工具与上游工具。 | 工具 | 模块 / 标志 | 用途 | |---|---|---| | **nuclei** (projectdiscovery) | `scan --nuclei`, `box --nuclei`, `surface --nuclei` | 基于模板的扫描器 —— 包含数千个社区提供的 CVE / 错误配置 / 信息泄露模板 | | **amass** (OWASP) | `ngehe surface` | 全面的被动子域枚举 | | **subfinder** (projectdiscovery) | `ngehe surface` | 快速被动子域枚举 | | **httpx** (projectdiscovery) | `ngehe surface` | 探测主机名是否存活(HTTP)及进行技术指纹识别 | 这四个工具均可通过 `./install.sh --with-extras` 安装(在 Debian 系发行版上使用 apt,macOS 上使用 brew,并将各项目 GitHub releases 中的上游发布二进制文件作为便携后备方案)。它们均为可选启用:如果缺少二进制文件,ngehe 会打印提示并跳过,而不会导致运行失败。 如果需要进行更深入的漏洞利用,请单独安装:`hashcat`、`sqlmap`、`bloodhound`、`impacket` —— 这些都在每个发现结果的 `next` 字段中作为下一步的交接说明被记录。Docker 镜像捆绑了所有这些工具,因此你无需在宿主机上安装任何内容。 ## 非 Web 服务扫描器 (ngehe box) 内置服务模块。当 nmap 检测到相关服务时,每个模块都会自动触发。 | 服务 | 模块 | 功能描述 | |---|---|---| | SSH | `ssh-banner`, `ssh-old-openssh`, `ssh-libssh-auth-bypass`, `ssh-cve-2018-15473`, `ssh-auth-methods`, `ssh-none-auth-allowed` | 获取 Banner,基于版本的 CVE 标记(libssh CVE-2018-10933,OpenSSH ≤7.7 用户枚举),认证方式枚举 | | FTP | `ftp-banner`, `ftp-anonymous-allowed`, `ftp-anonymous-listing` | 匿名登录及文件列出 | | SMB | `smb-null-session-allowed`, `smb-anonymous-allowed`, `smb-guest-allowed` | 使用 null / anonymous / guest 进行共享枚举 | | LDAP | `ldap-anonymous-bind`, `ldap-root-dse`, `ldap-user-enum`, `ldap-asrep-roastable` | 匿名绑定,域控信息,完整用户列表,具有 DONT_REQ_PREAUTH 属性的账户 | | SNMP | `snmp-community-accepted` | 常见团体字符串(public、private 等) | | DNS | `dns-axfr-allowed`, `dns-subdomain` | 区域传送及子域暴破 | | MySQL / Postgres / MSSQL / Redis | `db-default-creds-*`, `db-no-auth-redis` | 默认凭证检查;Redis 未授权 INFO | | Active Directory | `kerberos-asrep-roast`, `kerberos-kerberoast` | 通过 gokrb5 提取 hashcat 格式的哈希 | | BloodHound | `bloodhound-collect` | 在 BloodHound JSON schema 中进行基于 LDAP 的子集收集(用户 / 计算机 / 组) | | HTTP NTLM | `ntlm-spray-hit` | 针对 HTTP NTLM endpoint 进行密码喷洒 | ## 检测器库 — OWASP 覆盖范围 | OWASP | 检测器 | 功能描述 | |---|---|---| | **A01 失效的访问控制** | `bola-cross-user-access` | 将请求作为其他每个 session 进行重放;当违规者获得相似响应时进行标记 | | | `broken-auth-anon-access` | 发送不含认证的相同请求 —— 标记 2xx 响应 | | | `idor-mutated-id` | 篡改路径和 JSON body 中的数字 / UUID ID | | | `lfi-path-traversal` | `../../etc/passwd`,编码变体,`php://filter`,`file://` | | **A02 加密机制失效** | `jwt-alg-none` | 服务器接受了未签名的 token | | | `jwt-weak-secret-*` | 使用弱密钥重新签名的 HS256 token 被接受 | | | `jwt-no-exp-check` | `exp=0` 的 token 被接受 | | | `jwt-kid-injection` | 路径遍历的 `kid` 被接受 | | | `jwt-no-iss-check` / `jwt-no-aud-check` | 未验证签发方 / 受众 | | **A03 注入** | `sqli-error-based` | 单引号 payload 触发了数据库错误字符串 | | | `sqli-time-based` | `SLEEP(5)` / `WAITFOR DELAY` 导致了响应延迟 | | | `cmdi-marker` | Shell 命令执行结果在响应中回显(确认 RCE) | | | `cmdi-time-based` | 休眠 payload 导致了响应延迟(盲注 RCE) | | | `ssti` | 模板表达式 `{{1337*1331}}` 被计算为 `1779547` | | | `xss-reflected` | Payload 未转义地回显到了 HTML 上下文中 | | **A05 安全配置错误** | `sensitive-file` | 针对带有内容指纹识别的 .git、.env、AWS 凭证、phpinfo 进行精选探测 | | | `sensitive-path` | 广泛的 SecLists quickhits.txt 探测(低特征覆盖) | | | `dir-discovery` | SecLists common.txt 目录暴破 | | | `default-credentials` | 针对已配置登录 URL 测试精选的 Web 管理员凭证 | | **A06 易受攻击和已过时的组件** | `tech-fingerprint` | 识别服务器、框架、CMS、runtime 版本以供手动查询 CVE | | | `cve-2026-41940-cpanel-whm-auth-bypass` | 针对存在认证绕过漏洞分支的非侵入式 cPanel/WHM/WP Squared 版本检查 | | | `cve-2026-42945-nginx-rift` | 基于 Banner 的 NGINX Rift 漏洞版本检查(不发送崩溃/DoS payload) | | | `server-header` / `x-powered-by` | 原始 header 泄露 | | **A07 身份验证失效** | `default-credentials` | (见 A05) | | | `jwt-*` | (见 A02) | | **A08 软件和数据完整性失效** | `mass-assign-reflected` | 注入的 `isAdmin`/`role`/`owner`/... 在响应中被回显 | | | `mass-assign-accepted` | 相同的注入被静默接受 | | **A10 服务器端请求伪造 (SSRF)** | `ssrf` | 云元数据服务(AWS/GCP/Azure),`file://`,loopback,gopher/dict 包装器 | ## 字典 ngehe 内置了来自 [danielmiessler/SecLists](https://github.com/danielmiessler/SecLists)(MIT 许可证,被 `ffuf`、`gobuster`、`dirsearch`、`feroxbuster` 广泛使用的事实标准集合)的三份字典: | 文件 | 来源 | 大小 | |---|---|---| | 常见路径 | `Discovery/Web-Content/common.txt` | 4750 条 | | 敏感文件 | `Discovery/Web-Content/quickhits.txt` | 2567 条 | | 默认凭证 | `Passwords/Default-Credentials/default-passwords.csv` | 2876 条 | 此外,还包含一小部分精心挑选的、极其通用的 Web 管理员凭证,用于快速默认凭证扫描。 归属说明请参阅 [`internal/wordlist/NOTICE.md`](internal/wordlist/NOTICE.md)。 ## 架构 ``` ┌───────────────────────────────────────┐ │ target / capture │ └───┬──────────────────┬────────────────┘ ▼ ▼ ┌──────────────────┐ ┌──────────────────┐ │ ngehe recon │ │ ngehe scan │ │ (URL only) │ │ (HAR / OpenAPI) │ └────────┬─────────┘ └────────┬─────────┘ ▼ ▼ ┌─────────────────────────────────────────┐ │ fingerprint sensitive dirbust │ │ sqli cmdi ssti lfi ssrf xss creds │ │ bola jwt-abuse id-mutate mass-assign │ └────────────────────┬────────────────────┘ ▼ ┌────────────────────────┐ │ JSONL + markdown report│ └────────────────────────┘ ``` 每个检测器都是 `internal/detector/` 和 `internal/recon/` 下的一个独立包。它们共享 `httpx`、`fuzz`、`oracle`、`finding` 和 `wordlist` 实用程序。 ### `ngehe chain ` 引导式漏洞利用演练。在任何扫描之后,你都会获得一个 JSONL 文件,其中包含 `next` 字段里针对各个规则的实战手册提示;`ngehe chain` 会以交互方式遍历它们,为每个严重/高危的发现结果展示手册,并提示你输入/确认要运行的命令。该命令会通过 `bash` 调用并绑定标准输入输出,因此反弹 shell 监听器、evil-winrm 会话、sqlmap 提示等均能正常运行。**这是连接“ngehe 发现了漏洞”与“我拿到了一个 shell”的桥梁。** ``` ngehe surface -d example.com --nuclei --out findings.jsonl ngehe chain findings.jsonl ngehe chain findings.jsonl --all # include medium / low findings, not just critical / high ``` 最好在容器内运行 —— 每一个交接工具(`hashcat`、`evil-winrm`、`netexec`、`impacket-*` 等)均已预装。 ## 容器 不想在宿主机上安装?使用内置的 Docker 镜像即可。适用于 Linux、macOS(Apple Silicon + Intel)、Windows / WSL —— 同一个镜像,没有特定平台编译的烦恼。 ``` # 1. Clone repo(需要 Dockerfile + wrapper)。 git clone https://github.com/chud-lori/ngehe.git cd ngehe # 2. 首次运行会自动构建 image(一次性,15-25 分钟 —— NetExec 的 Rust RDP module 是耗时的部分)。 ./scripts/ngehe doctor # 3. 像原生 binary 一样使用它。 ./scripts/ngehe surface -d example.com --nuclei ./scripts/ngehe box --target 10.10.11.5 --markdown box.md ./scripts/ngehe --shell # drop into a shell with every tool on PATH ``` 镜像大小约为 2GB,捆绑了**完整的 Web + box 渗透测试工具包** —— ngehe 是主要入口点,但在对抗中你可能会用到的每一个工具都在 PATH 中: - **ngehe 及集成工具**:nuclei(模板已预置)+ amass + subfinder + httpx - **Web**:nmap、sqlmapffuf、gobuster、dalfox - **AD / box**:hashcat、impacket(完整 Python 套件)、netexec、evil-winrm、kerbrute、enum4linux-ng、smbclient、ldap-utils、bloodhound-python - **网络**:ncat、socat、openssh-client、proxychains4 - **参考**:PayloadsAllTheThings 已克隆至 `/opt/PayloadsAllTheThings` 无需 `--with-extras`,无需 `apt install`,无需折腾 Python venv,无需 `nuclei -update-templates` —— 拉取一次,所有命令即可运行。 拉取仓库更新后重新构建: ``` git pull ./scripts/ngehe --rebuild doctor # or: docker compose build ``` 使用 docker compose 代替包装脚本: ``` docker compose run --rm ngehe surface -d example.com --nuclei ``` 直接使用 `docker run`(跳过包装脚本): ``` docker run --rm -it \ --network host \ -v "$PWD:/work" \ -v ngehe-nuclei-templates:/root/nuclei-templates \ ngehe:local surface -d example.com --nuclei ``` **macOS 注意事项:** Docker Desktop 的 `--network host` 需要通过 VM 网桥运行。扫描你自己的局域网是可行的(RFC1918 地址可达),但少数极端情况(原始套接字 nmap 模式)需要添加 `--cap-add=NET_RAW --cap-add=NET_ADMIN`。ngehe 默认使用 TCP 连接扫描,因此基础流程完全可以正常运行。 构建参数(跳过模板、版本锁定)请查阅 [Dockerfile](Dockerfile),标准的挂载布局请查阅 [compose.yaml](compose.yaml)。 ## 安装 一行命令安装程序(自动检测 brew/apt/dnf/pacman/apk,安装 `nmap`,构建并将 ngehe 放置在 `/usr/local/bin`): ``` git clone https://github.com/chud-lori/ngehe.git cd ngehe sudo ./install.sh # base install (ngehe + nmap) sudo ./install.sh --with-extras # also install nuclei + amass + subfinder + httpx ``` 非 root 用户安装到 `~/.local/bin`: ``` PREFIX=$HOME/.local ./install.sh --with-extras ``` 卸载: ``` sudo ./install.sh --uninstall # ngehe binary only sudo ./install.sh --uninstall --with-extras # also remove nuclei + amass + subfinder + httpx sudo ./install.sh --uninstall --purge # nuke EVERYTHING: above + nmap + ~/nuclei-templates # + tool config dirs + Go module cache ``` 普通的 `--uninstall` 比较保守:它仅移除 `ngehe` 二进制文件。`--with-extras` 还会移除四个扫描器软件包(apt remove / brew uninstall / `~/go/bin/*` / `~/.local/bin/*`),但会保留配置目录和 nuclei 模板缓存。 `--purge` 是全面擦除 —— 移除 nmap,删除 `~/nuclei-templates`(约 1GB),删除 `~/.config/{nuclei,subfinder,amass,httpx}` 中的配置目录,运行 `go clean -modcache` 清除所有遗留模块(包括被某些扫描器标记的 `vulncheck-oss/go-exploit` webshell 测试用例)。Go 工具链本身将保留不动(ngehe 从未安装过它);如果你想同时移除 Go,清理步骤会打印出相应的 apt/brew/压缩包移除命令。 手动安装: ``` go build -o ngehe . sudo install -m 0755 ngehe /usr/local/bin/ngehe # 你仍然需要:brew install nmap (macOS) # sudo apt install nmap (debian/ubuntu) ``` 安装完成后,验证依赖: ``` ngehe doctor ``` 必需:`nmap`(用于 `ngehe box`)。推荐:`hashcat`(破解 krb5asrep / krb5tgs / JWT 哈希),`sqlmap`(在 ngehe 标记后进行更深入的 SQLi),`bloodhound`(导入 ngehe 生成的 AD JSON)。 ## HTB 快速入门 ``` # 1. 全频谱 scan(需要 nmap)。探测每一个开放 port。 ngehe box --target 10.10.11.5 --domain target.htb --markdown box.md # 2. 如果 web app 在范围内:捕获真实流量(Burp / mitmproxy / 浏览器 HAR)。 # 3. 编写包含 sessions + default-creds URL 的 ngehe.yaml。 ngehe init --out ngehe.yaml # 4. 主动 web scan —— 所有 detector。 ngehe scan --har capture.har --config ngehe.yaml --markdown web.md ``` 对于重 AD 的靶机,在 `ngehe box` 暴露出 LDAP/Kerberos 服务并列举出用户名后,可交由 `impacket` 进行更深入的攻击。ngehe 的轻量级 Kerberos 原语位于 `internal/scanner/kerberos/` 中,并在具备足够目标上下文的情况下被服务模块所调用。 完整演练请查阅 [HOWTO.md](HOWTO.md)。 ## 输出 每个发现结果都包含一个 **`next` 字段** —— 针对该漏洞类型的具体利用指南。Markdown 报告会以一个**“建议的攻击链”**部分开头,对严重/高危发现结果进行排序,并为你提供从发现漏洞到获取 shell 所需的具体 payload / curl 命令 / hashcat 调用。 JSONL 摘录(每行一个发现结果): ``` { "rule": "ssti", "severity": "critical", "method": "GET", "url": "http://target/api/greet?name=%7B%7B1337%2A1331%7D%7D", "path": "/api/greet", "param": "query:name", "payload": "{{1337*1331}}", "evidence": "Jinja2/Twig/Liquid evaluated 1337*1331 → 1779547", "why": "template expression was evaluated server-side — SSTI confirmed (RCE chain available)", "next": "RCE via template. Engine identified in evidence — chain to OS commands:\n Jinja2: {{config.__class__.__init__.__globals__['os'].popen('id').read()}}\n Twig: {{['id']|filter('system')}}\n ..." } ``` 筛选出可操作的发现结果: ``` # 仅包含 attack-chain 候选项 ngehe view findings.jsonl --severity critical,high ``` ## 配套工具 ngehe 是由三个工具组成的防御/攻击技术栈中的主动测试组件: - [cornela](https://github.com/chud-lori/cornela) — Linux 容器内核审计工具。主机加固,逃逸风险检测。 - [milog](https://github.com/chud-lori/milog) — nginx + 系统监控工具。日志扫描,漏洞利用检测,主机完整性审计。 - **ngehe** — Web 渗透测试 CLI。在授权评估和 CTF 期间进行主动测试。 这三个工具共享统一的 JSONL 输出规范。 ## 安全模型 ngehe 专用于授权的对抗评估。 - 仅对你拥有的系统、获得书面测试许可的系统,或明确设计为 CTF / HTB 目标的系统使用。 - 部分检测器会发送可能触发 WAF 警报或导致你被列入黑名单的 payload(如 SLEEP、命令注入标记、目录遍历序列)。在生产环境中扫描前,请与资产所有者协调。 - ngehe 不会端到端地利用发现的漏洞 —— 它只负责识别。SSTI → RCE、SQLi → 数据提取等均需要人工跟进。 - 捕获的数据和配置文件包含真实的 token。请将其视为机密信息妥善保管。 ## 许可证 Apache-2.0。SecLists 字典遵循 MIT 许可证;详见 `internal/wordlist/NOTICE.md`。
标签:Docker容器, EVTX分析, 安全侦察, 对称加密, 插件系统, 攻击面发现, 日志审计, 模拟器, 自动化审计, 请求拦截, 运行时操纵