Attack Residues

Attack Residues

One-liner: Traces, artifacts, and remnants left behind by attackers during or after an intrusion that can be used to detect, investigate, or hunt for malicious activity.

🎯 What Is It?

Attack Residues are the forensic breadcrumbs that adversaries leave behind when operating in an environment. These include IOCs, IOAs, log entries, file system artifacts, memory artifacts, and network traces that persist after an attack.

Unlike clean, stealthy operations attackers aspire to, reality means they leave traces—and these residues are what defenders hunt for.

🤔 Why It Matters

🔬 How It Works

Core Principles

  1. Attackers Can't Be Perfect: Even advanced adversaries leave traces
  2. Residues Blend with Noise: Separating malicious from benign requires environmental knowledge
  3. Time-Sensitive: Some residues are ephemeral (memory, volatile logs)
  4. Context Matters: Same artifact may be normal or malicious depending on context

The Attack Residue Lifecycle

[Attack Occurs]
    ↓
[Residues Created]
├─ Files written/modified
├─ Registry keys changed
├─ Network connections
├─ Process execution
├─ Log entries
└─ Memory artifacts
    ↓
[Detection Window]
├─ Real-time (seconds-minutes)
├─ Short-term (hours-days)
└─ Long-term (weeks-months)
    ↓
[Residue Cleanup or Decay]
├─ Attacker cleanup
├─ Log rotation
├─ System reboots
└─ Overwritten data

📊 Types of Attack Residues

Residue Type Description Examples Persistence
Network Traffic patterns and connections C2 traffic, DNS queries, lateral movement Depends on log retention
File System Files created, modified, or deleted Malware binaries, scripts, stolen data Until deleted/overwritten
Registry Windows Registry changes Persistence keys, configuration Until modified/deleted
Logs Event logs and application logs Failed logins, privilege escalation Log retention period
Memory RAM artifacts Injected code, process memory Until reboot
Authentication Login and credential artifacts Ticket-granting tickets, hashes Session duration/cache
Scheduled Tasks Persistence mechanisms Malicious cron jobs, scheduled tasks Until removed

🛡️ Detection & Prevention

How to Detect Attack Residues

1. File System Artifacts

# Linux: Check for suspicious files
find / -type f -mtime -7 -name "*.sh" -o -name "*.py"

# Windows: PowerShell for recent executables
Get-ChildItem -Path C:\ -Recurse -Include *.exe | 
  Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-7)}

2. Registry Persistence (Windows)

# Check common persistence locations
Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"

3. Network Residues

# Check for suspicious connections
netstat -antp | grep ESTABLISHED

# DNS query logs (if available)
grep -i "malicious-domain.com" /var/log/dns.log

4. Log Analysis

# Failed authentication attempts (Linux)
grep "Failed password" /var/log/auth.log | tail -20

# Windows Event Logs (PowerShell)
Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4625} -MaxEvents 50

How to Hunt for Attack Residues

Intelligence-Driven Hunting:

Hypothesis-Driven Hunting:

Hypothesis: "Attacker used WMI for lateral movement"

Expected Residues:
├─ WMI event logs (Event ID 5857, 5858, 5859)
├─ wmic.exe process executions
├─ wmiprvse.exe network connections
└─ Suspicious WMI persistence (root\subscription)

Hunt Queries:
- Check WMI event logs for remote execution
- Analyze wmic.exe command-line arguments
- Review network connections from wmiprvse.exe

Challenges in Finding Attack Residues

  1. Normal vs Malicious: Legitimate tools used maliciously (Living Off the Land)
  2. Attacker Cleanup: Sophisticated adversaries delete logs and artifacts
  3. Log Gaps: Insufficient logging coverage
  4. Volatile Artifacts: Memory and ephemeral residues disappear quickly
  5. Encryption: Encrypted C2 traffic hides network residues

🎤 Interview Angles

Common Questions

STAR Story

Situation: Our organization experienced a security alert for suspicious PowerShell activity, but initial triage found nothing conclusive. However, the timing was suspicious.
Task: Conduct a thorough hunt for attack residues to determine if a breach had occurred and been partially cleaned up.
Action: Reviewed PowerShell Operational logs for script block logging (Event ID 4104) and found obfuscated code that had been executed 3 days prior. Pivoted to that timeframe—discovered registry persistence keys, scheduled tasks, and deleted files in recycle bin. Found C2 domain in web proxy logs that aligned with the PowerShell execution. Cross-referenced with threat intel—matched known APT29 TTPs.
Result: Confirmed active breach with 3-day Dwell Time. Escalated to Incident Response. Contained the threat, removed persistence mechanisms, and created 8 new detection rules based on discovered attack residues to prevent future similar intrusions.

✅ Best Practices

❌ Common Misconceptions

📚 References