Please enable JavaScript to use CodeHS

Cybersecurity Tutorial

Digital Forensics

Every click, save, and login leaves a trail. Digital forensics is the science of following that trail: collecting digital evidence, examining it without changing a single byte, and using it to figure out exactly what happened. Step into the lab and solve a case yourself.

evidence lab ~25 min Beginner friendly
The Big Idea

What is digital forensics?

Digital forensics is the use of digital media from a computer, phone, server, or network as evidence, often in a court of law. When something goes wrong in the digital world, whether it is a hacker breaking into a company server, a plagiarized essay, or a photo that proves where someone really was, investigators are called in to answer one question: what actually happened here?

A digital forensic investigator works a lot like a detective at a crime scene. But instead of fingerprints and footprints, the clues are files, timestamps, logs, and metadata. And digital clues have a superpower: computers write down almost everything, automatically, all the time. A person can lie about what they did. Their login log usually cannot.

Not just for crimes. Digital forensics also settles everyday disputes. A school IT department might check a document's metadata to test a plagiarism claim, or a company might read network logs to learn how an attacker got in so it never happens again.


The Clue Collection

Types of digital evidence

Almost anything stored on or recorded by a computer can become evidence. These are the big five that investigators reach for first:

Files and timestamps

Every file remembers when it was created and when it was last changed. A "finished on Monday" story falls apart if the file says it was edited Thursday at midnight.

Metadata

Data about data. A document quietly records its author, creation date, last editor, and even total editing time, all hidden behind the visible text.

Logs

Servers and networks keep diaries: every login attempt, every connection, success or failure, with a time and a username attached.

Browser history

The list of pages visited and searches typed on a computer. Searching "how to hide file edits" five minutes before a file was edited is a very loud clue.

EXIF data

Short for Exchangeable Image File: metadata embedded in photos from digital cameras. Camera model, flash, zoom, exact time, and often GPS location.

Network traffic

Records of which machines talked to which, and when. Firewalls can log every attempt to reach a server, even from the other side of the world.

From a real training case: in one classic exercise, a server admin named Addison is accused of stealing company data. The firewall's SSH login log tells the true story: an outside attacker hammered the server with hundreds of failed password guesses (a brute-force attack) before slipping in with a stolen account. The log cleared the innocent admin.


Evidence Deep Dive

Reading an EXIF file like an investigator

Here is EXIF metadata from a photo in a fictional case, pulled with a command line tool called exiftool. Police asked investigators to check five claims about the photo. Watch how the data answers them:

suspect.jpg EXIF READOUT
$ exiftool suspect.jpg
Lens Model     : iPhone 7 Plus front camera
Date Original  : 2020:09:15 09:22:43
Flash          : Off, Did not fire
Light Source   : 1  (1 = daylight)
Zoom Ratio     : 0  (0 = no zoom)
Serial Number  : KCFGP71706722
GPS Position   : 40°41'45.9"N, 73°19'52.6"W

Checking the claims:

  • SUPPORTED "Taken with the suspect's iPhone 7 Plus": the lens model and serial number match.
  • SUPPORTED "No zoom was used": zoom ratio is 0.
  • REFUTED "She shielded her face from the flash": the flash never fired.
  • REFUTED "Taken inside a building": the light source is daylight, and there is a GPS fix.
  • SUPPORTED "Taken in Babylon, NY": those GPS coordinates land right there.

One photo, five answers. That is why investigators love metadata: the camera wrote it all down at the exact moment the shutter clicked, with no opinion and no memory problems. Want to get comfortable with tools like exiftool? Start with our command line interface tutorial.


The Method

The four-phase process

Real investigators do not just poke around and hope. Every digital forensics case follows the same four phases, in order, so the findings hold up when it matters:

1

Collect

Gather the evidence: seize the device, copy the files, export the logs. Get everything that might matter, legally (often with a search warrant).

2

Examine

Look closely at what you collected. Open the logs, read the metadata, list the timestamps. No conclusions yet, just careful observation.

3

Analyze

Connect the clues. Do the timestamps, logins, and searches line up into one story? Does the evidence support or refute each claim?

4

Report

Write up what you found and what it means, clearly enough for a judge, a jury, or a principal who has never read a log file.

Why the order matters: if you jump straight to analyzing before carefully collecting and examining, you risk missing evidence, or worse, accidentally changing it. In court, evidence that might have been altered is evidence that gets thrown out.


Interactive / Your Turn

Solve the case: the changed grade

Time to run all four phases yourself. The evidence below has already been collected for you. Examine each item by clicking it, and flag anything important into your evidence notebook. When you have flagged the three key clues, analyze them to pick the culprit, and the case feedback will be your report.

Case 24-0142: The Changed Grade

TRAINING CASE / 100% FICTIONAL

At Maplewood Middle School (go Otters!), teacher Ms. Okafor keeps her Period 3 gradebook in a file called grades_period3.csv on lab computer LAB-07. On Wednesday morning she noticed a quiz grade had mysteriously become an A+. Someone edited the file on Tuesday, October 14. Three students used LAB-07 that day.

Known: class ends 3:10 PM Known: 3 students used LAB-07 on Oct 14 Goal: who changed the file, and when?
Exhibit
The suspect lineup unlocks when your notebook holds all 3 key clues.

Everything above is invented for practice: fictional school, fictional students, fictional logs. Real investigations use the exact same reasoning, plus the strict evidence-handling rules you are about to learn.


Handle With Care

Keeping evidence intact

Here is the twist that makes digital forensics tricky: looking at digital evidence can change it. Simply opening a file can update its "last accessed" timestamp. If investigators are careless, a defense lawyer can argue the evidence was altered, and the whole case can collapse.

So investigators follow strict habits:

  1. Get permission first. Evidence is usually collected under a search warrant or with the owner's consent. Evidence gathered illegally cannot be used.
  2. Work on copies, never originals. The first move is making an exact bit-for-bit copy (a forensic image) of the drive or file. The original goes into secure storage; all examining happens on the copy.
  3. Keep a chain of custody. A written record of every single person who touched the evidence, when, and why. Any gap in the chain is a gap a lawyer can attack.
  4. Prove nothing changed. Investigators compute a hash of the evidence the moment it is collected, and again later. Matching hashes prove the copy is still byte-for-byte identical.

That last one, the hash, is the closest thing digital evidence has to a tamper-proof seal. Let's see it in action.


Interactive / Integrity Check

Hashes: the tamper alarm

A hash function turns any file into a short fingerprint of letters and numbers. The same file always produces the same fingerprint, but change even one character and the fingerprint changes completely. If you have read our blockchain tutorial, this is the exact same trick blockchains use to make their records tamper-evident.

Below is a sealed piece of evidence and the hash recorded when it was collected. Try tampering with it and watch the alarm go off:

Evidence Integrity Check

SIMPLIFIED DEMO
TAMPERED
exhibit_03 / statement.txt

            
Hash at collection (sealed)
Hash right now
MATCH: evidence is exactly as collected.

This demo uses a tiny toy hash so you can watch it change. Real forensics labs use heavy-duty hash functions like SHA-256, whose fingerprints are 64 characters long, and the one-character rule works exactly the same way.

Notice what changed: the edit swapped a single digit, but the hash became completely different, not just slightly different. That avalanche effect is why hashes make great seals: there is no way to make a "small" undetectable change.


Case Review

Quick quiz

1. What is the correct order of the four phases of a digital forensics investigation?

2. A photo's EXIF data showing the camera model, GPS location, and whether the flash fired is an example of...

3. Why does an investigator compute a hash of a file when collecting it, and again before trial?

Keep investigating

Case closed. You can now name the big types of digital evidence, run the collect-examine-analyze-report process, and explain how hashes and chain of custody keep evidence honest. Your next assignments are below.