d-ismlv/lim

GitHub: d-ismlv/lim

单脚本 Active Directory 安全评估编排工具,将多个经典 AD 安全工具整合为一次自动化运行并输出结构化结果。

Stars: 1 | Forks: 0

# lim 单脚本 Active Directory 评估收集器。将 PingCastle、Locksmith2、Rubeus、SharpHound 和 Snaffler 编排为带有时间戳的单次运行,并输出结构化结果。内置对 LDAP 签名、NTLM 配置和 GPP 凭据暴露的检查。 除了 PowerShell 5.1 和工具本身之外,没有其他依赖项。 ![收集运行 — 所有工具正常](https://raw.githubusercontent.com/d-ismlv/lim/main/assets/collector.gif) ## 前置条件 **环境** - Windows 主机,PowerShell 5.1+ - 加入域的会话 —— 域和 DC 会从当前 AD 上下文中自动解析 - 建议使用管理员令牌运行 PingCastle(用于 DNS 区域、对象创建日期) **工具** —— 运行前放入 `tools\` 目录: | 路径 | 来源 | |---|---| | `tools\PingCastle.exe` + `appsettings.console.json` | [pingcastle.com](https://www.pingcastle.com/download) | | `tools\Rubeus.exe` | [GhostPack/Rubeus](https://github.com/GhostPack/Rubeus) | | `tools\SharpHound.exe` + `SharpHound.exe.config` | [BloodHoundAD/SharpHound](https://github.com/BloodHoundAD/SharpHound) | | `tools\Locksmith2\` | [jakehildreth/Locksmith2](https://github.com/jakehildreth/Locksmith2) | | `tools\Snaffler.exe` | [SnaffCon/Snaffler](https://github.com/SnaffCon/Snaffler) | **PowerShell 模块** —— 如果不存在,会在首次运行时自动安装(需要网络): | 模块 | 作用 | |---|---| | `PSCertutil` | 必需 — ESC6, ESC7, ESC11, ESC16 | | `PSWriteHTML` | 可选 — Locksmith2 报告格式化 | ## 使用方法 ``` # 启动时提示输入凭据 .\collect.ps1 # 非交互 $cred = Get-Credential .\collect.ps1 -Credential $cred # 覆盖 Snaffler 超时(默认 30 分钟) .\collect.ps1 -SnafflerTimeout 60 ``` 凭据仅传递给 Locksmith2,它需要 PSCredential 来进行 LDAP 访问。所有其他工具都在当前会话令牌下运行。 ## 输出 ``` output\YYYY-MM-DD_HH-MM\ pingcastle\ ad_hc_*.xml ad_hc_*.html locksmith\ locksmith2_findings.json rubeus\ kerberoast.txt # absent if no kerberoastable accounts asreproast.txt # absent if no AS-REP roastable accounts sharphound\ *_BloodHound.zip adchecks\ adchecks.json # LDAP signing, channel binding, NTLM level gpp\ gpp_cpassword.json # absent findings = empty array snaffler\ snaffler.log # partial if timeout reached coercion\ coercion.json # Spooler + WebClient status per DC manifest.json # domain, dc, user, per-step results ``` ## 工作原理 **[PingCastle](https://www.pingcastle.com)** —— 针对已配置的 DC 运行 `--healthcheck --no-enum-limit`。受限令牌警告是非致命的;报告仍会照常生成。 **[Locksmith2](https://github.com/jakehildreth/Locksmith2)** —— 覆盖 ESC1–7、ESC9–11、ESC16。如果 `PSCertutil` 安装失败,则跳过 ESC6、ESC7、ESC11 和 ESC16,并且输出的文件会写入 `"partial": true`。ESC8(NTLM 中继到 HTTP 注册)不在主机本地收集器的范围内。 **[Rubeus](https://github.com/GhostPack/Rubeus)** —— 通过 `Assembly.Load()` 加载到内存中。使用当前会话令牌针对已配置的域运行 `kerberoast` 和 `asreproast`。不存储或传递任何凭据。 **[SharpHound](https://github.com/BloodHoundAD/SharpHound)** —— 运行 `--collectionmethods All`。有意省略了显式凭据传递;在 SharpHound v2 下,加入域的会话中此操作会失败。会话令牌足以进行完整收集。 **ADChecks** —— 通过 WinRM 使用提供的凭据从 DC 注册表中读取 LDAP 签名(`LDAPServerIntegrity`)、通道绑定(`LdapEnforceChannelBinding`)和 NTLM 级别(`LmCompatibilityLevel`)。同时独立于 WinRM 探测匿名 LDAP 绑定。如果 WinRM 不可用,注册表值将为空且 `source` 会被设置为 `winrm_unavailable`;匿名绑定结果将始终存在。 **GPP** —— 扫描 SYSVOL 中包含 `cpassword` 的组策略首选项 XML 文件。任何域用户均可读取。空的结果数组表示干净通过。 **Coercion** —— 通过 WMI 查询所有域控制器的 Spooler(PrinterBug / MS-RPRN)和 WebClient(HTTP 强制)服务状态。在 DC 上状态为 `Running` 意味着任何经过身份验证的域用户都可以利用该强制向量。 **[Snaffler](https://github.com/SnaffCon/Snaffler)** —— 在可访问的 SMB 共享中搜寻凭据、密钥和敏感配置。发现结果会实时流式传输到控制台。在 `$SnafflerTimeout` 分钟(默认 30)后停止;部分结果会保留在 `snaffler.log` 中。使用 `-SnafflerTimeout ` 进行调整。 ## 安全性 堆栈中的某些工具会触发终端检测。在运行前请将 `lim\` 目录添加为排除项。 二进制文件可以在静态下加密并在运行时于内存中解密,以减少静态检测面,但这超出了本项目的范围。 ## 许可证 MIT —— 详见 [LICENSE](LICENSE)
标签:Active Directory, AD域安全, AD安全评估, AI合规, BloodHound, Checkov, Conpot, GPP漏洞, IPv6, Kerberos攻击, LDAP安全, Libemu, Locksmith2, NTLM, OpenCanary, PingCastle, Plaso, PowerShell, Rubeus, SharpHound, Snaffler, StruQ, Windows安全, 凭据暴露, 单脚本编排, 域渗透, 域环境收集, 多人体追踪, 电子数据取证, 网络安全, 隐私保护