DLL Hijacking using Spartacus, outside of DllMain
A DLL hijacking vulnerability in Microsoft OneDrive allowed an attacker to place a malicious version.dll next to OneDrive.exe, which would load it and execute arbitrary code. The attacker could achieve code execution in the context of the user running OneDrive.
pavel.gr
Published on pavel.gr
Spartacus is a DLL Hijacking detection tool that utilises the SysInternals Process Monitor and has a built-in parser for raw ProcMon log and configuration files.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker who can write to the directory containing OneDrive.exe could execute arbitrary code with the privileges of the user running OneDrive.
What the attacker needed
Write access to OneDrive's directory; user launches OneDrive
How it was found
- Run Spartacus with ProcMon to capture OneDrive's DLL loads and identify missing DLLs.
- Generate a proxy DLL skeleton for version.dll using Spartacus.
- Create a Visual Studio DLL project named version, disable precompiled headers, and set /MT.
- Replace dllmain.cpp with Spartacus-generated code and implement a payload using msfvenom and process injection.
- Compile the DLL and place it in the same directory as OneDrive.exe.
- Start a Metasploit listener and launch OneDrive.exe to get a reverse shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a program starts, it loads shared code libraries called DLLs. If it looks for a DLL in a folder where an attacker can write files, the attacker can put a malicious DLL there with the same name. The program then runs the attacker's code instead of the real library.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.