# Alternate Service Name

커버로스 위임 중 Constrained Delegation은 S4U2Proxy 확장을 통해 A 서비스 티켓을 B 서비스 티켓으로 교환할 수 있습니다.&#x20;

커버로스 패킷의 sname 필드는 암호화 되지 않으며 서비스 티켓 검증 단계에서 sname에 대한 서명 검증이 없으므로 공격자는 제약된 위임을 통해 A 계정으로 B 계정의 B-1 서비스 티켓을 발급받고, 이 티켓을 B-2 서비스 티켓으로 교환하여 사용할 수 있습니다.

## Abuse

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

<pre class="language-powershell"><code class="lang-powershell"><strong># 서비스 티켓 교환
</strong>.\Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:cifs/ad01.contoso.com /user:user-A /rc4:2b576acbe6bcfda7294d6bd18041b8fe /domain:contoso.com /altservice:ldap /ptt /nowrap
</code></pre>

{% endtab %}

{% tab title="UNIX" %}

<pre class="language-bash"><code class="lang-bash"><strong># 서비스 티켓 교환
</strong>impacket-getST acs.secure/Mick3y:'Password123!' -impersonate Administrator -spn 'cifs/acs-dc01.acs.secure' -dc-ip 10.0.2.11 -altservice ldap/acs-dc01.acs.secure
</code></pre>

{% endtab %}
{% endtabs %}

## Root Cause

acs.secure/Mick3y는 acs-dc01.acs.secure의 cifs에 대해서 제약된 위임 권한이 있기 때문에 Administrator를 대행하여 자신의 서비스 티켓을 발급받습니다.

<div><figure><img src="/files/d5VR76AumKnpIQwehkaL" alt=""><figcaption><p>TGS-REQ</p></figcaption></figure> <figure><img src="/files/UTj9uyNPsUfCAP4rPBr9" alt=""><figcaption><p>TGS-REP</p></figcaption></figure></div>

두번째 TGS-REQ/REP 과정도 [Constrained Delegation](/data-theft/active-directory/constrained-delegation.md) 에서 본 것과 동일한 흐름을 확인할 수 있습니다.

<div><figure><img src="/files/aeYpAC1cGT5VwqmBWA0E" alt=""><figcaption><p>TGS-REQ</p></figcaption></figure> <figure><img src="/files/j1OPtd8rtPxjKnl633Ex" alt=""><figcaption><p>TGS-REP</p></figcaption></figure></div>

Alternate Service Name 공격의 TGS-REQ에서 요청하는 서비스 이름을 위임받은 SPN 소유자의 다른 서비스로 변경하지 않는 이유는 sname 필드 검증 단계가 TGS-REQ에는 있기 때문입니다.&#x20;

단지 반환받은 특정 서비스에 대한 TGS-REP의 sname 필드를 변조하여 같은 서비스 주체의 다른 서비스에 대해 AP-REQ를 했을 때 서비스 서버에서 검증하지 않아 발생하는 취약점입니다.

<figure><img src="/files/QaidNynlalBPR0Lh0NaG" alt=""><figcaption><p>KRB 오류</p></figcaption></figure>

따라서 altservice 인자를 넣었을 때 동작 흐름을 분석하려면 코드와 반환된 티켓을 봐야합니다.

<figure><img src="/files/nFaPj2mhJheBpnBAc1RY" alt=""><figcaption><p><a href="https://raw.githubusercontent.com/fortra/impacket/refs/heads/master/examples/getST.py">https://raw.githubusercontent.com/fortra/impacket/refs/heads/master/examples/getST.py</a></p></figcaption></figure>

getST.py에서 impersonate 인자를 넣었을 때 doS4U2ProxyWithAdditionalTicket 함수를 통해 TGS-REQ를전송하고 받은 TGS-REP를 TGS 변수에 할당합니다. 함수의 마지막은 saveTicket 함수에 반환된 TGS 변수를 전달하여 실행합니다.

<figure><img src="/files/hMLlJ5UfAaZoO3J9EUnu" alt=""><figcaption><p><a href="https://raw.githubusercontent.com/fortra/impacket/refs/heads/master/examples/getST.py">https://raw.githubusercontent.com/fortra/impacket/refs/heads/master/examples/getST.py</a></p></figcaption></figure>

saveTicket 함수에서는 사용자가 altservice 인자를 사용했을 경우 반환된 서비스 티켓에서 sname 값을 altservice에서 준 값에서 '/' 기호를 기준으로 동적으로 할당하여 저장하는 것이 확인됩니다.

<figure><img src="/files/C6QfNVFnUuf65gSsqlaX" alt=""><figcaption><p>Rubeus describe</p></figcaption></figure>

저장된 티켓을 Rubeus의 describe를 통해 확인하면 altservice 인자로 입력한 서비스 이름이 확인됩니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pentestwiki.com/data-theft/active-directory/alternate-service-name.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
