Skip to content
nysch3nPublic

About

Beta prototype & research project: Testing AI capabilities in generating low-level Windows Internals code for dynamic SSN resolution.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

NightCall 🌑

C++ ASM Windows x64 PoC
"Listen to the shadows, not the API."


🧪 Project Origin: AI-Assisted Beta Prototype

Full Transparency: This project was created primarily as a Proof of Concept (PoC) and a beta test to evaluate the capabilities of modern AI in writing low-level Windows Internals code (C++/MASM).

My goal was to see if AI could successfully generate complex malware evasion techniques like:

  • Manual PEB walking
  • EAT parsing
  • Hell's/Halo's Gate dynamic SSN resolution

I used Gemini 3 PRO, Github Copilot and Chatgpt 5.1


My role in this project: Prompt engineering, conceptual architecture, debugging, assembling the MASM stubs, and verifying the execution flow. It is a research prototype, not a fully weaponized tool.

⚠️ Disclaimer

For educational and research purposes only. NightCall demonstrates concepts (Indirect Syscalls, API Hashing, PEB walking) intended for security researchers and authorized Red Team exercises. Do not use these techniques for unauthorized access or malicious activity.


🔍 What is NightCall?

NightCall is a proof-of-concept syscall loader built to illustrate techniques used to avoid user-land hooks placed by Endpoint Detection & Response (EDR) systems. Instead of importing WinAPI or issuing direct syscall instructions from injected stubs, NightCall demonstrates an indirect approach that preserves a legitimate-looking call stack and avoids common user-mode hook detections.

This repository is intended as a learning resource for defensive researchers, OS internals students, and Red Teamers operating under authorization.


⚡ Key Features

  • 🚀 Indirect Syscalls — jumps to the syscall instruction inside ntdll.dll so the call stack appears to originate from ntdll.
  • 🔎 Dynamic SSN Resolution — implements variations of "Hell's Gate" and "Halo's Gate" logic to resolve System Service Numbers at runtime and handle hooked syscall stubs.
  • 🧭 No WinAPI Imports — discovers modules and functions via PEB walking and manual Export Address Table parsing (no GetModuleHandle/GetProcAddress entries in the IAT).
  • 🔐 API Hashing — obfuscates module and function names using a case-insensitive djb2 hash to remove readable strings from the binary.
  • 🧰 x64 ABI Compliance — ensures proper stack alignment and reserves Shadow Space before transitions to kernel mode.
  • 🛡️ Safety Checks — bounds-checks .text sections and avoids reading forwarders or uncommitted memory.

📖 How it works (high level)

  1. PEB Walk

    • Locate ntdll.dll by traversing the Process Environment Block's module lists.
  2. Manual EAT Parsing

    • Parse ntdll's Export Address Table and compare hashed function names to identify syscall stubs.
  3. Gate Logic

    • Inspect the function stub bytes to determine whether the stub is "clean" or has been hooked.
    • If hooked, perform neighborhood scanning (Halo's Gate) to infer the correct SSN from nearby stubs.
  4. Indirect Execution

    • Prepare registers (r10, eax), align the stack, allocate shadow space, then perform an indirect jump to the syscall instruction contained within ntdll.dll.

🗂 Project Structure

NightCall/
│
├── NightCall.cpp       # Main C++ logic (PEB walking, hashing, gate logic)
├── syscalls.asm        # MASM implementation of the indirect syscall stub
└── README.md           # Documentation

🛠 Build Instructions

Requirements

  • Visual Studio 2019 or 2022 with the "Desktop development with C++" workload.

Quick steps

  1. Clone the repository.
  2. Open the solution in Visual Studio.
  3. Enable MASM:
    • Project → Build Dependencies → Build Customizations... → Check masm.
    • Right-click syscalls.asm → Properties → Item Type → Microsoft Macro Assembler.
  4. Set configuration to Release and platform to x64 (x86 is not supported).
  5. Build the solution (Ctrl+Shift+B).

Note: The MASM configuration is a critical step — the assembly stub must be assembled with MASM for x64.


💻 Usage Example

The main() function currently demonstrates a PoC flow: it resolves a hashed name, finds the SSN and the syscall address for NtOpenProcess, and prepares to invoke it indirectly.

Example console output:

[*] Hash for NtOpenProcess: 0x71E3518A
[*] Searching for SSN and Syscall Address...
[+] SUCCESS!
    |-> SSN: 0x26
    |-> Syscall Address: 0x00007FFB3216D642
[*] Ready to invoke (Indirect Syscall).

To extend:

  • Define additional native API prototypes in the C++ source.
  • Add corresponding syscall stubs or use the existing indirect stub to invoke other native APIs.

(Use responsibly — this repository is a learning resource, not a turnkey offensive tool.)


🤝 Credits & References

  • Hell's Gate / Halo's Gate techniques — VxUnderground & Sektor7 community
  • SysWhispers — popularized direct/indirect syscall generation
  • ReactOS — Windows internals references
  • Tartarus Gate — advanced hooking detection ideas

Made for research. Keep it ethical.

About

Beta prototype & research project: Testing AI capabilities in generating low-level Windows Internals code for dynamic SSN resolution.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages