How gwillgues/bpfdoor works
Project type and purpose
• This is a small, single‐file C project—bpfdoor.c—which implements a BPF‐based backdoor or “door” into the Linux kernel. It consists of one user‐space loader (the same C binary) and a BPF program that gets injected into the kernel at runtime.
• The README says “BPFDoor Source Code… originally from Chinese Threat Actor Red Menshen,” so the purpose is to stealthily load a BPF filter that acts as a covert listening backdoor.
File structure
• Top‐level files:
• README.md – project description
• bpfdoor.c – the only source file, containing both user‐space and embedded BPF code
• There are no separate “frontend,” “backend,” “lib,” or “tests” folders. All logic lives in bpfdoor.c.
• Look for sections in the C file that separate:
a. User‐space code (parsing flags, setting up socket, loading the BPF bytecode via bpf() syscall)
b. BPF program definitions (often marked by SEC("…") or raw BPF instruction arrays)
c. Attachment points (e.g., socket filters, kprobe, tracepoint)
README for additional insights
• We must infer from bpfdoor.c: likely uses libc (or libbpf) to open a raw socket, call bpf() to load and attach, then loop waiting for command packets.
Elements
– “Attacker Remote Client” (External)
– “Network Interface”
– “eBPF Program (in‐kernel)”
– “User‐Space Loader (bpfdoor)”
– “Kernel BPF Subsystem”
– “magic UDP/TCP packets” → BPF Program
– “bpf() syscall” → Kernel BPF Subsystem
– “shell command results” ← User‐Space Loader
– Blue for user‐space
– Green for in‐kernel BPF
– Grey for external systems