DefensiveHub

Digital Forensics: How to Find Out What Happened After an Attack

Every attack leaves artifacts on disk and in memory. The forensic process, what to collect first, and the tools that analyze the evidence.

Ahmed Eid 7 min read

Topic
Digital Forensics
Level
Beginner to intermediate
Techniques
T1055 · T1003
Data sources
Disk image · Memory dump · Windows artifacts
Tools
FTK Imager · Volatility 3 · KAPE · Autopsy
You leave with
The forensic process, what to collect first, and the artifacts that tell the story

The forensic process

1Identificationscope it2Collectionpreserve3Examinationextract4Analysisreconstruct5ReportingexplainThe four phases in NIST SP 800-86

  1. IdentificationScope it: which systems and data sources matter, and which data disappears first. It isn't one of NIST's four phases, but every practical model starts here.
  2. CollectionThe critical phase: never work on original evidence. Image the disk, dump the memory, hash everything, and document the chain of custody.
  3. ExaminationOn the copy, never the original: carve deleted files, parse timestamps, registry and logs. The goal is to surface raw data.
  4. AnalysisCorrelate artifacts into one timeline: a Prefetch file on a workstation, a logon in the SIEM, an outbound transfer at the firewall.
  5. ReportingA reproducible report that separates facts from inferences, with hashes, timestamps and sources for every artifact.

When a security incident happens, whether a ransomware outbreak, a data breach or an insider threat, the first questions are always the same: what happened, how did they get in, what did they touch, and what did they take? Logs alone can’t answer that. It takes a disciplined process of collecting, preserving and analyzing evidence. That process is digital forensics.

The ruleEvery attack leaves artifacts. Digital forensics is how you collect them, preserve them, and read them correctly.

Digital forensics applies scientific methods to identify, collect, examine and analyze data in a way that keeps the evidence intact and the chain of custody unbroken, so the findings hold up in an incident report, and in a courtroom if needed. For a blue team it’s one of the most powerful tools there is: it lets you rebuild an attacker’s every move long after they tried to cover their tracks.

The forensic process

An investigation isn’t “look at logs and find bad stuff”. It follows a repeatable method. NIST SP 800-86 defines four phases: collection, examination, analysis and reporting. Most practical models add an identification step before them. The diagram at the top of this article walks through all five.

  • Identification: scope the incident, list the systems and data sources involved (endpoints, servers, cloud, mobile, network logs), and decide which data will disappear first.
  • Collection: the golden rule is to never work on original evidence. Image disks bit for bit (dd, FTK Imager, Magnet ACQUIRE), dump memory before any power change (WinPmem, Magnet RAM Capture, LiME), hash every image with SHA-256, and keep a signed chain-of-custody record.
  • Examination: on the copy, carve deleted files, parse MAC timestamps, recover registry hives, browser history and logs. The goal is raw data; interpretation comes next.
  • Analysis: turn raw data into a timeline by correlating sources: a Prefetch timestamp on a workstation, a logon in the SIEM, an outbound transfer at the firewall.
  • Reporting: reproducible, clear about facts versus inferences, and complete with hashes, timestamps and sources for every artifact.

The order of volatility

Collect the most volatile evidence first. RFC 3227 sets the order. The most common mistake is to reboot or power off a compromised machine straight away, which destroys everything above the disk. Always capture RAM first.

Collect top to bottom: the order of volatility

gone in secondsRegisters, cacheARP and routing tables, processes, memoryTemporary file systemsDiskRemote logging and monitoring dataPhysical configuration, network topologyArchival medialasts months or years
The order from RFC 3227. A reboot or power-off destroys everything above the disk, so memory always comes first.

Artifacts that tell the story

Windows

  • Event logs in %SystemRoot%\System32\winevt\Logs\: logons, privilege use, service installs, process creation.
  • Registry hives (HKLM, HKCU, SAM, SYSTEM): persistence, USB history, installed software.
  • Prefetch in C:\Windows\Prefetch\: proof a program ran, even if it was deleted.
  • ShellBags: folder browsing history, including deleted and network folders.
  • LNK files in %APPDATA%\Microsoft\Windows\Recent\: recently opened files and their original paths.
  • $MFT at the root of an NTFS volume: the full file system history, deleted files included.
  • Amcache and Shimcache: they show that a program was present on the system, but they are not enough on their own to prove it ran. Correlate them with Prefetch and Event Logs.

Linux

  • /var/log/: auth logs, syslog, application logs.
  • ~/.bash_history: the commands each user ran.
  • /etc/cron.*: scheduled tasks, a common persistence spot.
  • /tmp/ and /dev/shm/: favorite attacker staging folders.
  • The systemd journal (journalctl).

Memory is a goldmine: running processes with full command lines, live network connections, encryption keys not yet on disk, code injected into legitimate processes, and sometimes credentials in clear text.

Memory forensics with Volatility 3

Memory is where attackers try hardest to hide, and where investigators often find the strongest evidence. Volatility 3 reads a raw memory image through plugins, each aimed at one kind of artifact:

python3 vol.py -f memory.raw windows.info      # OS details of the image
python3 vol.py -f memory.raw windows.pslist    # running processes
python3 vol.py -f memory.raw windows.psscan    # hidden processes too
python3 vol.py -f memory.raw windows.pstree    # parent and child
python3 vol.py -f memory.raw windows.netstat   # network connections
python3 vol.py -f memory.raw windows.malfind   # injected code

malfind looks for memory regions marked PAGE_EXECUTE_READWRITE that aren’t backed by a file on disk, a classic sign of shellcode injection or process hollowing.

Tools

  • Acquisition: FTK Imager, Magnet ACQUIRE, dd and dcfldd, WinPmem and LiME.
  • Analysis: Autopsy (on The Sleuth Kit), Volatility 3, KAPE, and Eric Zimmerman’s tools (MFTECmd, PECmd, AppCompatCacheParser).
  • Timelines: Plaso (log2timeline), Timeline Explorer, and the Elastic Stack for large cases.

Forensics and incident response

Incident response is about containment and recovery: stop the bleeding and get systems back. Speed comes first. Forensics is about evidence and understanding: rebuild exactly what happened and prove it. Thoroughness comes first. In practice they run side by side: IR contains the incident while forensic analysts image the affected systems before they’re wiped. Not coordinating the two is one of the most common mistakes, because critical evidence gets destroyed in the rush to restore service.

A scenario. An endpoint is beaconing to a known C2 address. Don’t power it off. Capture memory, isolate the host from the network while it stays on, image the disk, hash both images, then analyze memory first (pslist, netstat, malfind) and build the timeline.

Keeping evidence trustworthy

Strong evidence doesn’t just reveal the truth. You also have to be able to prove it hasn’t changed. That’s why working on the original is off limits, why you use a write blocker with disks where possible, and why you calculate the hash at collection and again afterward. If the two match, the copy is intact.

The chain of custody is a record that follows every transfer:

CollectCollectSealSecureTransferTransferAnalyzeAnalyzeReportReport

  1. 1Collect the copy, calculate the hash, record time and place.
  2. 2Keep the original in a restricted location.
  3. 3Log every handover by name, time and reason.
  4. 4Analyze a copy, and verify the hash.
  5. 5The report ties each finding to its evidence.

Each time, write down what the evidence is, its number, its hash, who received it, who handed it over, the time and the reason. If there’s any gap in the record, write it down rather than hide it.

Building the timeline

The timeline turns scattered artifacts into a coherent story. Start from a confirmed point, like the time of an alert, and work backward and forward:

  1. Normalize the time zone across all sources, ideally to UTC.
  2. Gather events from disk, logs and network.
  3. Label each event with its source and your confidence in it.
  4. Look for the earliest suspicious activity, which is your closest estimate of the entry point.
  5. Separate what’s confirmed from what’s still inference.

Keep in mind that timestamps can be altered. This technique is called timestomping, so don’t rely on a single artifact.

Forensics in the cloud

In the cloud there’s usually no disk to hold in your hand, and logs become your primary source. Think about:

  • Retention: logs are kept for a limited time, so know that period before an incident.
  • Identity: sign-in and audit records in Microsoft Entra ID.
  • Microsoft 365: the Unified Audit Log shows email and file activity.
  • VMs: you can snapshot the disk before any change.

Responsibility is shared here, so know what the provider supplies and what you’re responsible for collecting.

Common mistakes

  • Shutting down the machine before collecting memory without a strong reason.
  • Working on the original machine and changing timestamps.
  • Running tools from the compromised disk itself.
  • Not writing down what you did, step by step.
  • Relying on a single source.
  • Announcing a conclusion before separating fact from inference.

If the case may end in criminal charges, a lawsuit or regulatory action, the chain of custody must be unbroken and documented from collection to presentation, and every acquisition method must be defensible. Bring in legal counsel before contacting law enforcement or disclosing anything publicly, and keep in mind that data stored in several countries falls under different laws; GDPR, for example, affects how you handle personal data found during an investigation.

References

Ahmed Eid. I write about the defensive security work I do every day, and explain it in Arabic to save you time.