In this section
LX0.5 The Attacker's Perspective
Why Attackers Target Linux — and What They Do When They Get In
Why Linux Gets Compromised
Linux has a reputation for security that is partially earned and partially mythological. The earned part: Linux's permission model, mandatory access control frameworks (SELinux, AppArmor), and open-source visibility make it possible to build extremely hardened systems. The mythological part: the assumption that Linux does not get compromised because it is inherently more secure than Windows.
The reality in production environments is different. Linux servers get compromised for reasons that have nothing to do with the operating system's theoretical security model and everything to do with how they are deployed and managed in practice.
# Trace the attacker's typical post-exploitation workflow
# Each command checks for evidence of a specific attack phase
# Phase 1: Initial access — how did they get in?
grep -E "Accepted|Failed" /var/log/auth.log | tail -30
# Brute force: hundreds of "Failed" then one "Accepted"
# Stolen credentials: "Accepted password" from unusual IP/geolocation
# Phase 2: Reconnaissance — what did they look for?
grep -E "whoami|id|uname|ifconfig|ip addr|cat /etc/passwd" /home/*/.bash_history /root/.bash_history 2>/dev/null
# Standard recon: whoami → id → uname -a → ip addr → cat /etc/passwd
# Phase 3: Persistence — how did they stay?
find /etc/systemd/system/ -name "*.service" -newer /etc/os-release 2>/dev/null
find /home /root -name "authorized_keys" -newer /etc/os-release 2>/dev/null
# Services or SSH keys created AFTER OS install = suspicious
# Phase 4: Objective indicators
ss -tnp | grep -E ":3333|:4444|:8333|:14444" # Mining pool ports
find /tmp /dev/shm -name "*.tar*" -o -name "*.zip" 2>/dev/null # Data stagingMyth: "Linux servers are targeted less frequently than Windows, so they need less monitoring."
Reality: Linux runs 96% of the world's top 1 million web servers, the majority of cloud infrastructure, and nearly all container workloads. The perception that Linux is "less targeted" comes from lower visibility — most Linux servers lack EDR agents and centralized logging. Servers are compromised at comparable rates; the compromises are detected less often and later. Cryptomining campaigns specifically target Linux because always-on, high-CPU servers are ideal for mining — and the absence of monitoring means miners run undetected for weeks.
Decision points: predicting the next attack phase
If you have identified initial access, predict the next steps: SSH brute force → check authorized_keys + bash history + /tmp for tools. Web exploit → check web root for web shells + process tree for reverse shells + privesc to root. Stolen cloud creds → check CloudTrail for API calls + new IAM roles + lateral movement to other resources.
Troubleshooting: when the attacker's workflow is unclear
No bash history and no auditd. Pivot to: filesystem timestamps (find -mtime), package manager logs, network connections, /proc enumeration.
Multiple persistence mechanisms found. Attackers deploy redundant persistence — document ALL before recommending eradication. Missing one means the attacker returns.
Try it yourself
Exercise
On a Linux system, run the attacker workflow trace commands from the code block above. Check whether your system has evidence of reconnaissance commands in any user's bash history. Check whether any systemd services or authorized_keys files were created after the OS installation. Check for outbound connections on common mining pool ports. You are practicing the same evidence checks you will use in every investigation scenario in this course.
Beyond this investigation
The attacker perspective in this subsection frames every investigation scenario in the course. LX4 (SSH Brute Force) follows the exact initial access → reconnaissance → persistence → objective pattern described here. LX5 (Web Application Compromise) shows how the attacker workflow differs when the entry point is a web vulnerability rather than SSH. LX7 (Persistence Mechanisms) catalogs every persistence technique the attacker's playbook includes — SSH keys, cron jobs, systemd services, PAM backdoors, kernel modules. LX13 (Malware Analysis) examines the tools the attacker deploys after gaining access. Understanding the attacker's workflow is not academic — it is the investigation roadmap.
2. An attacker gains access via SSH brute force, deploys an SSH key for persistence, and then truncates auth.log. What evidence of their activity still exists? 3. What reconnaissance commands does a typical attacker run immediately after gaining access, and where might the evidence of these commands be found? 4. Why is the absence of an EDR agent on a Linux server both a disadvantage for detection and a non-issue for investigation methodology?
Interactive lab: your first Linux investigation
Before diving into the methodology, try investigating a real compromise. This SSH brute force scenario gives you a terminal where you can run investigation commands and examine the evidence. Type help if you get stuck.
You are investigating a Linux server and discover evidence of both a cryptominer (resource abuse) and an SSH key theft (lateral movement preparation). The cryptominer is consuming 95% CPU and impacting production. Which do you address first?
Address the lateral movement first. The cryptominer is visible, noisy, and contained to this server — it is causing performance impact but not spreading. The SSH key theft is silent, potentially already exploited, and may have given the attacker access to additional servers. Contain the lateral movement risk: rotate the stolen SSH keys, check the target servers for unauthorized access, and apply network restrictions. Then address the cryptominer: kill the process, remove the binary and persistence mechanisms. Prioritizing the noisy but contained threat over the silent but spreading threat is the most common Linux IR prioritization mistake.
Get weekly detection and investigation techniques
KQL queries, detection rules, and investigation methods — the same depth as this course, delivered every Tuesday.
No spam. Unsubscribe anytime. ~2,000 security practitioners.