Skip to main content

Overview

The Napi2NativeLoader enables bypassing NTQQ’s security restrictions that prevent Node.js addons from accessing native APIs. This is required for advanced features like packet hooking and native module integration.
Security Notice:
  • Bypasses disable security features in the NTQQ environment
  • Only enable specific bypasses you need
  • Improper configuration can cause instability or crashes
  • Use at your own risk in production environments

Architecture

Implemented in packages/napcat-core/packet/handler/napi2nativeLoader.ts:22, the loader manages platform-specific native modules that patch NTQQ’s security checks.

Supported Platforms

  • win32.x64 - Windows 64-bit
  • linux.x64 - Linux 64-bit
  • linux.arm64 - Linux ARM64
  • darwin.x64 - macOS Intel
  • darwin.arm64 - macOS Apple Silicon

Initialization

Basic Setup

Loading Process

The loader automatically attempts to load the native module on construction:

Bypass Options

The enableAllBypasses function accepts granular control over which security features to bypass:

Enable All Bypasses

Selective Bypass Configuration

Common Configurations

Minimal Configuration (Packet Handling Only)

For basic packet monitoring:

Full Access Configuration

For development or debugging:

Production Configuration

For production bots with minimal risk:

Verbose Logging

Enable detailed logging from the native module:
Verbose mode is disabled by default for performance. Only enable during debugging.

Hook Initialization

After enabling bypasses, initialize hooks with memory offsets:

Complete Integration Example

Security Implications

Hook Bypass (hook: true)

  • Allows: Function hooking, detours, memory patching
  • Risk: Code injection vulnerabilities
  • Required for: Packet monitoring, protocol analysis

Module Bypass (module: true)

  • Allows: Loading additional native modules
  • Risk: Malicious module loading
  • Required for: Plugin system, dynamic features

Process Bypass (process: true)

  • Allows: System API access, process manipulation
  • Risk: System-wide impact, privilege escalation
  • Required for: Advanced system integration

Window Bypass (window: true)

  • Allows: GUI access, window manipulation
  • Risk: UI hijacking
  • Required for: Custom UI features

Container Bypass (container: true)

  • Allows: Escape sandbox restrictions
  • Risk: Sandbox escape
  • Required for: Full system access

JavaScript Bypass (js: true)

  • Allows: Bypass JS engine restrictions
  • Risk: Arbitrary code execution
  • Required for: Advanced scripting

Error Handling

Platform-Specific Considerations

Windows

  • Requires administrator privileges for some bypasses
  • Antivirus may flag native modules
  • Windows Defender may block hook operations

Linux

  • SELinux/AppArmor may interfere with bypasses
  • Permissions may need adjustment
  • Works best with relaxed security policies

macOS

  • System Integrity Protection (SIP) may block operations
  • Gatekeeper may prevent module loading
  • Requires appropriate entitlements

Debugging

Check Loader Status

Verify Bypass Status

Best Practices

  1. Minimal bypasses: Only enable what you need
  2. Error handling: Always check return values
  3. Platform detection: Verify platform support before loading
  4. Graceful degradation: Fall back to restricted mode if bypasses fail
  5. Security audit: Document which bypasses are enabled and why
  6. Testing: Test on all target platforms
  7. Monitoring: Log bypass operations for security audit

Troubleshooting

Module Not Loading

Bypass Fails to Enable

Hook Initialization Fails