How dualhorizon/blackpill works
Project Overview and Components
• Project Type: BlackPill is a Linux rootkit combining kernel module techniques (hooking, persistence, defense evasion), an internal hypervisor for executing malicious code, and integration with eBPF programs for network packet interception. It also includes a separate C2 (command and control) component written in Python.
• Main Components to Represent:
• Kernel Space Rootkit: Composed of multiple Rust modules (e.g., “hiding”, “hooking”, “persistence”, “hypervisor”, “utils”, “xdp”).
• Hypervisor Module: Implements VM entry/exit and guest management (includes C components and Rust module wrappers).
• Defense Evasion & Hooking: Using kprobes for syscall interception (e.g., modifying filldir64, hiding the module) plus IDT hooking.
• eBPF Programs: Located in the “stealthbpf” directory that include a common library, eBPF-based “stealthbpf-ebpf”, and additional components for filtering incoming (XDP) and outgoing (TC) network traffic.
• C2 Client: Found under “blackpill-c2”, a Python script that sends crafted x86-64 opcodes over UDP and communicates via TCP with the rootkit.
• Auxiliary Components: Build scripts (Makefile, shell scripts in “scripts”) and configuration files (Cargo.toml, rust-toolchain.toml) which support compilation and VM setup.
Relationships and Data Flows
• Within the kernel, the rootkit code intercepts system calls via registered hooks (depicting “hooking” and “defense evasion” modules) and modifies behaviors to hide files, processes, and connections.
• Packets arriving from the network are filtered by an eBPF XDP program before being passed to the Linux kernel module. Outgoing packets are similarly intercepted and modified by eBPF TC programs.
• Persistence functionality (triggered by the rootkit) ensures that critical operations (e.g., test file creation, future persistence methods) continue across reboots.
Architectural Patterns & Design Principles
• Layered Approach: Differentiate between kernel space (the rootkit and its modules) and user space (the C2 client). Clearly indicate the network stack interactions.
• Extensibility: Point out that additional functionalities (later evolutions of persistence or hooking techniques) can be expanded in the same modular format.