Skip to content

Commit 8246bbb

Browse files
author
HackTricks News Bot
committed
Add content from: Research Update Enhanced src/windows-hardening/windows-local...
1 parent b1150ce commit 8246bbb

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

src/windows-hardening/windows-local-privilege-escalation/dll-hijacking/writable-sys-path-dll-hijacking-privesc.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ For more info about **what is Dll Hijackig** check:
2121

2222
The first thing you need is to **identify a process** running with **more privileges** than you that is trying to **load a Dll from the System Path** you can write in.
2323

24+
Remember that this technique depends on a **Machine/System PATH** entry, not only on your **User PATH**. Therefore, before spending time on Procmon, it's worth enumerating the **Machine PATH** entries and checking which ones are writable:
25+
26+
```powershell
27+
$machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine") -split ';' | Where-Object { $_ }
28+
$machinePath | ForEach-Object {
29+
$path = $_.Trim()
30+
if ($path) {
31+
Write-Host "`n[*] $path"
32+
icacls $path 2>$null
33+
}
34+
}
35+
```
36+
2437
The problem in this cases is that probably thoses processes are already running. To find which Dlls are lacking the services you need to launch procmon as soon as possible (before processes are loaded). So, to find lacking .dlls do:
2538

2639
- **Create** the folder `C:\privesc_hijacking` and add the path `C:\privesc_hijacking` to **System Path env variable**. You can do this **manually** or with **PS**:
@@ -50,6 +63,9 @@ if ($envPath -notlike "*$folderPath*") {
5063
5164
<figure><img src="../../../images/image (945).png" alt=""><figcaption></figcaption></figure>
5265
66+
> [!TIP]
67+
> **Boot logging is only required for services that start too early** to observe otherwise. If you can **trigger the target service/program on demand** (for example, by interacting with its COM interface, restarting the service, or relaunching a scheduled task), it is usually faster to keep a normal Procmon capture with filters such as **`Path contains .dll`**, **`Result is NAME NOT FOUND`**, and **`Path begins with <writable_machine_path>`**.
68+
5369
### Missed Dlls
5470
5571
Running this in a free **virtual (vmware) Windows 11 machine** I got these results:
@@ -66,6 +82,18 @@ In this case the .exe are useless so ignore them, the missed DLLs where from:
6682
6783
After finding this, I found this interesting blog post that also explains how to [**abuse WptsExtensions.dll for privesc**](https://juggernaut-sec.com/dll-hijacking/#Windows_10_Phantom_DLL_Hijacking_-_WptsExtensionsdll). Which is what we **are going to do now**.
6884
85+
### Other candidates worth triaging
86+
87+
`WptsExtensions.dll` is a good example, but it is not the only recurring **phantom DLL** that shows up in privileged services. Modern hunting rules and public hijack catalogs still track names such as:
88+
89+
| Service / Scenario | Missing DLL | Notes |
90+
| --- | --- | --- |
91+
| Task Scheduler (`Schedule`) | `WptsExtensions.dll` | Classic **SYSTEM** candidate on client systems. Good when the writable directory is in the **Machine PATH** and the service probes the DLL during startup. |
92+
| NetMan on Windows Server | `wlanhlp.dll` / `wlanapi.dll` | Interesting on **server editions** because the service runs as **SYSTEM** and can be **triggered on demand by a normal user** in some builds, making it better than reboot-only cases. |
93+
| Connected Devices Platform Service (`CDPSvc`) | `cdpsgshims.dll` | Usually yields **`NT AUTHORITY\LOCAL SERVICE`** first. That is often still enough because the token has **`SeImpersonatePrivilege`**, so you can chain it with [RoguePotato / PrintSpoofer](../roguepotato-and-printspoofer.md). |
94+
95+
Treat these names as **triage hints**, not guaranteed wins: they are **SKU/build dependent**, and Microsoft may change the behavior between releases. The important takeaway is to look for **missing DLLs in privileged services that traverse the Machine PATH**, especially if the service can be **re-triggered without rebooting**.
96+
6997
### Exploitation
7098
7199
So, to **escalate privileges** we are going to hijack the library **WptsExtensions.dll**. Having the **path** and the **name** we just need to **generate the malicious dll**.
@@ -82,6 +110,10 @@ Having **generated the malicious Dll** (_in my case I used x64 rev shell and I g
82110
83111
When the service is re-started, the **dll should be loaded and executed** (you can **reuse** the **procmon** trick to check if the **library was loaded as expected**).
84112
85-
{{#include ../../../banners/hacktricks-training.md}}
113+
## References
86114
115+
- [Windows DLL Hijacking (Hopefully) Clarified](https://itm4n.github.io/windows-dll-hijacking-clarified/)
116+
- [Suspicious DLL Loaded for Persistence or Privilege Escalation](https://www.elastic.co/guide/en/security/current/suspicious-dll-loaded-for-persistence-or-privilege-escalation.html)
117+
118+
{{#include ../../../banners/hacktricks-training.md}}
87119

0 commit comments

Comments
 (0)