Lesson 5 of 10
Digital Forensics Fundamentals
Digital forensics is the science of collecting, preserving, and analyzing digital evidence in a manner admissible in legal proceedings. Proper forensic methodology ensures evidence integrity and chain of custody.
Evidence Acquisition & Chain of Custody
# Golden rule: Preserve evidence before analysis
# Any modification to evidence (even reading) must be documented
# 1. Disk Imaging - create bit-for-bit copy (never analyze original)
# Using dd (basic but reliable)
dd if=/dev/sda of=/secure-storage/disk_image.dd bs=4M status=progress
# Using dcfldd (forensic dd with hashing)
dcfldd if=/dev/sda of=/secure-storage/disk.dd hash=sha256 hashlog=/secure-storage/hash.txt conv=sync,noerror
# Using Guymager (GUI forensic imager) - recommended for court admissibility
# Creates E01 (Expert Witness Format) with embedded hash verification
# CRITICAL: Write-block the evidence drive before imaging!
# Hardware write blockers: Tableau T35u, FRED (Forensic Recovery of Evidence Device)
# Software: hdparm -r1 /dev/sda (Linux read-only mode)
# 2. Hash the original before and after - verify no modification
sha256sum /dev/sda > /secure-storage/original_hash.txt
# After imaging, hash the image and compare:
sha256sum disk.dd | diff - original_hash.txt
# MUST match - any difference means evidence was modified
# 3. Chain of custody documentation (critical for legal admissibility)
cat >> /secure-storage/chain_of_custody.txt << EOF
Item: Seagate 500GB SSD
Model/Serial: SSD-500/SN: XYZ123456
Acquired by: Jane Smith (CFCE #4521)
Date/Time: $(date -u '+%Y-%m-%d %H:%M:%S UTC')
Location: Server Room, Rack 3, Unit 14
Hash (SHA256): $(sha256sum disk.dd | cut -d' ' -f1)
Reason for collection: Suspected ransomware incident
Storage: Evidence locker #42, tamper-evident bag #IR-2025-001
EOFFile Recovery & Artifact Analysis
# Autopsy / Sleuth Kit - open source forensic platform
# Mount image for analysis (read-only)
losetup -r /dev/loop0 disk.dd
mount -o ro /dev/loop0 /mnt/evidence
# Sleuth Kit CLI tools
mmls disk.dd # Partition layout
fls -r disk.dd # File system listing (including deleted files)
icat disk.dd 12345 > recovered.pdf # Extract file by inode number
# Timeline analysis - ALL file system events
mactime -b $(fls -rm disk.dd) > timeline.csv
# M = Modified, A = Accessed, C = Changed (metadata), B = Born (created)
# Sort timeline to see what happened and when
# Search for keywords across entire disk image (unallocated space too)
grep -ab "password" disk.dd | head -20 # Search for "password" in binary
bulk_extractor disk.dd -o bulk_output/ # Extract emails, URLs, credit cards, keys
# Web browser artifacts
# Chrome/Edge history (SQLite database)
sqlite3 "/mnt/evidence/Users/Alice/AppData/Local/Google/Chrome/User Data/Default/History" "SELECT url, title, datetime(last_visit_time/1000000-11644473600, 'unixepoch') as time FROM urls ORDER BY time DESC LIMIT 50;"
# Windows Registry forensic artifacts
# Most recently used files, USB device history, user profiles, installed software
python3 -m pip install regipy
regdump /mnt/evidence/Windows/System32/config/SAM # User account databaseCommon Mistakes
- Working on the original evidence - ALWAYS image first, work on the copy. Modifying original evidence is inadmissible in court and may destroy irreplaceable evidence
- Not hashing evidence before and after - without hash verification, opposing counsel can argue evidence was tampered with
- Forgetting NTFS alternate data streams - malware can hide in ADS (Alternate Data Streams): notepad.exe:hidden_malware.exe. Use: dir /r to list ADS in Windows
Tip
Tip
Practice Digital Forensics Fundamentals in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Practice Task
Note
Practice Task - (1) Write a working example of Digital Forensics Fundamentals from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Digital Forensics Fundamentals is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- Digital forensics is the science of collecting, preserving, and analyzing digital evidence in a manner admissible in legal proceedings.
- Working on the original evidence - ALWAYS image first, work on the copy. Modifying original evidence is inadmissible in court and may destroy irreplaceable evidence
- Not hashing evidence before and after - without hash verification, opposing counsel can argue evidence was tampered with
- Forgetting NTFS alternate data streams - malware can hide in ADS (Alternate Data Streams): notepad.exe:hidden_malware.exe. Use: dir /r to list ADS in Windows
Finished this lesson?