Hacking Tools

PatchWerk : A Tool For Cleaning NTDLL Syscall Stubs

PatchWerk is a proof-of-concept (PoC) tool designed to clean NTDLL syscall stubs by patching syscall hooks without requiring a handle to the NTDLL library.

This innovative approach enables user-land hook evasion, allowing red teamers and security researchers to bypass detection mechanisms employed by Endpoint Detection and Response (EDR) systems.

Developed as a Cobalt Strike Beacon Object File (BOF), PatchWerk simplifies the process of unhooking system calls while maintaining stealth.

Core Functionality

PatchWerk identifies all Nt* system call stubs within the NTDLL library and overwrites them with clean stubs.

This ensures that NTAPI calls originate from NTDLL, avoiding suspicious patterns in call stacks that EDR solutions monitor.

Unlike traditional unhooking methods, PatchWerk avoids mapping ntdll.dll from disk or opening handles to remote processes, reducing the risk of detection.

Key features include:

  • Direct Syscall Usage: Utilizes HellsGate and HalosGate techniques for direct syscalls, such as NtOpenProcess, NtWriteVirtualMemory, and NtProtectVirtualMemory.
  • Custom Hook Evasion: Implements custom GetModuleHandle and GetProcAddress functions (written in C and assembly) to evade hooks on kernel32.dll.
  • Process-Specific Adjustments: For current process patching, it bypasses the need for NtOpenProcess by using hProc = (HANDLE)-1.

PatchWerk can be executed with or without specifying a process ID (PID). When a PID is provided, it patches the NTDLL syscall stubs of the specified remote process. Without a PID, it defaults to patching the current process.

Example usage:

textbeacon> patchwerk 6115
[*] Patchwerk (Bobby Cooke|@0xBoku|github.com/boku7}
[+] host called home, sent 4937
[+] received output:
Patching NTDLL System Call Stubs in Process: 6115 (PID)
  • Stealth: By avoiding direct interaction with disk or remote handles, PatchWerk minimizes its footprint.
  • Efficiency: It directly patches syscall stubs in memory, ensuring clean execution paths for NTAPI calls.
  • Flexibility: Can be used for both local and remote processes.

PatchWerk represents a significant advancement in evading user-mode hooks and maintaining operational security during red team engagements.

By leveraging direct syscalls and innovative patching techniques, it provides an effective method for bypassing modern EDR solutions.

Varshini

Varshini is a Cyber Security expert in Threat Analysis, Vulnerability Assessment, and Research. Passionate about staying ahead of emerging Threats and Technologies.

Recent Posts

Playwright-MCP : A Powerful Tool For Browser Automation

Playwright-MCP (Model Context Protocol) is a cutting-edge tool designed to bridge the gap between AI…

2 weeks ago

JBDev : A Tool For Jailbreak And TrollStore Development

JBDev is a specialized development tool designed to streamline the creation and debugging of jailbreak…

2 weeks ago

Kereva LLM Code Scanner : A Revolutionary Tool For Python Applications Using LLMs

The Kereva LLM Code Scanner is an innovative static analysis tool tailored for Python applications…

2 weeks ago

Nuclei-Templates-Labs : A Hands-On Security Testing Playground

Nuclei-Templates-Labs is a dynamic and comprehensive repository designed for security researchers, learners, and organizations to…

2 weeks ago

SSH-Stealer : The Stealthy Threat Of Advanced Credential Theft

SSH-Stealer and RunAs-Stealer are malicious tools designed to stealthily harvest SSH credentials, enabling attackers to…

2 weeks ago

ollvm-unflattener : A Tool For Reversing Control Flow Flattening In OLLVM

Control flow flattening is a common obfuscation technique used by OLLVM (Obfuscator-LLVM) to transform executable…

2 weeks ago