Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 37 ยท Concepts and Safe Lab

Malware Lifecycle and the Attack Chain

Walk through the stages of a malware infection, from delivery and execution to persistence, command and control and impact, and map each stage to analysis evidence.

Malware does not appear and act in one step. It travels through stages, from the moment it reaches a victim to the moment it achieves its goal. Knowing the lifecycle tells you where to look for evidence, because each stage leaves different traces. It also helps you read a sample: when a function opens a registry key, you ask which stage of the chain it belongs to.

This lesson uses a simplified chain. Frameworks such as the Lockheed Martin Cyber Kill Chain and MITRE ATT&CK describe the same ideas in more detail.

The stages

flowchart LR
    A["Delivery"] --> B["Execution"]
    B --> C["Persistence"]
    C --> D["Defence evasion"]
    D --> E["Discovery and credential access"]
    E --> F["Command and control"]
    F --> G["Lateral movement"]
    G --> H["Impact or exfiltration"]

Not every sample has every stage, and stages can overlap or repeat. Use the chain as a checklist, not a script.

  1. Delivery. How the file or exploit reaches the victim: phishing email attachment, malicious link, drive-by download, removable USB drive, compromised software update, an exposed remote service.
  2. Execution. The first code runs. A user opens a document and enables macros, double-clicks an executable, or a script is launched by an exploit.
  3. Persistence. The malware ensures it survives a reboot: registry Run keys, scheduled tasks, services, startup folder entries, browser extensions.
  4. Defence evasion. Hiding from tools: packing, obfuscation, disabling antivirus, deleting logs, detecting sandboxes.
  5. Discovery and credential access. It learns about the machine and the network, and steals passwords, tokens or keys.
  6. Command and control (C2). It talks to its operator to receive tasks and send results.
  7. Lateral movement. It spreads to other machines using stolen credentials or network services.
  8. Impact or exfiltration. The objective: encrypt files, steal data, mine coins, wipe disks, send spam.

Mapping stages to evidence

The same stage shows up in different places depending on the method you use.

Stage Static evidence Dynamic evidence
Delivery Document macros, embedded files Parent process (for example a mail client launching a script)
Execution Entry point, scripts New processes, command lines
Persistence Strings with registry paths, task names New registry values, scheduled tasks, services
Evasion Packer signatures, high entropy Checks for virtual machines, delays
Discovery Imports such as system-information functions Commands like whoami, ipconfig
C2 URLs, domains, IP addresses, user-agent strings DNS lookups, periodic connections
Impact Encryption routines, file-extension lists Mass file changes, ransom notes

A strong report ties each finding to a stage: "The sample writes a Run key (persistence) and contacts a server every 5 minutes (C2)."

MITRE ATT&CK in one minute

MITRE ATT&CK is a public knowledge base that catalogues attacker tactics (the goal, such as Persistence) and techniques (the method, such as "Registry Run Keys / Startup Folder", ID T1547.001). Using ATT&CK identifiers lets teams compare notes and spot gaps in their detections. You do not need to memorize them; you need to know they exist and how to search them.

Practice: tag observations with stages

The script below takes a list of behaviours seen during an imaginary investigation and tags each with a lifecycle stage and a technique name. Output ordering by stage reveals the story of the infection.

Python Build an infection timeline

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The "missing" line is a prompt for follow-up work: not seeing evasion does not mean it did not happen, only that you have not found it.

Persistence: the second look

Persistence is the stage analysts most often turn into detections, because it is predictable and hard to avoid. Common Windows locations are:

  • Registry keys named Run and RunOnce under both the user and machine hives.
  • Scheduled tasks and services.
  • The user's Startup folder.
  • WMI event subscriptions and DLL hijacking spots (advanced).

The next example checks a list of startup entries against simple suspicion rules. It uses fake data and reads no real registry.

Python Scan fake startup entries

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice svchost.exe in the Temp folder: the genuine Windows file lives in System32. Impersonating system names is a classic trick, so where a file lives matters as much as what it is called.

Common mistakes

  • Treating the first stage as the whole story.
  • Forgetting that C2 can be quiet for days.
  • Assuming absence of evidence is evidence of absence.
  • Memorizing technique IDs instead of understanding behaviour.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which stage ensures malware keeps running after a reboot?

    Persistence mechanisms such as Run keys, scheduled tasks and services restart the malware automatically.
  2. 2. Finding a process that contacts a server at fixed intervals most directly indicates which stage?

    Regular check-ins are beaconing, a hallmark of command and control.
  3. 3. Why is a file named svchost.exe in a Temp folder suspicious?

    Attackers copy system file names, so the location and signature are what separate the real program from an imitation.
  4. 4. What does MITRE ATT&CK provide?

    ATT&CK is a catalogue of behaviours that helps teams describe attacks and map detections.

Summary

  • Malware moves through stages: delivery, execution, persistence, evasion, discovery, C2, lateral movement, impact.
  • Each stage leaves distinct static and dynamic evidence.
  • Persistence and C2 are the best sources of reusable detections.
  • MITRE ATT&CK gives shared names for tactics and techniques.
  • Tie each finding to a stage when you report it.

Next: Building a Safe Analysis Lab