diff --git a/src/windows-hardening/windows-local-privilege-escalation/dll-hijacking/README.md b/src/windows-hardening/windows-local-privilege-escalation/dll-hijacking/README.md index 9a0ba4face8..818a1960d14 100644 --- a/src/windows-hardening/windows-local-privilege-escalation/dll-hijacking/README.md +++ b/src/windows-hardening/windows-local-privilege-escalation/dll-hijacking/README.md @@ -181,6 +181,55 @@ Operational usage example This technique has been observed in-the-wild to drive multi-stage sideloading chains: an initial launcher drops a helper DLL, which then spawns a Microsoft-signed, hijackable binary with a custom DllPath to force loading of the attacker’s DLL from a staging directory. +### .NET AppDomainManager hijacking via `.exe.config` + +For **.NET Framework** targets, sideloading can be done **before `Main()`** without patching memory by abusing the application's adjacent **`.exe.config`** file. Instead of relying only on the Win32 DLL search order, the attacker places a legitimate .NET EXE next to a malicious config and one or more attacker-controlled assemblies. + +How the chain works: +1. The host EXE starts and the **CLR reads `.config`**. +2. The config sets **``** and **``** so the runtime instantiates an attacker-controlled `AppDomainManager`. +3. The malicious manager gets **pre-`Main()` execution** inside the trusted host process. +4. The same config can force the CLR to resolve local assemblies first (for example `InitInstall.dll`, `Updater.dll`, `uevmonitor.dll`) and can weaken runtime validation/telemetry without inline patching. + +Campaign-style pattern (exact nesting can vary by directive / CLR version): + +```xml + + + + + + + + + + + + + + + +``` + +Why this is useful: +- **``** keeps assembly resolution in the application directory, turning the folder into a predictable sideloading surface. +- **`` + ``** move execution into attacker code during CLR initialization, before the legitimate app logic runs. +- **``** can let a full-trust app load unsigned or tampered assemblies without a strong-name validation failure. +- **``** avoids publisher-policy redirects to newer assemblies. +- **``** makes runtime selection more deterministic. +- **``** is especially interesting because the **CLR disables its own ETW visibility** from configuration instead of the implant patching `EtwEventWrite` in memory. + +Operational pattern seen in recent campaigns: +- Stage 1 drops `setup.exe`, `setup.exe.config`, and local assemblies. +- Stage 2 copies them into a believable **AppData update** folder, renames the host to something like `update.exe`, and relaunches it via a **scheduled task**. +- Stage 3 verifies execution context (for example expected parent `svchost.exe` from Task Scheduler) before loading the final RAT DLL/export. + +Hunting ideas: +- Signed or otherwise legitimate **.NET executables** running with suspicious adjacent **`.config`** files in user-writable locations. +- `.config` files containing **`appDomainManagerAssembly`**, **`appDomainManagerType`**, **`probing privatePath="."`**, **`bypassTrustedAppStrongNames`**, or **`etwEnable enabled="false"`**. +- Scheduled tasks that relaunch renamed update binaries from **`%LOCALAPPDATA%`** or app-specific `\bin\update\` directories. +- Parent/child chains where a scheduled task launches a trusted .NET host that immediately loads non-vendor assemblies from its own directory. + #### Exceptions on dll search order from Windows docs Certain exceptions to the standard DLL search order are noted in Windows documentation: @@ -606,6 +655,13 @@ Defensive pivots - [Check Point Research – Inside Ink Dragon: Revealing the Relay Network and Inner Workings of a Stealthy Offensive Operation](https://research.checkpoint.com/2025/ink-dragons-relay-network-and-offensive-operation/) - [Rapid7 – The Chrysalis Backdoor: A Deep Dive into Lotus Blossom’s toolkit](https://www.rapid7.com/blog/post/tr-chrysalis-backdoor-dive-into-lotus-blossoms-toolkit) - [0xdf – HTB Bruno ZipSlip → DLL hijack chain](https://0xdf.gitlab.io/2026/02/24/htb-bruno.html) +- [Unit 42 – Tracking Iranian APT Screening Serpens’ 2026 Espionage Campaigns](https://unit42.paloaltonetworks.com/tracking-iran-apt-screening-serpens/) +- [Microsoft Learn – `` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/appdomainmanagerassembly-element) +- [Microsoft Learn – `` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/appdomainmanagertype-element) +- [Microsoft Learn – `` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/probing-element) +- [Microsoft Learn – `` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/bypasstrustedappstrongnames-element) +- [Microsoft Learn – `` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/publisherpolicy-element) +- [Microsoft Learn – `` element](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/requiredruntime-element) {{#include ../../../banners/hacktricks-training.md}}