courses

Host Security and the Attack Lifecycle

From a foothold to total control

The social-engineering page ends where this one begins: an attacker has tricked someone, exploited a service, or stolen a credential and now has a foothold — code running on one host as one user. A single unprivileged shell is rarely the goal. What turns a foothold into a breach is everything the attacker does next: escalating privilege, looking around, stealing credentials, spreading to other machines, establishing persistence, and finally acting on their objective (stealing data, deploying ransomware).

That sequence is the attack lifecycle, and host security is the discipline of detecting and disrupting it at every step. The key defensive insight is that a competent attacker must complete many steps, each of which can be observed or blocked. You do not have to stop the initial break-in perfectly (you won’t); you have to make sure that the dozen actions that follow leave evidence and hit walls. That is defense in depth on the host.

This page uses Linux for the worked examples (the course VM), but the lifecycle is platform-independent.

The map: MITRE ATT&CK tactics

The industry-standard model of the lifecycle is the MITRE ATT&CK framework, which organizes real-world adversary behavior into tactics (the attacker’s goal at each stage) and techniques (the specific how). The ATT&CK reference page covers the framework itself; here are the enterprise tactics in roughly the order an intrusion moves through them:

Tactic The attacker’s goal Example on a host
Reconnaissance (TA0043) Gather target info before attacking OSINT, port scanning (recon)
Resource Development (TA0042) Build/acquire infrastructure Register domains, buy a VPS, build malware
Initial Access (TA0001) Get in Phishing, exploit a public service, valid accounts
Execution (TA0002) Run their code Malicious script, scheduled task, interpreter abuse
Persistence (TA0003) Survive reboots & logouts cron job, systemd unit, SSH key, new account
Privilege Escalation (TA0004) Become root/admin SUID abuse, sudo misconfig, kernel exploit
Defense Evasion (TA0005) Avoid detection Clear logs, disable auditd, masquerade as system processes
Credential Access (TA0006) Steal secrets Dump /etc/shadow, scrape memory, read SSH keys
Discovery (TA0007) Map the environment Enumerate users, network, running services
Lateral Movement (TA0008) Reach other hosts SSH with stolen keys, pass-the-hash
Collection (TA0009) Gather target data Stage files, capture keystrokes
Command and Control (TA0011) Remote-control the host Beacon to an external C2 server
Exfiltration (TA0010) Steal the data out Upload over HTTPS/DNS to attacker infra
Impact (TA0040) Achieve the end goal Encrypt (ransomware), destroy, manipulate

You do not need to memorize the IDs. The point is the shape: intrusions are a chain, and each link is a detection-and-prevention opportunity.

Host attacks, step by step

Initial access and execution

The attacker arrives via one of a handful of doors: a phishing payload, an exploited internet-facing service, a stolen credential, or a malicious supply-chain dependency. However they get in, they then need to execute code — drop a script, spawn a reverse shell, abuse a built-in interpreter (Python, PowerShell, bash). “Living off the land” (using tools already on the box) is favored precisely because it blends in.

Discovery and internal recon

A careful attacker’s first move on a new host is to look around — quietly. This is the on-host counterpart to network recon:

$ id; whoami                      # who am I, what groups
$ uname -a; cat /etc/os-release   # kernel & distro (→ which exploits apply)
$ sudo -l                         # what can I run as root WITHOUT a password?
$ ps aux; ss -tulpn               # running services & listening ports
$ ls -la /home/*; cat /etc/passwd # other users and accounts

sudo -l is the single highest-value command: a misconfigured sudoers entry is the most common clean path to root.

Privilege escalation

Escalation is, at its core, a failure of least privilege — the attacker finds something more powerful than it should be. The classic Linux hunting grounds:

# SUID binaries: run as their owner (often root) regardless of caller.
# A SUID binary that can spawn a shell or write files = instant root.
$ find / -perm -4000 -type f 2>/dev/null
/usr/bin/passwd          # expected
/usr/bin/find            # NOT expected — find can run commands → root shell

# World-writable files owned by root, weak service unit perms, etc.
$ find / -writable -type f 2>/dev/null | grep -vE '^/proc|^/sys'

Other common vectors: passwordless sudo entries, writable cron scripts running as root, a vulnerable setuid program (memory corruption), an exposed kernel exploit, or secrets sitting in a readable config file. Tools like LinPEAS and linux-smart-enumeration automate this entire sweep — defenders run them too, to find the holes first.

Credential access

With or without root, stealing credentials lets the attacker expand and persist. On Linux: reading /etc/shadow (root only — the hashes then go to hashcat/john), harvesting SSH private keys from ~/.ssh/, scraping passwords from history files, config files, and environment variables, or dumping process memory.

Persistence

The attacker wants to survive a reboot or a password reset. Every persistence mechanism is something a defender can enumerate and monitor:

# cron — a job that re-establishes a backdoor every minute
$ crontab -l; ls -la /etc/cron.* /var/spool/cron/

# systemd — a malicious service or timer that starts at boot
$ systemctl list-units --type=service; ls -la /etc/systemd/system/

# an added SSH key = passwordless login forever
$ cat ~/.ssh/authorized_keys

# a new or modified account / a backdoored shell profile
$ cat /etc/passwd; ls -la ~/.bashrc ~/.profile

Lateral movement, collection, exfiltration, and impact

From one host the attacker pivots to others — reusing the SSH keys and passwords just stolen (lateral movement shows up in network flow data), collects the data they came for, exfiltrates it (often tunneled over HTTPS or DNS to evade egress filtering), and finally delivers impact: ransomware encryption, destruction, or quiet long-term espionage.

Host defenses

Defenses map onto the lifecycle: some prevent steps, some detect them, some limit the blast radius when prevention fails.

Reduce the attack surface (prevention)

Detection: signatures vs. anomalies

Two complementary philosophies underpin every detection tool:

The tools that implement these:

A practical Linux example — watch for tampering with the password file with the kernel audit system:

# Tell auditd to log every write/attribute change to /etc/passwd
$ sudo auditctl -w /etc/passwd -p wa -k passwd_changes

# Later, review what tripped the rule
$ sudo ausearch -k passwd_changes

This is a detective control implementing complete mediation over a sensitive object — the same reference-monitor idea from access control, applied as monitoring.

Allowlisting vs. blocklisting

Software signing and verified boot

Code signing lets a host verify that software genuinely comes from its claimed publisher and has not been tampered with — the digital-signature primitive applied to executables and packages (Linux package signing, Windows Authenticode, macOS notarization). Extended down the stack, Secure Boot and measured boot verify the bootloader and kernel before they run, resisting low-level persistence (bootkits/rootkits).

Isolation and recovery (limiting the blast radius)

When prevention and detection both fail, you are in incident response — containment, eradication, and recovery.

Key takeaways

References


Related course pages: MITRE ATT&CK Framework · Social Engineering · Access Control and Authorization · Memory Corruption · Suricata IDS/IPS · SIEM and SOC · Incident Response · Containerization

🛠️ Maintenance note: MITRE ATT&CK is versioned and revised periodically — re-verify the tactic list and any technique IDs against the current matrix each term. The enumeration commands (sudo -l, find -perm -4000, auditd) are stable, but confirm tool names (Wazuh, LinPEAS/PEASS-ng) haven’t moved repos.