Linux

BlackPill : A Comprehensive Overview Of A Stealthy Linux Rootkit

Dive into the dark intricacies of BlackPill, a sophisticated Linux rootkit engineered in Rust that epitomizes stealth and versatility in cyber threats.

This article unravels its multi-faceted modules, from evasion tactics to persistent attacks, outlining how it manipulates system operations to remain undetected.

Features

The rootkit is composed of multiple modules (talking about Rust modules, not kernel modules):

  • defense evasion: hide files, processes, network connections, etc.
  • hooking: hook syscalls and IDT
  • hypervisor: create a virtual machine to execute malicious code
  • persistence: make the rootkit persistent after reboot and resilient to supression
  • utils: various utilities

C2 sends crafted assembled x86_64 mnemonics to the rootkit, which then sends it to the VM guest to execute it. The VM guest is isolated from the host and can be used to execute malicious code.

Kernel do not see incoming malicous packets as they are filtered by the eBPF XDP program and sent to the LKM module, and outgoing packets are modified by the eBPF TC program.

Hooking

Hooking is a fundamental capability of the rootkit, implemented using kprobes in the Linux kernel. This technique intercepts and redirects the execution of system functions to monitor or modify their behavior.

In the context of this rootkit, kprobes provides a powerful mechanism to interact with kernel functions without altering the source code directly.

Defense Evasion

To ensure stealth, the rootkit employs two primary anti-detection mechanisms:

  1. Removing the Module from the Kernel Module List
    When a kernel module is loaded, it is added to the kernel’s module list, visible via tools like lsmod or /proc/modules. To prevent detection:
    • The rootkit manually removes itself from this list.
    • Despite being removed from the list, the module remains operational, enabling continued execution of its functionality.
  2. Hooking the filldir64 Function to Hide a Specific Directory
    To conceal files used by the rootkit, a hook is implemented on the filldir64 function. This function is invoked when a process reads directory contents (e.g., via getdents or readdir system calls).
    • Hooking Process:
      • The rootkit intercepts the filldir64 function using kprobes.
      • During execution, the handler inspects directory entries returned to the user.
      • If an entry matches the /BLACKPILL-BLACKPILL directory (used to store critical rootkit files), it is filtered out and not returned to the user.
      • All other directory entries are returned normally, ensuring transparency for user-space tools.
  3. Using eBPF XDP and TC Programs to Modify Ingress and Egress network traffic To normalize our malicious network communications, we use eBPF XDP (eXpress Data Path) and TC (Traffic Control) programs. As such, we can:
    • Intercept specific incoming (ingress) packets with the XDP program at the lowest network level by matching the crafted TCP payload signature from our C2, which we then redirect to a custom BPF map for VM/LKM processing.
    • Intercept specific outgoing (egress) packets with the TC program by matching TCP packets generated by VM/LKM, which we then modify by overwriting their payload with our C2 response data.
      • The original packets are automatically retransmitted by TCP, maintaining the appearance of legitimate traffic.

For more information click here.

Varshini

Tamil has a great interest in the fields of Cyber Security, OSINT, and CTF projects. Currently, he is deeply involved in researching and publishing various security tools with Kali Linux Tutorials, which is quite fascinating.

Recent Posts

Awesome EDR Bypass : A Comprehensive Guide For Ethical Hackers

EDR bypass technology is not just for attackers. Many malware now have EDR bypass capabilities,…

7 hours ago

Better-Sliver : The Community-Driven Fork For Advanced Security Testing

Welcome to Better-Sliver, a fork of the Sliver project. This fork is intended to be…

7 hours ago

Fuzzing Lab : Mastering Software Testing Techniques With UCLA ACM Cyber

This is the repository for the Introduction to Fuzzing Lab run by ACM Cyber at…

8 hours ago

Apache HTTP Server Vulnerability Testing Tool

This repository provides a Proof of Concept (PoC) for testing various vulnerabilities in the Apache…

8 hours ago

Wez’s Terminal : A Rust-Powered GPU-Accelerated Terminal Emulator

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust Getting…

2 days ago

AutorizePro : Revolutionizing Authorization Testing With AI

一句话介绍工具: AutorizePro 是一款创新性的内置AI分析模块的专注于越权检测的 Burp 插件 (已有多个白帽反馈用工具嘎嘎挖到src洞, 每周末更新, 欢迎Star🌟以便持续跟踪项目最新版本功能) 工具背景 越权漏洞在黑盒测试、SRC挖掘中几乎是必测的一项,但手工逐个测试越权漏洞往往会耗费大量时间。 而自动化工具又因为接口的多样化,难以制定一个全面的检测逻辑而存在大量误报, 基于此产生了 AI辅助分析的检测工具 ➡️ AutorizePro…

2 days ago