Lab 17: Lateral Movement & Persistence

Objective

Simulate post-exploitation techniques inside a compromised Linux environment:

  1. SSH key implantation — plant an attacker-controlled SSH key to maintain persistent access without a password

  2. Backdoor user creation — create a hidden system user for re-entry after a password change

  3. Cron-based persistence — install a cron job that calls home every minute

  4. Environment hijacking — plant a malicious command in .bashrc and PATH to execute on every login

  5. Detection — identify the indicators of compromise left by each technique


Background

Persistence is what separates a one-time access event from a long-term breach. Attackers install multiple persistence mechanisms simultaneously — so that patching one doesn't evict them. Lateral movement spreads the compromise to other systems using credentials or trust relationships.

Real-world examples:

  • SolarWinds 2020 — SUNBURST maintained persistence via a scheduled task named SolarWinds.Orion.Core.BusinessLayer.dll; disguised as a legitimate software update mechanism. Dwell time: 9+ months undetected.

  • 2022 Uber breach — attacker gained VPN access, then used stolen credentials to pivot from contractor laptop to internal admin tools. SSH keys found planted in 5+ internal bastion hosts.

  • Operation Aurora (Google, 2010) — APT attackers used compromised IE zero-day for initial access, then planted registry run keys + remote access trojans on 20+ Google systems before discovery.

  • 2021 Microsoft Exchange (Hafnium) — after initial RCE, attackers planted web shells in multiple directories as backup persistence in case the primary exploit was patched.

MITRE ATT&CK: T1098.004 (SSH Auth Keys), T1136 (Create Account), T1053 (Scheduled Task), T1546 (Event Triggered Execution)


Architecture

Time

40 minutes


Lab Instructions

Step 1: Setup — Start as Root (Post-Exploitation)


Step 2: Technique 1 — SSH Key Implantation

📸 Verified Output:


Step 3: Technique 2 — Hidden Backdoor User


Step 4: Technique 3 — Cron-Based Callback


Step 5: Technique 4 — .bashrc / PATH Hijacking


Step 6: Technique 5 — Web Shell (if web server exists)


Steps 7–8: Indicator of Compromise Detection + Cleanup


Remediation

  • SSH keys: Regular audit of ~/.ssh/authorized_keys against approved key inventory; alert on changes via file integrity monitoring (FIM)

  • User accounts: Alert on useradd with UID 0; review /etc/passwd for unexpected accounts; disable root login

  • Cron: Monitor /etc/cron.d/, /var/spool/cron/, crontab -l for all users; alert on new entries

  • Bashrc: FIM on all .bashrc/.profile/.bash_profile files; immutable flag (chattr +i) on skel files

  • Web shells: Regular find scans for newly modified PHP/ASPX/JSP files; WAF rules for shell command patterns

Further Reading

Last updated