# SMB

SMB 기본 공유 폴더 중 서버의 C:\Windows 경로인 ADMIN$ 쉐어에 쓰기 권한이 있다면 Sysinternal Suite - PsExec와 같은 원격 제어 프로그램을 사용하여 쉘을 얻을 수 있습니다.

해당 프로그램 외에도 SMB에 권한이 있다면 다양한 방법으로 측면 이동이 가능하겠지만, C2 프레임워크에서 널리 사용되는 방법인 PsExec를 기반으로 설명하겠습니다.

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

<pre><code><strong># 대상 시스템 로컬 계정/도메인 계정으로 원격 쉘 획득
</strong>.\PsExec64.exe -u Administrator -p 'Password123!' \\192.168.1.11 cmd
</code></pre>

{% endtab %}

{% tab title="UNIX" %}

<pre><code><strong># 대상 시스템 로컬 계정/도메인 계정으로 원격 쉘 획득
</strong>impacket-psexec contoso.com/Administrator:'Password123!'@192.168.1.11
</code></pre>

{% endtab %}
{% endtabs %}

## Root Cause

<figure><img src="/files/b1Dpj8gzVEBS2Du8PdaW" alt=""><figcaption><p>PSEXESVC.exe Create Request</p></figcaption></figure>

PsExec를 실행하면 클라이언트는 서버의 ADMIN$ 공유 폴더 하위에 PSEXESVC.exe를 업로드 합니다. 해당 실행 파일을 통해 원격 제어를 할 수 있습니다. C:\Windows 경로가 공유 폴더에서 ADMIN$으로 나타나는데, 이 폴더에 쓰기 권한이 있는 원격 로컬 사용자 계정 혹은 도메인 계정만이 가능합니다.

<figure><img src="/files/ucGaNLC0ASAynPftaZ1U" alt=""><figcaption><p>PsExec를 통한 원격 제어 흐름</p></figcaption></figure>

PSEXESVC.exe는 실행했을 때 원격 제어가 되도록 돕는 실행 파일입니다. 해당 파일을 바이너리 파일로 지정하는 서비스를 생성 및 실행하기 위해 SVCCTL(Service Control Manager Remote Protocol)을 사용합니다.

<figure><img src="/files/ru1Yab3RcR5yKpUn4KlH" alt=""><figcaption><p>서비스 바이너리를 실행 파일로 지정하여 서비스 생성</p></figcaption></figure>

## Opsec

PSEXESVC는 Windows System Event ID 7036을 남깁니다.

<figure><img src="/files/4GkxhzBfw2x5HpnLUxgg" alt=""><figcaption><p>Windows System Event log</p></figcaption></figure>

## References

{% embed url="<https://www.extrahop.com/blog/psexec-explanation-and-lateral-movement>" %}

{% embed url="<https://dmcxblue.gitbook.io/red-team-notes/lateral-movement/untitled>" %}

{% embed url="<https://jakpentest.tistory.com/entry/WinRM%EC%9D%B4%EB%9E%80>" %}


---

# 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/lateral-movement/windows/smb.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.
