Linux Rootkit Forensics: Advanced Detection & Analysis

62次阅读
没有评论

Rootkit Threat Landscape 2024

⚠️ 300% Increase in kernel-level rootkits since 2020 (CrowdStrike Threat Report)
⚠️ 57% evade traditional AV detection
⚠️ Average 278 days dwell time before discovery

Linux Rootkit Forensics: Advanced Detection & Analysis

Rootkit Classification Matrix

Type Detection Difficulty Persistence Mechanism Case Study
Kernel (LKM) ★★★★★ Kernel module loading Diamorphine
Userland ★★★☆☆ LD_PRELOAD hijacking Reptile
Memory-Resident ★★★★☆ Direct kernel object patching Suterusu
Firmware ★★★★★★ UEFI/ACPI implantation LoJax

Forensic Investigation Methodology

1. Live System Triage (Volatile Evidence)

<BASH># Check for anomalous kernel moduleslsmod | grep -Ev "$(cat /proc/modules | awk '{print $1}' | tr '\n' '|')"# Detect hidden processes (ps vs /proc comparison)diff <(ps -eF | awk '{print $2}') <(ls /proc | grep -E '^[0-9]+$')# Hunt for rootkit hooks - system call table checksudo cat /proc/kallsyms | grep -E 'sys_call_table|commit_creds' > /tmp/clean_syms

Pro Tip: Capture RAM immediately with:

<BASH>sudo dd if=/dev/mem bs=1M | gzip > /tmp/memdump_$(date +%s).gz

2. Filesystem Forensics

Malware Hunting Checklist:

<BASH># Modified binaries (compare against package manager)sudo rpm -Va | grep '^..5'  # RHELsudo dpkg-query -W -f='${Conffiles}\n' | awk 'MD5SUM {print $1}' | xargs md5sum  # Debian# Timestomping detectionsudo find / -type f -exec stat -c '%n %Y %y %z' {} + | awk '$2 != $3 || $3 != $4'

Rootkit Indicators:

  • /lib/modules/$(uname -r)/extra/ – Unofficial kernel modules
  • LD_PRELOAD entries in /etc/ld.so.preload
  • strace inconsistencies between privileged/unprivileged users

Advanced Detection Techniques

Kernel Integrity Verification

1. System Call Table Audit

<PYTHON>#!/usr/bin/python3import fcntl, sysTIOCGSERIAL = 0x541Ebad_syscalls = []try:    fcntl.ioctl(sys.stdin, TIOCGSERIAL, 0)except:    pass  # Expected failureelse:    bad_syscalls.append("sys_ioctl hook detected")

2. eBPF-Based Anomaly Detection

<C>// Detects hooked syscalls via kprobesSEC("kprobe/sys_execve")int kprobe_execve(struct pt_regs *ctx) {    u64 real = kallsyms_lookup_name("sys_execve");    if (PT_REGS_IP(ctx) != real) {        bpf_alert("SYSCALL_HOOK", "execve");    }    return 0;}

Memory Forensics with Volatility3

<BASH>volatility -f memory.dump linux.check_syscall --table sys_call_tablevolatility -f memory.dump linux.lsmod --verbosevolatility -f memory.dump linux.elfs --dump-dir ./malware_samples

Modern Rootkit Case Studies

1. Diamorphine (2023 Variant)

  • TTPs:
    • Uses nftables netlink sockets for C2
    • Patches kprobe_blacklist to block instrumentation
  • Detection:
<BASH>sudo cat /sys/kernel/debug/kprobes/blacklist | grep -iv 'kernel'

2. Reptile 2.0 (Userland)

  • Stealth Mechanisms:
    • Hijacks libc‘s readdir() via LD_PRELOAD
    • Masks network connections in /proc/net/tcp6
  • Forensic Signs:
<BASH>strace -e trace=openat ls /proc 2>&1 | grep -i "preload"

Mitigation Framework

Hardened System Configuration

<YAML># /etc/sysctl.d/99-antirootkit.confkernel.kptr_restrict = 2kernel.modules_disabled = 1  # For CRITICAL systemskernel.dmesg_restrict = 1kernel.unprivileged_bpf_disabled = 1

Runtime Protection Stack

  1. Lockdown Mode:
<BASH>echo integrity > /sys/kernel/security/lockdown
  1. eBPF Monitoring:
<BASH>sudo apt install bpfcc-toolssudo opensnoop-bpfcc -T 60 > io_monitor.log
  1. LSM Enforcement:
<BASH>echo "apparmor=1 security=apparmor" >> /boot/cmdline.txt

Forensic Toolchain

Tool Purpose Key Command
lynis Security auditing sudo lynis audit system
strace+ltrace System call tracing strace -f -e trace=file,process
ebpfmon Kernel hook detection sudo ebpfmon --hooks
Tripwire FIM (File Integrity Monitoring) sudo tripwire --check

📥 Download Our [Linux Rootkit DFIR Playbook]
▸ Includes YARA rules for common rootkits
Memory analysis cheat sheet
Kernel debug compilation guide

“Modern rootkits don’t hide – they impersonate. Finding them requires understanding both kernel internals and attacker tradecraft.”
— Dr. Anton Chuvakin, Google Cloud Security

<BASH># Verify running kernel against signed buildssudo cat /proc/version_signature | awk '{print $3}' | cmp --silent - <(apt-cache show linux-image-$(uname -r) | grep Version)
正文完
 0
评论(没有评论)