x-glacier/kali-pentest / kali-pentest-zh
kali-pentest-zh
Flagged通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。
references/playbooks/password-audit.md
View on GitHub# 密码审计 Playbook
用于已授权的密码破解、哈希分析、默认凭据检查、密码喷洒或凭据复用测试。
## 输入
- 哈希文件、凭据列表、用户名、目标服务和范围。
- 锁定策略、允许速率、允许时间窗口和排除账号。
- GPU 破解是否可用且已授权。
## 流程
1. **密码策略分析**
- 在测试前分析目标的密码策略:最小长度、复杂度要求(大写、小写、数字、特殊字符)、最大长度和字符限制。
- 确定锁定阈值:锁定前的失败尝试次数、锁定持续时间和重置行为。
- 识别轮换要求和密码历史深度。
- 利用这些信息聚焦字典选择、规则生成和掩码设计——跳过违反已知策略的候选项。
2. **分类材料**
- 用 `hashid`、工具上下文或来源系统识别哈希类型。
- 分离哈希、明文凭据、用户名和服务目标。
(哈希识别工具选择参见 `../password/README.md`。)
- **哈希提取来源**:SAM 数据库(本地 Windows 账号)、NTDS.dit(Active Directory 域哈希,通过 `impacket-secretsdump`)、`/etc/shadow`(Linux/Unix)、数据库凭据表、应用程序配置文件和内存转储。提取方法和访问前提条件交叉参考 `post-exploitation.md`。
使用 `hashid -m` 识别哈希类型并获取 hashcat 模式编号(参见 `../password/tools/hashid.md`)。
**哈希识别歧义处理:** 当 hashid 返回多个候选类型时,通过以下方式缩小范围:(1) 来源上下文(shadow → sha512crypt/md5crypt;NTDS.dit → NT;Responder → NetNTLMv2),(2) 哈希长度和字符集,(3) 用小型字典测试排名靠前的候选类型,再运行完整的攻击升级阶梯。
3. **准备字典和规则**
- 使用 `rockyou.txt`、SecLists、`cewl`、`crunch` 和目标相关词汇。
- 除非 Deep 深度已授权,否则避免生成超大字典。
(字典生成工具选择参见 `../password/README.md`。)
使用 `cewl` 和 `crunch` 生成自定义字典(参见 `../password/tools/cewl.md` 和 `../password/tools/crunch.md`)。
4. **离线破解**
- 根据哈希类型和硬件选择 `john` 或 `hashcat`。
- 做出 GPU 假设前检查 `hashcat -I`。
- 保存破解结果和 potfile 上下文。
(破解工具选择参见 `../password/README.md`。)
- 根据哈希类型和已知密码策略选择攻击模式:
- `-a 0` 字典攻击:适用于大多数场景,配合规则使用。应用 `-r /usr/share/hashcat/rules/best64.rule` 进行常见变异;链接多个规则文件以获得更深覆盖。
- `-a 3` 掩码/暴力破解:用于短密码或策略允许短长度时。定义与已知策略匹配的掩码(例如 `?u?l?l?l?d?d` 用于以大写开头的 6 字符密码)。
- `-a 6` 混合模式(字典 + 掩码追加):用于密码可能遵循"基础词 + 后缀"模式时(例如 `Password1!`)。在字典词后追加数字/符号。
- 当哈希类型计算缓慢(bcrypt、scrypt、Argon2、phpass、sha512crypt)时,优先使用针对性字典和智能规则,而非穷举暴力破解。
运行离线破解:
- GPU 首选:`hashcat -m <mode> -a 0 hashes.txt <wordlist>`(参见 `../password/tools/hashcat.md` 了解攻击模式和规则文件)
- CPU 备选:`john --wordlist=<wordlist> --format=<format> hashes.txt`(参见 `../password/tools/john.md`)
```bash
# 字典配合规则
hashcat -m <mode> -a 0 hashes.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule
# 掩码攻击(8 字符密码:大写 + 小写 + 数字)
hashcat -m <mode> -a 3 hashes.txt ?u?l?l?l?l?l?d?d
# 混合模式:字典 + 2 位数字后缀
hashcat -m <mode> -a 6 hashes.txt /usr/share/wordlists/rockyou.txt ?d?d
# John 格式示例
john --format=NT --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
john --format=netntlmv2 --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
```
**攻击升级阶梯(必须执行):** 不要在单次字典攻击后停止。对每个哈希文件,按以下顺序逐级升级,直到达到约定的时间预算:(1) 字典 + `best64.rule`,(2) 字典 + `dive.rule` 或 `OneRuleToRuleThemAll.rule`,(3) 来自 `cewl` 和公司术语的目标专属字典 + 规则,(4) 匹配已知密码策略的掩码攻击,(5) 混合字典 + 掩码追加/前置。如果阶段 1 后零个哈希被破解,先确认哈希类型、模式和格式正确。
4b. **加密文件哈希提取**
- 使用 `*2john` 工具从加密文件中提取哈希,然后进行破解:
```bash
zip2john protected.zip > zip_hash.txt
ssh2john id_rsa > ssh_hash.txt
keepass2john database.kdbx > keepass_hash.txt
gpg2john private.key > gpg_hash.txt
rar2john archive.rar > rar_hash.txt
```
5. **在线测试**
- 使用 `hydra`、`medusa`、`patator`、`crowbar`、`netexec` 或服务专项工具。
- 暴力破解前先测试已知凭据和默认凭据。
- 执行锁定安全延迟、单账号尝试上限和停止条件。
(在线攻击工具选择参见 `../password/README.md`。)
在线测试(遵守锁定策略):
- SSH/FTP/Web 表单:`hydra -l <user> -P <wordlist> <protocol>://<target>`(参见 `../password/tools/hydra.md` 了解协议相关语法)
- SMB/WinRM 凭据测试:`nxc smb <cidr> -u <user> -p <pass>`(参见 `../password/tools/netexec.md`)
- Kerberos 密码喷洒:`kerbrute passwordspray -d <domain> --dc <dc-ip> valid_users.txt '<password>'`(参见 `../password/tools/kerbrute.md`)
```bash
# Kerberos 密码喷洒(锁定安全:对多用户测试同一密码)
kerbrute passwordspray -d <domain> --dc <dc-ip> valid_users.txt 'Password1!'
```
**逐协议在线覆盖:** 测试所有已发现的认证服务(SSH、RDP、SMB、FTP、HTTP 登录、数据库),而非仅测试一种协议。使用 `netexec` 进行多协议扫描,使用 `hydra` 或 `medusa` 进行协议专项深度测试。未测试的服务就是未测试的攻击面。
6. **凭据复用**
- 仅在授权服务上测试已破解或已提供凭据。
- 记录成功、失败、MFA、禁用账号和权限级别。
(凭据测试工具选择参见 `../password/README.md`。)
使用 `nxc` 在跨服务中测试已破解凭据(参见 `../password/tools/netexec.md` 了解 smb/winrm/mssql/ssh 协议模块)。
```bash
nxc smb <CIDR> -u cracked_users.txt -p cracked_passwords.txt --continue-on-success
nxc winrm <CIDR> -u <user> -H <hash>
nxc ssh <CIDR> -u <user> -p '<password>'
nxc mssql <CIDR> -u <user> -p '<password>'
```
**凭据 × 服务覆盖矩阵(必须执行):** 对每个破解出的凭据在每个授权服务和协议上进行测试——不要只测试一个协议。构建凭据 × 服务矩阵(SMB、WinRM、SSH、RDP、MSSQL、LDAP、HTTP),并将每格记录为:成功、失败、MFA 阻断、账号禁用或未测试。未测试的格子是覆盖缺口。
6b. **MFA 评估**(风险门控:需要明确批准)
- 测试 MFA 疲劳攻击:发送重复推送通知,确定用户是否最终批准。
- 测试短代码(4-6 位)OTP 暴力破解:检查验证端点的速率限制和锁定。
- 测试备份码复用:验证备份码在使用后是否被失效处理。
- 测试 MFA 注册绕过:确定持有有效凭据的攻击者能否在无额外验证的情况下注册自己的 MFA 设备。
- 记录 MFA 覆盖缺口——跳过 MFA 强制执行的端点或流程。
7. **哈希捕获**
- 仅在明确批准且位于内网范围内时使用 `responder`、中继相关工具或捕获流程。
- 始终先使用分析模式(`responder -A`)观察流量,再进行主动投毒。
(哈希捕获工具选择参见 `../password/README.md`。中继工具选择参见 `../exploitation/README.md`。)
- 对于中继攻击,使用 `ntlmrelayx` 将捕获的认证中继到其他服务(参见 `../exploitation/tools/impacket.md`),使用 `mitm6` 进行基于 IPv6 的 MITM(参见 `../exploitation/tools/mitm6.md`)。
如果已授权进行内网 LAN 捕获,运行 `responder -I <interface>`(参见 `../password/tools/responder.md`)。
```bash
# 第 1 步:分析模式——观察但不投毒
responder -I <interface> -A
# 第 2 步:主动投毒(需要明确批准)
responder -I <interface>
# NTLM 中继到目标服务
impacket-ntlmrelayx -tf targets.txt -smb2support
# 基于 IPv6 的 MITM 用于 WPAD/DNS 接管
mitm6 -d <domain>
```
## 交叉引用
- `active-directory.md` — AS-REP roasting 和 Kerberoasting 攻击工作流。
- `post-exploitation.md` — 哈希提取方法。
- `reporting-workflow.md` — 发现文档。
## 预期产物
- 哈希类型清单。
- 使用的字典/规则。
- 破解命令日志和已破解凭据列表。
- 在线尝试次数和锁定安全证据。
- 按服务整理的凭据复用矩阵。
## 停止条件
- 离线破解达到约定时间预算。
- 在线测试达到约定尝试上限。
- 出现任何账号锁定风险、意外生产影响或范围外凭据。
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |