Linux Intrusion Analysis
Overview
This workflow provides a structured methodology for investigating Linux system compromises. Commands can be executed during live response or adapted for post-compromise disk analysis by prepending the mount path (e.g., cat /media/compromised_disk/var/log/auth.log).
Investigation Phases:
Preparation & Scoping
Live Response & Triage
Evidence Collection
Analysis & Investigation
Remediation & Reporting
Phase 1: Preparation & Scoping
Initial Assessment Questions
Before beginning technical investigation, establish:
What triggered the investigation? (Alert, user report, external notification)
What is the suspected timeframe of compromise?
What is the system's role? (Web server, database, workstation, etc.)
What level of access does the attacker potentially have?
Are there compliance/legal requirements for evidence handling?
Documentation Setup
Phase 2: Live Response & Triage
CRITICAL: Execute live response commands before any remediation. Volatile data disappears on reboot or process termination.
2.1 System Information Collection
General System Information
Environment and Initialisation
2.2 Network Connections Analysis
Active Connections
Network Configuration
DNS and Domain Information
2.3 User and Account Analysis
Current Session Information
Account Enumeration
SSH Analysis
2.4 Process Analysis
Process Enumeration
Suspicious Process Investigation
Binary Recovery and Analysis
2.5 Scheduled Tasks Analysis
Cron Jobs
Systemd Timers
At Jobs
2.6 Persistence Mechanism Analysis
Services and Systemd
Init Scripts and RC
Shell Initialisation Files
PAM Configuration
MOTD Scripts
LD_PRELOAD Hijacking
2.7 Webshell Detection
2.8 File System Analysis
Suspicious Files and Directories
File Timeline Analysis
Package and Binary Analysis
2.9 Kernel and Module Analysis
2.10 Command History Analysis
2.11 System Resource Anomalies
Phase 3: Evidence Collection
3.1 Live Response Data Export
3.2 Disk Imaging
3.3 Memory Acquisition
Using AVML (Microsoft)
Using LiME
Phase 4: Analysis & Investigation
4.1 Log Analysis
Authentication Logs
System Logs
Web Server Logs
Application Logs
4.2 Artifact Analysis
Decode Suspicious Content
File Analysis
4.3 Memory Analysis with Volatility
4.4 Disk Analysis
Mount Disk Image
File System Analysis with Sleuth Kit
Timeline Generation with Plaso
4.5 File Recovery
Using debugfs (ext3/4)
Using ext4magic
Using PhotoRec
4.6 Automated Scanning
THOR Lite (Compromise Assessment)
Rootkit Detection
ClamAV Scan
Phase 5: Privilege Escalation Hunting
Indicators of Privilege Escalation Attempts
Phase 6: Reporting
Investigation Report Structure
IOC Export Format
Quick Reference Commands
Network
All connections
ss -tulpan
Established only
ss -tan state established
Listening ports
ss -tlnp
By process
lsof -i -P -n
Processes
Process tree
ps auxf
Deleted binaries
ls -la /proc/*/exe 2>/dev/null | grep deleted
High CPU
ps aux --sort=-%cpu | head -10
Process details
cat /proc/<PID>/cmdline status maps
Files
Modified today
find / -mtime -1 -type f -ls 2>/dev/null
SUID files
find / -perm -4000 -type f -ls 2>/dev/null
Hidden files
find / -name ".*" -type f 2>/dev/null
Webshells
grep -r -l "eval|base64_decode|shell_exec" /var/www/
Persistence
Cron jobs
cat /etc/crontab; ls /etc/cron.*
Services
systemctl list-unit-files --state=enabled
Authorized keys
find / -name authorized_keys -exec cat {} \;
Shell configs
cat /etc/profile ~/.bashrc ~/.profile
Tool Quick Install
References
Last updated