Service DLL Hijacking
Last updated
Last updated
This attack is similar to "Service Binary Hijacking" but instead of replacing the executable, it targets a DLL the application relies on.
Another approach is hijacking the DLL search order, where Windows looks for the required DLLs in this sequence:
List applications on the machine:
Do some research about an application which is vulnerable to DLL Hijacking.
The following example displays a Service which is vulnerable kind of this attack.
In the example above, the application attempts to load a DLL, but fails to find it in its directory. Instead, TextShaping.dll
loads from the System directory (2th in the search order).
The following screenshot is from Procmon, showing the application's attempt to load TextShaping.dll
from the The directory from which the application loaded.
To exploit this, create a malicious DLL in the FileZilla directory so that when the application looks for the legitimate DLL, it loads the attacker’s version instead, executing malicious code.
Using C++ it is possible to create DLLMain
function which is responsible to execute code in the DLL life cycle:
Compile it:
Alternatively, use msfvenom
to generate the DLL:
Moving the DLL to the target directory:
Soon as the DLL will be attached the DLLMain function will execute.