Skip to content
Tutorials Center
My learning

Topics

Lesson 22 of 37 ยท Incident Response

Evidence Handling and Forensic Basics

Learn how SOC analysts preserve digital evidence: order of volatility, hashing, chain of custody, log integrity and timelines, with runnable examples.

When an incident might lead to disciplinary action, legal proceedings, an insurance claim or a regulator's questions, the way you collect and store evidence matters as much as what you find. Even when no court is involved, careless handling can make your own conclusions impossible to check. Digital forensics is the careful collection and analysis of data from systems; a SOC analyst does not need to be a forensic examiner, but should know the basic rules so as not to damage what a specialist will need later.

All activity in this lesson applies only to systems and data you are authorized to examine.

Principles

  1. Preserve the original. Work on copies whenever possible. Every action on a live system changes it, so keep actions minimal and written down.
  2. Prove integrity. Record cryptographic hashes of every artifact at collection time and again later. If the hashes match, the data did not change.
  3. Keep a chain of custody. A written record of who collected each item, when, where, how, and who held it afterwards.
  4. Document everything. Commands run, times, observations, in order, with the time zone.
  5. Follow authority. Collect only what policy and law allow; privacy and employment rules vary by country and by organization. When in doubt, ask legal or HR before collecting personal data.

Order of volatility

Collect the most short-lived data first, because it disappears fastest.

flowchart TD
    A["1. CPU registers, cache"] --> B["2. Memory (RAM): processes, connections, keys"]
    B --> C["3. Network state: connections, routing and ARP tables"]
    C --> D["4. Running processes and logged-in users"]
    D --> E["5. Disk: files, logs, registry, swap"]
    E --> F["6. Remote logs and monitoring data"]
    F --> G["7. Backups and archives"]

Top is the most volatile. In practice analysts start at memory.

Typical practice: capture memory with an approved tool, record network connections and running processes, then image the disk, and only then power down or rebuild. Cloud and virtual machines add shortcuts such as snapshots, which capture disk (and sometimes memory) without touching the guest.

Four rules of evidence

Preserve Work on copies
Hash Prove nothing changed
Chain of custody Who held it, when
Document Every step, with times

If you cannot show how you got it, it is only an opinion.

1 / 2

Hashing evidence

A hash function (SHA-256 is a common choice) turns any file into a short fixed fingerprint. Change one bit and the fingerprint changes completely. Record the hash when you collect an item, then recompute it before analysis.

Python Hash and verify an evidence file

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.

Chain of custody

A chain-of-custody form is just a table, but each row must be complete. Here is a tiny version that refuses incomplete entries and prints the history.

Python Chain of custody log

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.

Log integrity

Logs are evidence too, and attackers know it. They clear them, edit them or stop the logging service. To protect them:

  • Forward logs off the machine in near real time (to the SIEM or a log server), so deleting local logs does not erase history.
  • Restrict write access to the log store and monitor for changes.
  • Keep time synchronized (NTP) across systems; evidence with clocks minutes apart is hard to correlate.
  • Retain logs for as long as your policy, law or contracts require.

Alert on "log cleared" and "logging service stopped" events; they are strong signs of trouble. Chapter 4 of this track covers writing detection rules for exactly these events.

Building a timeline

A timeline merges events from many sources (authentication logs, endpoint events, proxy logs, file timestamps) into one chronological list. Normalize every time to UTC, note the source of each entry, and mark which are facts from logs and which are your interpretation.

Python Merge sources into a UTC 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.

Without conversion, the proxy event looks like it happened two hours after the rest. In UTC it is the final step of a clear sequence.

When to call a specialist

Bring in a trained forensic examiner or your legal team when an incident may go to court, involves insiders, law enforcement, or very sensitive data. Until they arrive, stop touching the affected systems unless you must contain damage, and record what you did.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why record a hash of an evidence file at collection time?

    A matching hash later shows the data is bit-for-bit identical to what was collected.
  2. 2. According to the order of volatility, which should be collected first?

    Memory disappears when power is lost or processes end, so it is captured before disks and archives.
  3. 3. What does a chain of custody record?

    It documents every hand-off so the item's integrity can be defended.
  4. 4. Why convert all timeline entries to UTC?

    A single time standard lets you order events from different systems correctly.

Summary

  • Preserve originals, hash everything, keep a chain of custody and document each step.
  • Collect volatile data (memory, network state) before disks and archives.
  • Forward and protect logs, and keep clocks synchronized.
  • Build timelines in UTC and separate observed facts from interpretation; call specialists for legal or sensitive cases.

Next: Post-Incident Review and Lessons Learned