How bytecode77/r77-rootkit works
Project Type and Purpose
• The project is a security tool—in this case, a fileless user-mode (ring 3) rootkit—whose purpose is silently to hide and obfuscate system components.
• The README confirms that it hides files, directories, processes, registry keys, TCP/UDP connections, etc., using multiple evasion techniques (AMSI bypass, DLL unhooking, etc.), with its configuration stored in the Windows registry under a hidden key.
File Structure and Components
• Core Rootkit Modules:
• The “r77” directory contains the core source code (configuration, hooks, rootkit functionality).
• The “r77api” folder provides auxiliary API functions to interact with system components (such as manipulating PEB structures, setting hooks, etc.).
• Installation and Injection:
• “Install”, “InstallShellcode”, and “Uninstall” directories hold the installer and uninstaller programs, as well as the shellcode for fileless installation.
• “Stager” is responsible for the code injection and stager logic which helps launch the payload.
• Process Injection and Reflective Loading:
• “ReflectiveDllMain” supplies the reflective DLL entry-point mechanisms needed for injecting the rootkit code into other processes.
• Services and Runtime Components:
• “Service”, “Service32”, and “Service64” indicate components that run as services or background processes to maintain the rootkit's presence.
• Helper and Supporting Code:
• “Helper”, “Helper32”, “Helper64” directories provide common utilities and support files.
• The “TestConsole” and “Example” directories contain test applications and examples; “TestConsole” is especially important for inject testing and configuration system debugging.
• Assembly and Manual Code:
• “InstallShellcode” and “Unhook” include assembly files (with .asm extensions) that illustrate low-level operations, which are essential for AV/EDR evasion.
• Build Resources:
• The “SlnBin” directory holds important build artifacts such as the FASM binaries and supporting include files for hook-related APIs.
Key Components and Their Relationships
• Installation Phase:
• Installer (found in “Install” and “InstallShellcode”) is the entry point, which, when executed, loads the shellcode or runs Install.exe to inject the rootkit into running processes.
• The shellcode version demonstrates fileless installation techniques.
• Injection and Staging:
• The “Stager” module is used to inject the rootkit’s code into various processes.
• “ReflectiveDllMain” provides the entry point for the injection by enabling reflective DLL loading.
• Core Rootkit Engine:
• The “r77” and “r77api” modules are responsible for hooking APIs, hiding system components (files, directories, processes, etc.), and ensuring persistence.
• Global configurations and constants (in “Global” and configuration files) manage the dynamic configuration stored in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\$77config.
• Monitoring/Service Components:
• The “Service” set of projects is used to monitor system events (like process creation) and apply hooks dynamically.
• Auxiliary Tools:
• The “TestConsole” application acts as a control panel for testing, injecting, and debugging the rootkit behavior.
• The “Example” projects provide reference implementations for using core functionalities (e.g., CPU usage monitoring, control pipe communication).
Architectural Patterns and Design Principles to Highlight
• Fileless Execution: Emphasize that the rootkit resides purely in memory and does not leave traces on disk after installation.
• Dynamic Configuration: Illustrate the dynamic configuration mechanism that uses the registry (with the hidden “$77config” key) to control what is hidden and how.
• AV/EDR Evasion Techniques: Include components responsible for AMSI bypass, DLL unhooking, and low-level system patching.
• 32-bit vs. 64-bit Handling: Note that the project includes separate builds for 32-bit and 64-bit environments (e.g., directories Helper32, Helper64, Service32, Service64, r77-x86, and r77-x64).
Detail for the Principal Software Engineer
• Subsystem is clearly demarcated:
• Installer: “Install”, “InstallShellcode”
• Injection/Staging: “Stager”, “ReflectiveDllMain”
• Core Rootkit: “r77”, “r77api” (along with “Global” definitions and hooks)
• Evasion Techniques: “Unhook” module and FASM builds in “SlnBin”
• Support and testing: “TestConsole” and “Example”
• Modules written in C/C++ (core and system-level code)
• Modules written in C# (e.g., some helper or testing UIs)
• Assembly routines (for low-level AV bypass and injection)
• How the installation/injection process initiates the rootkit’s operation,
• How core engine components hook and hide system objects,
• How auxiliary modules such as the configuration system and TestConsole integrate with the main engine,
• And how AV/EDR evasion strategies are implemented.