Fatskills
Practice. Master. Repeat.
Study Guide: CompTIA Security+ Malware Types - Zero-Fluff, Hands-On Guide
Source: https://www.fatskills.com/comptia-security-/chapter/tech-comptia-security-malware-types-zero-fluff-hands-on-guide

CompTIA Security+ Malware Types - Zero-Fluff, Hands-On Guide

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~9 min read

CompTIA Security+ Malware Types: Zero-Fluff, Hands-On Guide

(Ransomware, Trojans, Worms, Rootkits, Logic Bombs)


1. What This Is & Why It Matters

Malware is the #1 cause of security incidents in production environments. If you ignore it, you’re one click away from: - A $5M ransomware payout (or a career-ending breach). - A worm spreading across your cloud VPCs in minutes. - A rootkit hiding in your CI/CD pipeline, stealing API keys for months.

Real-world scenario: You’re a SOC analyst. At 3 AM, your SIEM alerts on unusual SMB traffic (port 445) from a developer’s laptop. Your boss asks: - "Is this ransomware? A worm? How do we stop it?" - "Could this be a Trojan from that ‘free’ IDE plugin the dev installed?" - "How do we know if it’s already in our Active Directory?"

If you can’t answer these instantly, you’re already behind. This guide gives you: ? Instant recognition of malware types (no theory—just what you’ll see in logs). ? CLI commands to detect and contain them. ? Checklists for incident response (IR) when the alarm goes off.


2. Core Concepts & Components

? Ransomware

  • Definition: Malware that encrypts files and demands payment (usually in crypto) for the decryption key.
  • Production insight:
  • #1 cause of downtime in enterprises (avg. 21 days to recover).
  • Double extortion: Attackers steal data before encrypting it—then threaten to leak it if you don’t pay.
  • Targets: Windows (SMB), Linux (NFS), cloud storage (S3, Azure Blob), databases (MongoDB, SQL Server).
  • Example strains: LockBit, REvil, Conti, BlackCat.

? Trojan (Trojan Horse)

  • Definition: Malware disguised as legitimate software (e.g., a "free" VPN, cracked game, or "urgent" PDF).
  • Production insight:
  • #1 delivery method: Phishing emails (e.g., "Your invoice is attached").
  • Backdoor access: Often installs a RAT (Remote Access Trojan) for persistent control.
  • Example strains: Emotet, TrickBot, QakBot.

? Worm

  • Definition: Self-replicating malware that spreads without user interaction (e.g., via network vulnerabilities).
  • Production insight:
  • Fastest-spreading malware type (can infect thousands of hosts in minutes).
  • Targets: Unpatched systems (e.g., EternalBlue for SMBv1), misconfigured cloud instances.
  • Example strains: WannaCry, NotPetya, Conficker.

Rootkit

  • Definition: Malware that hides its presence by modifying the OS (e.g., kernel, bootloader, or firmware).
  • Production insight:
  • Nearly undetectable by traditional AV (requires memory forensics or behavioral analysis).
  • Used for: Persistent access, data exfiltration, or hiding other malware (e.g., a rootkit hiding a RAT).
  • Example strains: Stuxnet (used rootkit to hide), Sony BMG rootkit (2005), Alureon.

? Logic Bomb

  • Definition: Malware that triggers on a condition (e.g., date, user action, or system event).
  • Production insight:
  • Often planted by insiders (e.g., a disgruntled employee).
  • Hard to detect—sits dormant until triggered (e.g., "Delete all files if my account is disabled").
  • Example: A logic bomb in a trading system that wipes databases at 3 PM on a Friday.

3. Step-by-Step Hands-On: Detect & Respond to Malware

Prerequisites

  • A Windows 10/11 VM (for ransomware/Trojan analysis) or Linux VM (for worm/rootkit analysis).
  • Sysinternals Suite (Windows) or Linux forensic tools (chkrootkit, rkhunter, volatility).
  • Wireshark (for network analysis).
  • A safe malware sample (e.g., from MalwareBazaaruse a VM!).

Step 1: Detect Ransomware (Windows)

Symptoms: - Files renamed with .lockbit, .revil, or .encrypted. - Ransom note (README.txt, DECRYPT-FILES.html) in every folder. - High CPU/disk usage (encryption in progress).

Commands to confirm:

# Check for suspicious processes (e.g., encrypting files)
Get-Process | Where-Object { $_.CPU -gt 50 } | Select-Object Name, CPU, Path

# Look for ransom notes
Get-ChildItem -Path C:\ -Recurse -Filter "*README*.txt" -ErrorAction SilentlyContinue

# Check for unusual SMB connections (ransomware spreads via SMB)
netstat -ano | findstr "445"

Containment steps:
1. Isolate the machine (unplug network cable or disable Wi-Fi).
2. Kill the malicious process (use taskkill /PID <ID> /F).
3. Restore from backups (if available—test backups first!).
4. Block known ransomware IPs in firewall: bash # Example: Block LockBit C2 servers (replace with actual IPs) iptables -A INPUT -s 185.141.63.120 -j DROP


Step 2: Detect a Trojan (Windows)

Symptoms: - Unusual outbound connections (e.g., to 185.141.63.120:443). - Suspicious startup entries (msconfig or autoruns). - Unexpected .exe files in %APPDATA% or %TEMP%.

Commands to confirm:

# Check for suspicious startup programs
Get-CimInstance Win32_StartupCommand | Select-Object Name, Command, Location

# Look for unusual scheduled tasks (Trojans often persist here)
Get-ScheduledTask | Where-Object { $_.TaskPath -notlike "\Microsoft*" } | Select-Object TaskName, TaskPath

# Check for unusual network connections (e.g., to known C2 servers)
netstat -ano | findstr "ESTABLISHED"

Containment steps:
1. Kill the process (taskkill /PID <ID> /F).
2. Delete the malicious file (check Path in Get-Process).
3. Remove persistence (delete registry keys, scheduled tasks, or startup entries).
4. Scan with Microsoft Defender Offline (or another AV).


Step 3: Detect a Worm (Linux)

Symptoms: - High network traffic (worms spread aggressively). - Unusual processes (e.g., minerd, cryptonight—crypto mining worms). - New users or SSH keys added.

Commands to confirm:

# Check for unusual processes
ps auxf | grep -i "minerd\|cryptonight\|worm"

# Look for suspicious network connections
ss -tulnp | grep -E "445|139|135"  # SMB ports (WannaCry)

# Check for new users (worms often add backdoors)
cat /etc/passwd | grep -v "root\|daemon\|bin"

# Check for unusual cron jobs (persistence)
crontab -l
ls -la /etc/cron.* /etc/crontab

Containment steps:
1. Isolate the machine (ifconfig eth0 down or iptables -A INPUT -j DROP).
2. Kill the worm process (kill -9 <PID>).
3. Remove persistence (delete cron jobs, SSH keys, or malicious users).
4. Patch the vulnerability (e.g., apt update && apt upgrade -y for EternalBlue).


Step 4: Detect a Rootkit (Linux)

Symptoms: - AV scans come back clean, but the system is still compromised. - Hidden processes (not visible in ps or top). - Modified system binaries (ls, ps, netstat behave strangely).

Commands to confirm:

# Check for hidden processes (compare ps vs. /proc)
ps aux
ls /proc | grep -E "^[0-9]+$" | sort -n | xargs -I {} ls -la /proc/{}/exe 2>/dev/null | grep -v " (deleted)"

# Check for modified system binaries (compare hashes)
rpm -Va  # For RPM-based systems (RHEL, CentOS)
debsums -c  # For Debian/Ubuntu

# Use chkrootkit (basic rootkit detection)
sudo apt install chkrootkit -y
sudo chkrootkit

# Use rkhunter (more thorough)
sudo apt install rkhunter -y
sudo rkhunter --check

Containment steps:
1. Assume the system is fully compromised (rootkits are extremely hard to remove).
2. Wipe and rebuild the machine (do not try to "clean" it).
3. Rotate all credentials (SSH keys, API keys, passwords).
4. Investigate how it got in (e.g., unpatched software, weak SSH passwords).


Step 5: Detect a Logic Bomb

Symptoms: - No immediate signs (logic bombs lie dormant). - Unexpected system behavior (e.g., files deleted at a specific time). - Suspicious scripts in cron jobs, scheduled tasks, or CI/CD pipelines.

Commands to confirm:

# Check for time-based triggers (cron jobs)
crontab -l
ls -la /etc/cron.* /etc/crontab

# Check for suspicious scripts in CI/CD (e.g., GitHub Actions)
find / -name "*.sh" -o -name "*.ps1" -o -name "*.py" 2>/dev/null | xargs grep -l "rm -rf\|shutdown\|reboot"

# Check for unusual file modifications (e.g., "delete if user X is disabled")
auditctl -l  # Linux auditd rules

Containment steps:
1. Review all automation scripts (cron, CI/CD, GPOs).
2. Remove suspicious entries (e.g., crontab -e to edit cron jobs).
3. Monitor for unexpected behavior (e.g., file deletions, reboots).
4. Rotate all credentials (logic bombs are often planted by insiders).


4.-Production-Ready Best Practices

? Security

  • Least privilege: Limit user/admin access (e.g., no local admin for end users).
  • Application whitelisting: Only allow approved executables (e.g., AppLocker on Windows, fapolicyd on Linux).
  • Network segmentation: Isolate critical systems (e.g., no SMB between workstations and servers).
  • Endpoint detection & response (EDR): Use CrowdStrike, SentinelOne, or Microsoft Defender for Endpoint (not just AV).
  • Immutable backups: Store backups offline/air-gapped (ransomware targets backups).

? Cost Optimization

  • Automate patching: Use WSUS (Windows) or unattended-upgrades (Linux) to reduce attack surface.
  • Serverless for IR: Use AWS Lambda or Azure Functions for automated malware response (cheaper than 24/7 SOC).
  • Free tools: Use Sysmon (Windows), osquery (cross-platform), or Wazuh (SIEM) for detection.

? Reliability & Maintainability

  • Golden images: Deploy pre-hardened VMs (e.g., CIS benchmarks).
  • Immutable infrastructure: Use containers (Docker) or immutable VMs (e.g., AWS AMI updates).
  • Tagging: Label systems by criticality (e.g., env=prod, data=PII).

Observability

  • Log everything: Enable Windows Event Forwarding (WEF) or Linux auditd.
  • Alert on anomalies:
  • Ransomware: Sudden file encryption (FileCreate events with .locked extensions).
  • Worms: Unusual SMB/RDP traffic (netstat -ano | findstr "445").
  • Rootkits: Modified system binaries (rpm -Va).
  • SIEM rules: Use Sigma rules (e.g., Sigma GitHub) for detection.

5. Common Mistakes & Traps

Mistake Symptom Fix/Prevention
Assuming AV will catch everything Rootkits, logic bombs, and zero-days bypass AV. Use EDR + behavioral analysis (e.g., CrowdStrike).
Not testing backups Ransomware encrypts backups before you realize. Test restore monthly (e.g., aws s3 cp s3://backup-bucket/test-file ./).
Ignoring SMB/RDP exposure Worms like WannaCry spread via SMB (445). Disable SMBv1, block RDP (3389) at firewall.
Not monitoring for lateral movement Attackers move from workstation-server-cloud. Segment networks, monitor for unusual logins (e.g., Event ID 4624 in Windows).
Assuming Linux is "safe" Rootkits like Alureon target Linux. Harden Linux (CIS benchmarks), use rkhunter.

6.-Exam/Certification Focus (CompTIA Security+)

Typical Question Patterns

  1. "Which malware type spreads without user interaction?"
  2. ? Worm (self-replicating).
  3. Trojan (requires user action).

  4. "A user’s files are encrypted, and a ransom note appears. What’s the next step?"

  5. ? Isolate the machine (prevent spread).
  6. Pay the ransom (never recommended).

  7. "Which malware hides its presence by modifying the OS kernel?"

  8. ? Rootkit.
  9. Logic bomb (triggers on condition, doesn’t hide).

  10. "An employee’s account is disabled, and all files are deleted. What malware is this?"

  11. ? Logic bomb (triggered by account deactivation).
  12. ? Ransomware (would encrypt, not delete).

Trap Distinctions

Term Key Difference Exam Trap
Ransomware vs. Worm Ransomware encrypts files, worms spread automatically. "Which spreads via SMB?"-Worm (WannaCry).
Trojan vs. Virus Trojans disguise as legit software, viruses attach to files. "Which requires user action?"-Trojan.
Rootkit vs. Spyware Rootkits hide in the OS, spyware steals data. "Which modifies the kernel?"-Rootkit.

7.-Hands-On Challenge (With Solution)

Challenge:

You’re a SOC analyst. A user reports their files are renamed with .locked. You suspect ransomware. Task: Write a PowerShell one-liner to:
1. Find all .locked files.
2. Kill any process using high CPU (likely the encryptor).
3. Output the results to a file for IR.

Solution:

# Find .locked files, kill high-CPU processes, and log results
Get-ChildItem -Path C:\ -Recurse -Filter "*.locked" -ErrorAction SilentlyContinue | Select-Object FullName | Out-File -FilePath "C:\ransomware_files.txt"
Get-Process | Where-Object { $_.CPU -gt 50 } | ForEach-Object { taskkill /PID $_.Id /F; "Killed process: $($_.Name) (PID: $($_.Id))" } | Out-File -FilePath "C:\ransomware_processes.txt" -Append

Why it works: - Get-ChildItem finds all encrypted files (ransomware leaves a trail). - Get-Process + taskkill stops the encryptor (high CPU = likely malware). - Out-File logs evidence for IR.


8.-Rapid-Reference Crib Sheet

Malware Type Detection Method Containment Command Ports to Block
Ransomware Get-ChildItem -Filter "*.locked" taskkill /PID <ID> /F 445 (SMB)
Trojan Get-ScheduledTask \| Where-Object { $_.TaskPath -notlike "\Microsoft*" } schtasks /delete /tn "MaliciousTask" /f 443 (C2)
Worm ss -tulnp \| grep "445" iptables -A INPUT -s <IP> -j DROP 445, 139, 135
Rootkit rpm -Va (Linux) Wipe & rebuild N/A
Logic Bomb crontab -l crontab -e (remove entry) N/A

Exam Traps: - "Which malware requires user interaction?"-Trojan (not worm). - "Which malware hides in the OS?"-Rootkit (not spyware). - "Which spreads via SMB?"-Worm (not ransomware).


9.-Where to Go Next

  1. MalwareBazaar – Safe malware samples for analysis.
  2. Sysinternals Suite – Windows forensic tools.
  3. CIS Benchmarks – Hardening guides for Windows/Linux.
  4. Sigma Rules – SIEM detection rules for malware.
  5. MITRE ATT&CK – Malware techniques & mitigations.

Final Takeaway

Malware isn’t just a theory—it’s a daily threat in production. The difference