Skip to main content

AntiHook Engine

A lightweight, high-performance user-mode memory integrity and unhooking engine for Windows, written in Cython.

It scans the Export Address Table (EAT) of loaded PE modules (e.g., ntdll.dll) to detect instruction redirects (relative, absolute, or indirect jumps) and restores their original .text sections from clean system files on disk.

Features

  • Native PE Parsing: Traverses module exports with zero Python overhead using direct memory pointers.
  • Hook Detection: Identifies standard user-mode hooks (relative, absolute, and indirect jumps).
  • Origin Tracking: Resolves the exact path of the third-party DLL or security product placing the hook.
  • Minimized CRT Dependency: Reduces reliance on the C Runtime (CRT) by utilizing custom-implemented string and memory operations, retaining only essential allocations (malloc and free).

Quick Start

Requirements

  • Operating System: Windows (x64 architecture only)
  • Python: version 3.8 or higher
  • Compiler: Visual Studio C++ Build Tools (MSVC Compiler)

Open the appropriate Visual Studio Native Tools Command Prompt and run:

pip install antihook

2. Usage

import antihook
import ctypes
import json

# Ensure target system DLL is loaded
ctypes.windll.ntdll

# Scan ntdll.dll
scan = antihook.unhook("ntdll.dll", scan_only=True)
print("Scan Results:", json.dumps(scan, indent=4))

# Restore ntdll.dll .text section
restored = antihook.unhook("ntdll.dll", scan_only=False)
print("Unhook Results:", json.dumps(restored, indent=4))

API Reference

unhook(module_name: str, scan_only: bool = False) -> dict

  • module_name: Target DLL name (e.g., "ntdll.dll").
  • scan_only: If True, only reports hooks. If False, performs the full unhooking routine.

Returns:

{
    "status": "success",
    "unhooked": true,
    "detected_hooks": [
        {
            "function": "NtCreateFile",
            "type": "Relative",
            "hook_address": "0x7FFE12345678",
            "hook_module": "C:\\Windows\\System32\\monitor.dll"
        }
    ]
}

Disclaimer

This project is intended strictly for authorized security research, application self-defense, and educational purposes. Modifying execution sections of system libraries in memory can cause instability if handled incorrectly. Use with caution.

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for antihook 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for antihook 0.2.0
File Size Uploaded Provenance Actions
antihook-0.2.0.tar.gz 10.7 kB Without provenance Details for antihook-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for antihook 0.2.0
File Interpreter ABI Platform Actions
antihook-0.2.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for antihook-0.2.0-cp314-cp314-win_amd64.whl

Total release size: 45.7 kB

Release files / antihook-0.2.0.tar.gz

Download URL antihook-0.2.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
de58a7e9fffebde34d05fde9bff018a86042e37bb6820b9bcf9040cfdbcd0185
BLAKE2b-256 checksum
How to use checksums
2900fc06b25c8fa9a06cdbc84ce533d1ae36f129bd374600322c0a4fdbb8629c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / antihook-0.2.0-cp314-cp314-win_amd64.whl

Download URL antihook-0.2.0-cp314-cp314-win_amd64.whl
Size 35.0 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
7798822d76cb6d26b10fea7bbc1e5603f092022c168e8e88c6a4af6f23d0299a
BLAKE2b-256 checksum
How to use checksums
0df7b1ce4f39ed081199db3d9cdba5f2bd6a37b8b97245f338bd2eefd24519f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for antihook 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page