EZ LearnEZ Learn
Courses
EZ Board
Dashboard
All articles
python-for-cyber-securitypythondigital-forensicschain-of-custody

The Digital Forensic Investigation Process

A forensic investigator does not rearrange the furniture at a crime scene. Digital forensics applies the same discipline to data: examine without disturbing, and let the script's own log prove it.

Ashish Revar17 October 20266 min read
1 video lesson 6:09 total
Sign in to track your progress

Video lesson

The first two units built tools that act on a system: a scanner that knocks on doors, an SSH client that runs commands, a credential tester that tries logins. This unit turns that around. Every script here examines a system without disturbing it, because the moment digital forensics touches evidence it must be prepared to explain exactly what it touched and why.

Analogy: The crime scene

A forensic investigator arriving at a crime scene does not rearrange the furniture, wipe the surfaces, or pocket a souvenir. They photograph everything first, touch as little as possible, bag each item with a signed label, and record who handled what and when. Digital forensics applies the same discipline to data: recover and examine it in a way that would survive a challenge in court.

Key takeaway: The one rule

The whole craft rests on one rule: do not alter the evidence. Every Python script in this unit is written to read and copy, never to change. You will see this rule shape almost every design decision ahead, from copying a file before opening it to choosing which timestamp a script is allowed to touch.

A recognised process, not improvisation

A forensic investigation follows a process, and every script in this unit plays a part in one of its stages.

Python concept: The digital forensic investigation process

  1. Identify: locate the devices and data that may hold evidence.
  2. Preserve: protect the originals; work only from verified copies.
  3. Collect: acquire the evidence in order of volatility, most fleeting first, hashing each item as it is collected.
  4. Examine: extract the relevant content and metadata without altering the source.
  5. Analyse: correlate the findings, often onto a single timeline.
  6. Report: present the findings and the method clearly enough to withstand challenge.

Vocabulary: Chain of custody

A documented record of who collected a piece of evidence, when, how it was stored, and who accessed it afterward, like the signature log on a sealed evidence bag. A script that logs its own actions, the file it read, the hash it computed, the time it ran, contributes directly to this record. The next article builds exactly that logger, and every later script in this unit calls it.

Collect the fleeting things first

Vocabulary: Order of volatility

The principle that the most fleeting evidence is collected first. Data in RAM vanishes the moment a machine powers off; a file's last-access time can change the moment an investigator opens it; data on a write-protected image is stable. Collect from the top of the pyramid down.

RAMRunning processes, network stateTemporary files, logsDisk files, archived datacollect firstcollect last
Figure 3.1. The order of volatility, pictured as a freezer. RAM is the ice cream, melting within minutes; disk archives are the canned goods, and will keep for years.

RAM

Vanishes the moment a machine powers off. Running processes, open network connections, decrypted contents in memory: gone forever at shutdown.

Temporary files, logs

Overwritten or rotated on a running schedule, sometimes within hours.

Disk files, archived data

The canned goods. Stable until something is deliberately written over the same space.

How this rule shapes every script ahead

Why it carries weight: Why it carries weight

This unit shifts the book from building tools that act on systems to building tools that examine them without disturbance, which is a different frame of mind. A script that copies a database before reading it, hashes a file before and after moving it, or reads a timestamp without opening the file first is not being cautious for its own sake; it is following the order of volatility and the chain-of-custody rule from this article. You will meet all three habits in the articles ahead.

Case study: Why a script's own log matters as much as its finding

An investigator presents a timeline showing a suspicious file was modified before a login occurred. Opposing counsel asks: how do you know the examination itself did not change that timestamp? Without a log, there is no answer but trust. With one, the investigator shows the exact moment the file was copied, read-only, before any analysis began, and the hash computed at collection matching the hash computed before presentation. The finding is the same either way; only the second version survives the question. This scenario is illustrative, but the underlying demand, prove you did not disturb what you are presenting, is real in every forensic process.

Check your understanding

Question 1: Using the freezer analogy, explain the order of volatility and give one example of evidence that must be collected before a file's last-access time.

The order of volatility says to collect the most fleeting evidence first, the way ice cream has to be dealt with before canned goods spoil. The contents of RAM, such as running processes or network connections, must be collected before a file's last-access time, because RAM disappears completely the instant the machine is powered off, while an access time merely changes and can still be read, just not to its original value.

Question 2: What does a chain of custody actually document, and what role does a script's own log file play in it?

It documents who collected a piece of evidence, when, how it was stored, and who accessed it afterward. A script's log file records exactly this for its own actions, the file it touched, the hash it computed, the timestamp it ran, so the log becomes part of the chain of custody rather than something separate from it.

Question 3: Why does this unit insist that every script reads and copies, but never changes, the evidence it touches?

Because an investigation's findings only hold up if the examination itself can be shown not to have altered what was found. A script that modifies evidence while examining it destroys the ability to prove the evidence is in its original state, which is the one thing a forensic examination can never recover once lost.

Key takeaway: Key takeaway

Digital forensics is examination without disturbance, carried out through six recognised stages: identify, preserve, collect, examine, analyse, report. Collect the most volatile evidence first, and let every script log its own actions, because an undocumented action is of little use as evidence.

Assessments

Unit Assessment

Digital Forensics with Python

20 questions30 minPass: 60%

Start exam →

Comprehensive Assessment

Python for Cyber Security: Complete Assessment

100 questions120 minPass: 60%

Start final exam →

Related to this topic

Continue learning

Reference material

Cheatsheet

Python for Cyber Security — Cheatsheet

v1.0

Open resource

MCQ Bank

Python for Cyber Security — MCQ Bank

v1.0

Open resource

Question Bank

Python for Cyber Security — Question Bank

v1.0

Open resource

eBook

Python for Cyber Security — eBook

v1.0

Open resource

Discussion

Loading comments…
More articlesTest your knowledge
EZ MentorAI · Free

The Digital Forensic Investigation Process

Hi! I'm EZ Mentor

Your AI tutor for
The Digital Forensic Investigation Process

Sign in to ask, it's free.

EZ Mentor is AI-powered · Answers may not be perfect · 10 free questions / day

EZ LearnEZ Learn

Structured learning across Reverse Engineering, Cloud Security, and Research Methodology, plus games and practice tools in EZ Arena. Free, and open to anyone.

EZ Learn

  • Courses
  • EZ Articles
  • EZ Watch
  • EZ Talks
  • EZ Bytes
  • Cyber Hygiene

EZ Library

  • All Resources
  • eBooks & PDFs
  • Question Banks
  • MCQ Banks
  • Cheatsheets

EZ Exams

  • All Exams
  • REMA
  • Cloud Security
  • Research Methodology
  • Python for Cyber Security
  • Cyber Law & IPR
  • Community
  • EZ Board

EZ Arena

  • EZ Games
  • Live Quiz
  • ML Challenges
  • दिशा - Hygiene
  • सजग - Awareness
  • अभ्यास - Practice

Platform

  • About
  • Contact
  • Terms of Use
  • Disclaimer
  • Verify Certificate
  • Events

© 2026 EZ Learn by EpochZero. Educational content for learning purposes.

Platform Lead: Ashish Revar