DLL Hijack Search Order BOF
November 2, 2021 ยท View on GitHub
What is this?
- This is a
Cobalt StrikeBOFfile, meant to use two arguments (path to begin, and aDLLfilename of interest), that will traverse theSafeSearchorder ofDLLresolution - Optionally, this will also attempt to ascertain a
HANDLEto the provided file (if found), and alert the operator of its mutability (WRITEaccess)
What problem are you trying to solve?
- There are tools (mostly in
.NETor otherwise) that do this job (traditionallyPowershell-based), but I hadn't seen similar inCat the time of writing. I may just be terrible atdorking
How do I build this?
- In this case, you have two options:
- Use the existing, compiled object file, located in the
distdirectory (AKA proceed to major step two) - Compile from source via the
Makefilecd srcmake cleanmake
- Use the existing, compiled object file, located in the
- Load the
Aggressorfile, in theScript Manager, located in thedistdirectory
How do I modify this BOF to not attempt to get a HANDLE on the provided DLL filename, if found?
- Within
./src/main.c, modifydfsStruct.bCheckCreateFileAanddfsStruct.bResultCreateFileAtoFALSE. - Rebuild with the included build instructions
How do I use this?
- From a given
Beacon:# For accessing the help menu prompt hijack_hunter help # Example usage hijack_hunter C:\Users\User\Desktop superLegit.dll
Any known downsides?
- We're still using the
Win32API andDynamic Function Resolution. This is for you to determine as far as "risk". - You may attempt to incur a privileged action without sufficient requisite permissions. I can't keep you from burning your hand.
What does the output look like?
