How 0xsch1zo/nullgate works
Project Type and Purpose
• NullGate is a native C++ library and command-line tool (hasher) that provides a modern, type-safe interface for invoking Windows NT API functions via indirect syscalls with dynamic syscall number resolution and simple obfuscation routines.
• It also includes a proof-of-concept sample injector demonstrating how to bypass Windows Defender’s memory scans using its syscall and obfuscation primitives.
High-Level Architecture
• Components:
• NullGate Core Library
– Modules:
· syscalls (dynamic lookup of syscall numbers & wrappers)
· obfuscation (FNV-1 hashing, xor/b64 encode‐decode, hex2bin)
– Interfaces: templated SCall<>, non-templated Call()
– Dependencies: Windows ntdll.dll, FreshyCalls technique
• Hasher CLI Executable
– Built from src/hasher/hasher.cpp
– Reads stdin, applies xor+base64 via obfuscation module, outputs payload
• Sample Injector Executable
– Built from src/sample/sample.cpp
– Uses NullGate::syscalls to allocate memory, write shellcode, bypass Defender
• Build System
– Top-level CMakeLists.txt orchestrates building library, hasher, sample
– FetchContent support for inclusion in external CMake projects
Component Interactions and Data Flow
• At build time: CMake builds the static NullGate library, links it into hasher.exe and sample.exe.
• At runtime:
1. Sample.exe calls into NullGate::syscalls
2. syscalls module reads ntdll exports, matches hashed names via obfuscation::fnv1Runtime
3. Executes indirect syscall stubs (syscalls.S, .asm) to perform NtAllocateVirtualMemory, NtWriteVirtualMemory, NtResumeThread
4. Obfuscation routines handle shellcode encoding/decoding as needed
5. Memory scan bypass logic: allocate with PAGE_NOACCESS/junk write, create suspended thread, write real shellcode, resume thread
• Hasher.exe: stdin → obfuscation::xorEncode → obfuscation::base64Encode → stdout
Architectural Patterns and Design Principles
• Modularity: separate compilation units for syscalls, obfuscation, sample, hasher
• Type Safety: use of C++ templates for compile-time signature enforcement
• Separation of Concerns: library core versus CLI tools versus sample PoC
• Static Linking: avoids symbol export and makes integration seamless
• Build-time configuration: CMake flags for sample build and cross-compilation