Full Remote DLL Unhooking

Unhook DLLs in a remote process

DLL unhooking is a methodology employed to circumvent detection by endpoint detection and response (EDR) systems. EDRs employ hooks within DLLs that contain Windows API functions to monitor for malicious activity. A comprehensive catalog of EDR hooks is readily accessible at Mr-Un1k0d3rs Github.

Usage

std::string dllName = "ntdll.dll"
int pid = [Code to get process ID of any function]
remoteunhook(dllName, int pid)

POC

  1. Open x64dbg.exe and attach it to the target process (ex. procexp64.exe)

  2. Identify a hooked function, I will search for "ZwMapViewOfSection":

Find ZwMapViewOfSection
E9? Hooked
  1. E9 indicates ZwMapViewOfSection is hooked. Unhooked ntdll functions are expected to return have BX.

  2. Detach x64dbg.exe and execute the remote dll unhooking tool against the remote process.

  3. Re-attach x64dbg.exe and return to the ZwMapViewOfSection

  4. If successful, there will be a BX value instead of E9

B8!

NOTE

The code below will only work with NTDLL.DLL, according to the research where I got the main base of this code from, ntdll doesn't need image base relocations. I have experimental code I have been working on at the bottom of this article but it has no been tested as I am still learning as I go!

Code

UNTESTED CODE:

I don't fully understand everything about PE files yet. This is code that I developed with a lot of research and asking ChatGPT what was wrong with my code LOL. USE AT OWN RISK.

Contribution Credit

mantvydasb - Blog Post with original code - Github & Twitter - For the codebase that I used to make this project Mr-Un1k0d3r - For the EDR hook research

Last updated