Analyzing Linux Kernel Rootkits
Overview
Linux kernel rootkits operate at ring 0, modifying kernel data structures to hide processes, files, network connections, and kernel modules from userspace tools. Detection requires either memory forensics (analyzing physical memory dumps with Volatility3) or cross-view analysis (comparing /proc, /sys, and kernel data structures for inconsistencies). This skill covers using Volatility3 Linux plugins to detect syscall table hooks, hidden kernel modules, and modified function pointers, supplemented by live system scanning with rkhunter and chkrootkit.
When to Use
Trigger phrases:
"analyzing linux kernel rootkits"
"Detect kernel-level rootkits in Linux memory dumps using Volatility3 linux plugi"
When investigating security incidents that require analyzing linux kernel rootkits
When building detection rules or threat hunting queries for this domain
When SOC analysts need structured procedures for this analysis type
When validating security monitoring coverage for related attack techniques
Prerequisites
- Volatility3 installed (pip install volatility3)
- Linux memory dump (acquired via LiME, AVML, or /proc/kcore)
- Volatility3 Linux symbol table (ISF) matching the target kernel version
- rkhunter and chkrootkit for live system scanning
- Reference known-good kernel image for comparison
Steps
- Scope the task — define objectives, boundaries, and success criteria
- Gather information — collect all necessary data and context before proceeding
- Execute the core workflow — follow the domain-specific steps methodically
- Validate results — verify outputs against expected outcomes or baselines
- Document findings — record results, anomalies, and recommendations
Step 1: Acquire Memory Dump
Capture Linux physical memory using LiME kernel module or AVML for cloud instances.
Step 2: Analyze with Volatility3
Run linux.check_syscall, linux.lsmod, linux.hidden_modules, and linux.check_idt plugins to detect rootkit artifacts.
Step 3: Cross-View Analysis
Compare module lists from /proc/modules, lsmod, and /sys/module to identify modules hidden from one view but present in another.
Step 4: Live System Scanning
Run rkhunter and chkrootkit to detect known rootkit signatures, suspicious files, and modified system binaries.
Expected Output
JSON report containing detected syscall hooks, hidden kernel modules, modified IDT entries, suspicious /proc discrepancies, and rkhunter findings.
Example Output
$ sudo python3 rootkit_analyzer.py --memory /evidence/linux-mem.lime --profile Ubuntu2204
Linux Kernel Rootkit Analysis Report
=====================================
Memory Image: /evidence/linux-mem.lime
Kernel Version: 5.15.0-91-generic (Ubuntu 22.04 LTS)
Analysis Time: 2024-01-18 09:15:32 UTC
[+] Scanning syscall table for hooks...
Syscall Table Base: 0xffffffff82200300
Total syscalls checked: 449
HOOKED SYSCALLS DETECTED:
┌─────────┬──────────────────┬──────────────────────┬──────────────────────┐
│ NR │ Syscall │ Expected Address │ Current Address │
├─────────┼──────────────────┼──────────────────────┼──────────────────────┤
│ 0 │ sys_read │ 0xffffffff8139a0e0 │ 0xffffffffc0a12000 │
│ 2 │ sys_open │ 0xffffffff8139b340 │ 0xffffffffc0a12180 │
│ 78 │ sys_getdents64 │ 0xffffffff813f5210 │ 0xffffffffc0a12300 │
│ 62 │ sys_kill │ 0xffffffff8110c4a0 │ 0xffffffffc0a12480 │
└─────────┴──────────────────┴──────────────────────┴──────────────────────┘
WARNING: 4 syscall hooks detected - rootkit behavior confirmed
[+] Checking for hidden kernel modules...
Loaded modules (lsmod): 147
Modules in kobject list: 149
HIDDEN MODULES:
- "netfilter_helper" at 0xffffffffc0a10000 (size: 12288)
- "kworker_sched" at 0xffffffffc0a14000 (size: 8192)
[+] Scanning /proc for discrepancies...
Processes in task_struct list: 234
Processes visible in /proc: 231
HIDDEN PROCESSES:
- PID 31337 cmd: "[kworker/0:3]" (disguised as kernel thread)
- PID 31442 cmd: "rsyslogd" (fake, real rsyslogd is PID 892)
- PID 31500 cmd: "" (unnamed process)
[+] Checking IDT entries...
IDT entries scanned: 256
Modified entries: 0 (clean)
[+] Running rkhunter scan...
Checking for known rootkits: 68 variants checked
Diamorphine rootkit: WARNING - signatures match
System binary checks:
/usr/bin/ps: MODIFIED (SHA-256 mismatch)
/usr/bin/netstat: MODIFIED (SHA-256 mismatch)
/usr/bin/ls: MODIFIED (SHA-256 mismatch)
/usr/sbin/ss: OK
[+] Network analysis...
Hidden connections (not in /proc/net/tcp):
ESTABLISHED 0.0.0.0:0 -> 198.51.100.47:4443 (PID 31337)
ESTABLISHED 0.0.0.0:0 -> 198.51.100.47:8080 (PID 31442)
Summary:
Rootkit Type: Loadable Kernel Module (LKM)
Probable Family: Diamorphine variant
Syscall Hooks: 4 (read, open, getdents64, kill)
Hidden Modules: 2
Hidden Processes: 3
Hidden Connections: 2 (C2: 198.51.100.47)
Modified Binaries: 3 (/usr/bin/ps, netstat, ls)
Risk Level: CRITICAL
When NOT to Use
- You need to perform the attack, not analyze it (use performing-* skills)
- Task is about detection, not analysis (use detecting-* skills)
- You need to implement controls (use implementing-* skills)
- Task is about threat hunting, not post-incident analysis (use hunting-* skills)
- You don't have access to the artifacts/logs to analyze
- Task requires real-time monitoring (use SOC tools)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Failing to use write-blockers when acquiring forensic evidence
- Not verifying hash integrity before and after imaging
- Modifying original evidence during analysis
Process
- Scope — Define research questions, identify data sources, set time boundaries
- Gather — Collect data from primary sources, APIs, and public records
- Synthesize — Analyze findings, identify patterns, produce actionable report
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Hash values computed and verified match between source and image
- Chain of custody log complete with timestamps and examiner names
- Analysis tools and versions documented for reproducibility
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: analyzing-linux-kernel-rootkits3description: Use when detect kernel-level rootkits in Linux memory dumps using Volatility3 linux plugins (check_syscall, lsmod, hidden_modules), rkhunter system scanning, and /proc vs /sys discrepancy analysis to identify hooked syscalls, hidden kernel modules, and tampered system structures. Use when detecting kernel-level rootkits in linux memory dumps using volatility3 linux.4license: Apache-2.05---678# Analyzing Linux Kernel Rootkits910## Overview1112Linux kernel rootkits operate at ring 0, modifying kernel data structures to hide processes, files, network connections, and kernel modules from userspace tools. Detection requires either memory forensics (analyzing physical memory dumps with Volatility3) or cross-view analysis (comparing /proc, /sys, and kernel data structures for inconsistencies). This skill covers using Volatility3 Linux plugins to detect syscall table hooks, hidden kernel modules, and modified function pointers, supplemented by live system scanning with rkhunter and chkrootkit.131415## When to Use16**Trigger phrases:**17- "analyzing linux kernel rootkits"18- "Detect kernel-level rootkits in Linux memory dumps using Volatility3 linux plugi"192021- When investigating security incidents that require analyzing linux kernel rootkits22- When building detection rules or threat hunting queries for this domain23- When SOC analysts need structured procedures for this analysis type24- When validating security monitoring coverage for related attack techniques2526## Prerequisites2728- Volatility3 installed (pip install volatility3)29- Linux memory dump (acquired via LiME, AVML, or /proc/kcore)30- Volatility3 Linux symbol table (ISF) matching the target kernel version31- rkhunter and chkrootkit for live system scanning32- Reference known-good kernel image for comparison3334## Steps35361. **Scope the task** — define objectives, boundaries, and success criteria372. **Gather information** — collect all necessary data and context before proceeding383. **Execute the core workflow** — follow the domain-specific steps methodically394. **Validate results** — verify outputs against expected outcomes or baselines405. **Document findings** — record results, anomalies, and recommendations41### Step 1: Acquire Memory Dump42Capture Linux physical memory using LiME kernel module or AVML for cloud instances.4344### Step 2: Analyze with Volatility345Run linux.check_syscall, linux.lsmod, linux.hidden_modules, and linux.check_idt plugins to detect rootkit artifacts.4647### Step 3: Cross-View Analysis48Compare module lists from /proc/modules, lsmod, and /sys/module to identify modules hidden from one view but present in another.4950### Step 4: Live System Scanning51Run rkhunter and chkrootkit to detect known rootkit signatures, suspicious files, and modified system binaries.5253## Expected Output5455JSON report containing detected syscall hooks, hidden kernel modules, modified IDT entries, suspicious /proc discrepancies, and rkhunter findings.5657## Example Output5859```text60$ sudo python3 rootkit_analyzer.py --memory /evidence/linux-mem.lime --profile Ubuntu22046162Linux Kernel Rootkit Analysis Report63=====================================64Memory Image: /evidence/linux-mem.lime65Kernel Version: 5.15.0-91-generic (Ubuntu 22.04 LTS)66Analysis Time: 2024-01-18 09:15:32 UTC6768[+] Scanning syscall table for hooks...69 Syscall Table Base: 0xffffffff8220030070 Total syscalls checked: 4497172 HOOKED SYSCALLS DETECTED:73 ┌─────────┬──────────────────┬──────────────────────┬──────────────────────┐74 │ NR │ Syscall │ Expected Address │ Current Address │75 ├─────────┼──────────────────┼──────────────────────┼──────────────────────┤76 │ 0 │ sys_read │ 0xffffffff8139a0e0 │ 0xffffffffc0a12000 │77 │ 2 │ sys_open │ 0xffffffff8139b340 │ 0xffffffffc0a12180 │78 │ 78 │ sys_getdents64 │ 0xffffffff813f5210 │ 0xffffffffc0a12300 │79 │ 62 │ sys_kill │ 0xffffffff8110c4a0 │ 0xffffffffc0a12480 │80 └─────────┴──────────────────┴──────────────────────┴──────────────────────┘81 WARNING: 4 syscall hooks detected - rootkit behavior confirmed8283[+] Checking for hidden kernel modules...84 Loaded modules (lsmod): 14785 Modules in kobject list: 14986 HIDDEN MODULES:87 - "netfilter_helper" at 0xffffffffc0a10000 (size: 12288)88 - "kworker_sched" at 0xffffffffc0a14000 (size: 8192)8990[+] Scanning /proc for discrepancies...91 Processes in task_struct list: 23492 Processes visible in /proc: 23193 HIDDEN PROCESSES:94 - PID 31337 cmd: "[kworker/0:3]" (disguised as kernel thread)95 - PID 31442 cmd: "rsyslogd" (fake, real rsyslogd is PID 892)96 - PID 31500 cmd: "" (unnamed process)9798[+] Checking IDT entries...99 IDT entries scanned: 256100 Modified entries: 0 (clean)101102[+] Running rkhunter scan...103 Checking for known rootkits: 68 variants checked104 Diamorphine rootkit: WARNING - signatures match105 System binary checks:106 /usr/bin/ps: MODIFIED (SHA-256 mismatch)107 /usr/bin/netstat: MODIFIED (SHA-256 mismatch)108 /usr/bin/ls: MODIFIED (SHA-256 mismatch)109 /usr/sbin/ss: OK110111[+] Network analysis...112 Hidden connections (not in /proc/net/tcp):113 ESTABLISHED 0.0.0.0:0 -> 198.51.100.47:4443 (PID 31337)114 ESTABLISHED 0.0.0.0:0 -> 198.51.100.47:8080 (PID 31442)115116Summary:117 Rootkit Type: Loadable Kernel Module (LKM)118 Probable Family: Diamorphine variant119 Syscall Hooks: 4 (read, open, getdents64, kill)120 Hidden Modules: 2121 Hidden Processes: 3122 Hidden Connections: 2 (C2: 198.51.100.47)123 Modified Binaries: 3 (/usr/bin/ps, netstat, ls)124 Risk Level: CRITICAL125```126## When NOT to Use127128- You need to perform the attack, not analyze it (use performing-* skills)129- Task is about detection, not analysis (use detecting-* skills)130- You need to implement controls (use implementing-* skills)131- Task is about threat hunting, not post-incident analysis (use hunting-* skills)132- You don't have access to the artifacts/logs to analyze133- Task requires real-time monitoring (use SOC tools)134135136## Red Flags137138- Performing actions without explicit written authorization from the asset owner139- Testing against production systems without a defined scope and rules of engagement140- Failing to use write-blockers when acquiring forensic evidence141- Not verifying hash integrity before and after imaging142- Modifying original evidence during analysis143144## Process1451461. **Scope** — Define research questions, identify data sources, set time boundaries1471. **Gather** — Collect data from primary sources, APIs, and public records1481. **Synthesize** — Analyze findings, identify patterns, produce actionable report149150## Verification151152- All steps executed successfully against a test environment before production use153- Output documented with screenshots or logs demonstrating expected behavior154- Hash values computed and verified match between source and image155- Chain of custody log complete with timestamps and examiner names156- Analysis tools and versions documented for reproducibility157158## Anti-Rationalization Table159160| Rationalization | Reality |161|---|---|162| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |163| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |164| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |