TExcelTAD
Home › Malware Analysis, Digital Forensics & Incident Response › Eradication, Recovery and Lessons Learned

Eradication, Recovery and Lessons Learned

Containment stopped the bleeding. Eradication removes everything the intruder left (malware, persistence, accounts, stolen credentials) and closes the way they came in. Recovery brings systems back into service, from sources you trust, in an order that works, while watching for the attacker's return. Lessons learned turns the incident into improvements. In CSF 2.0 terms: RS.MI mitigation, then RC.RP recovery plan execution and RC.CO recovery communication, and ID.IM improvement (lifecycle).

Eradication

  • Rebuild, don't clean. For a compromised host, reinstalling from a known-good image is faster to trust than deleting the files you found: you never know you found all of them. Cleaning is acceptable only for well-understood, low-impact infections, and then with verification.
  • Remove every foothold found in scoping: for the lab sample, the dropped file, the Run value, the scheduled tasks and services checked by Autoruns, and anything the hunt found on other hosts.
  • Reset credentials: every account used on affected hosts; service accounts; in a domain compromise, the krbtgt account twice (with replication in between) and all privileged accounts (AD backup and recovery).
  • Close the entry vector: the phishing path, the unpatched service, the exposed remote desktop, the weak password. Without this, eradication is temporary.
  • Hunt again with the final indicators and behaviours after eradication: no hits means you can move on.

Recovery

  • Restore from clean sources: images and backups from before the compromise began (not just before the detection: dwell time matters), verified for integrity, scanned with the incident's YARA rules before going live.
  • Restore in dependency order: identity and name services first, then shared infrastructure, then applications, then end users.
  • Monitor closely after restoration: the same indicators, plus new logins of reset accounts, for weeks.
  • Communicate: when services return, what users must do (new passwords, reinstall a client), and what remains degraded.

Planning a restore

The example plans the recovery of a small synthetic environment after the lab incident, as if every system had to be brought back (for example in a recovery site): it picks, for each system, the newest backup that is older than the earliest evidence of compromise on that system and has passed a restore test, and orders the restoration by dependencies with Python's graphlib.

python · try it yourself
from datetime import datetime
from graphlib import TopologicalSorter

compromise_start = {   # earliest evidence per system, from the timeline (UTC)
    "dc01": None, "dns01": None, "srv-files01": "2026-01-15 10:40", "app-crm": None, "lt-0815": "2026-01-15 10:04"}
backups = {            # (taken at UTC, restore-tested?, immutable?)
    "dc01":        [("2026-01-14 22:00", True, True), ("2026-01-15 22:00", True, True)],
    "dns01":       [("2026-01-15 22:00", True, True)],
    "srv-files01": [("2026-01-13 22:00", True, True), ("2026-01-14 22:00", False, True), ("2026-01-15 22:00", True, True)],
    "app-crm":     [("2026-01-15 22:00", True, False)],
    "lt-0815":     [],                                          # laptops are rebuilt from the standard image
}
depends_on = {"dns01": {"dc01"}, "srv-files01": {"dc01", "dns01"}, "app-crm": {"dc01", "dns01", "srv-files01"},
              "lt-0815": {"dc01", "dns01"}}

def choose(system):
    start = compromise_start[system]
    good = [b for b in backups[system] if b[1] and (start is None or b[0] < start)]
    if not backups[system]:
        return "rebuild from the standard image"
    if not good:
        return "NO CLEAN TESTED BACKUP: escalate"
    t, _, immutable = max(good)
    return f"restore backup {t}" + ("" if immutable else " (mutable store: verify integrity first)")

order = list(TopologicalSorter(depends_on).static_order())
for i, system in enumerate(order, 1):
    print(f"{i}. {system:<12} {choose(system)}")
1. dc01         restore backup 2026-01-15 22:00
2. dns01        restore backup 2026-01-15 22:00
3. srv-files01  restore backup 2026-01-13 22:00
4. lt-0815      rebuild from the standard image
5. app-crm      restore backup 2026-01-15 22:00 (mutable store: verify integrity first)

Three decisions are visible. The file server's newest backup (22:00 on the 15th) was taken after the compromise began, so it may contain the attacker's changes; the one from the 14th never passed a restore test; the plan therefore falls back to the 13th and accepts losing two days of changes (which may be recovered selectively from later backups after scanning). The CRM's backup is on mutable storage, so its integrity is checked before use. And everything waits for the domain controller and DNS, which come first. Systems with no evidence of compromise get their newest tested backup; if scoping were less certain (no EDR on the domain controller, say), a backup from before the laptop's first event would be the safer choice.

Lessons learned

Within about two weeks, while memories are fresh, the people involved meet without blame and answer: what happened, when did we know, what went well, what didn't, what would have detected it earlier or stopped it, and what will we change? The output is a short list of owned, dated actions (new detections, hardening, process fixes, training), tracked like any other work. Useful metrics:

Metric Meaning In the lab case
Dwell time first compromise to detection 10:04 to 10:09 (5 minutes)
Time to contain detection to the last containment action 10:09 to about 11:10
Time to recover detection to normal operation about one day for the laptop, longer for the file server
Scope at detection vs final scope how much the first view missed 1 host vs 2 hosts

How recovery is verified

  • Scan restored systems with the incident's YARA and Sigma rules and compare with known-good baselines (Autoruns, installed services, local accounts).
  • Watch for the indicators and for logins of reset accounts from unusual places.
  • Retest the entry vector (the patch is applied, the exposed service is closed).

Pitfalls

  • Restoring the attacker. A backup taken during the dwell time contains their persistence; choose by compromise start, not by detection time.
  • Untested backups. A backup that has never been restored is a hope, not a plan.
  • Partial credential resets. One forgotten service account or API token is enough to come back.
  • Blame in the lessons-learned meeting: people then hide mistakes, and the organisation learns nothing.

Practice

1. Change the file server's compromise start to 2026-01-14 21:00. Which backup is chosen?

Only backups before 21:00 on the 14th qualify, and the 22:00 backup of the 14th was untested anyway: the plan still picks 2026-01-13 22:00. If the compromise had started before that too, it would print the escalation message.

2. Why does the laptop wait for dc01 and dns01 in the order?

Users need to log on and resolve names; a rebuilt laptop joined to a domain that isn't back yet can't be used and may cache wrong state. The dependency graph encodes that.

3. Write one lessons-learned action for the lab case, with an owner and a date.

For example: "Block execution of unsigned programs from user Downloads and Temp folders with application control (owner: endpoint team, pilot by 2026-02-15, all laptops by 2026-03-31)", derived from the entry path of the incident.

Test yourself

Why is rebuilding a compromised host usually preferred over cleaning it?

  1. Rebuilding is cheaper in all cases
  2. You can never be sure cleaning found every foothold; a known-good image is trustworthy
  3. Cleaning is illegal
  4. Rebuilding preserves evidence

Which backup is safe to restore?

  1. The newest one
  2. The newest restore-tested one taken before the compromise began on that system
  3. The oldest one
  4. Any immutable one

What does the topological sort in the example ensure?

  1. Backups are encrypted
  2. Each system is restored after the systems it depends on
  3. The fastest restore first
  4. Alphabetical order

What is the main purpose of a blameless lessons-learned review?

  1. To find someone to fire
  2. To produce owned, dated improvements while people speak openly
  3. To write the press release
  4. To close the ticket quickly