Digital Forensics Basics: Collecting and Analyzing Evidence
Learn digital forensics fundamentals including evidence collection, forensic imaging, memory analysis, timeline analysis, and proper chain of custody procedures for investigations.
The Memory Dump That Convicted a Hacker
In 2011, a group calling itself "Anonymous" breached HBGary Federal and leaked 68,000 internal emails. During the investigation, forensic analysts captured memory dumps from compromised servers before anyone hit the power button. That single decision — acquiring RAM before disk — preserved running processes, active network connections, and decrypted credentials that would have vanished with a reboot. The evidence led directly to the attackers. Memory forensics proved that volatile data is often the most valuable data.
Digital forensics is the process of preserving, collecting, analyzing, and presenting digital evidence in a manner that is legally admissible. The fundamental principle is that digital evidence is fragile — improper handling can destroy or invalidate it.
Prerequisites
Forensic Principles
The Locard Exchange Principle
Every interaction leaves a trace. When an attacker compromises a system, they leave digital artifacts — registry modifications, log entries, file creations, memory artifacts, and network connections.
Order of Volatility
Digital evidence must be collected from most volatile to least volatile:
# Live response: collect volatile data first
# Order of execution matters
# 1. Running processes
ps aux > processes.txt
# 2. Network connections
netstat -anob > network.txt
# 3. Active network connections
lsof -i > connections.txt
# 4. Current user sessions
who /users > users.txt
# 5. System uptime and time
uptime && date > timing.txt
# 6. Loaded kernel modules
lsmod > modules.txt
Chain of Custody
Chain of custody is the documentation trail that shows evidence was handled properly from collection to courtroom presentation. Every transfer must be documented.
Chain of Custody Record
Evidence ID: DF-2026-001
Description: Forensic image of server FS-01
MD5 Hash: a1b2c3d4e5f6...
Date/Time Person Action Location
2026-06-01 14:00 John Doe (Analyst) Collected Server Room A
2026-06-01 16:30 John Doe (Analyst) Transferred Lab 2 to Evidence Locker
2026-06-02 09:00 Jane Smith (Analyst) Accessed Evidence Locker
...continue for each access...
Forensic Imaging
Write Blockers
Forensic imaging must never modify the source drive. Hardware write blockers prevent any writes to the source. Software write blockers provide an additional layer.
# Verify write blocker is working
# Device should show as read-only
dmesg | grep -i "write protected"
# Identify the target disk
lsblk
sudo fdisk -l
Creating Forensic Images
# DD imaging (bit-for-bit copy)
sudo dd if=/dev/sdb of=/evidence/disk_image.dd bs=4M conv=noerror,sync status=progress
# Verify integrity with SHA256
sha256sum /evidence/disk_image.dd > /evidence/disk_image.sha256
# Using Guymager (GUI forensic imager)
sudo guymager
# Creating EWF (EnCase) format
sudo ewfacquire /dev/sdb -t /evidence/case001
Memory Analysis
Memory contains volatile evidence: running processes, loaded DLLs, network connections, open files, decrypted data (passwords in clear), encryption keys, and rootkits.
Acquiring Memory
# Using LiME (Linux Memory Extractor)
insmod lime.ko "path=/evidence/ram.mem format=lime"
# Using avml (Acquire Volatile Memory Linux)
sudo ./avml /evidence/ram.mem
# Windows memory with winpmem
winpmem_mini_x64_rc2.exe /evidence/ram.raw
# Using FTK Imager (Windows GUI)
# File → Create Memory Image
Analyzing Memory with Volatility
# Identify the OS profile
volatility -f ram.mem imageinfo
# List running processes
volatility -f ram.mem --profile=Win10x64 pslist
volatility -f ram.mem --profile=Win10x64 pstree
volatility -f ram.mem --profile=Win10x64 psscan # Unlinked/hidden processes
# Network connections
volatility -f ram.mem --profile=Win10x64 netscan
# DLLs loaded by a specific process
volatility -f ram.mem --profile=Win10x64 dlllist -p 1234
# Extract command line arguments
volatility -f ram.mem --profile=Win10x64 cmdline
# Dump a process for analysis
volatility -f ram.mem --profile=Win10x64 memdump -p 1234 -D /evidence/
# Scan for injected code
volatility -f ram.mem --profile=Win10x64 malfind
# Registry hives in memory
volatility -f ram.mem --profile=Win10x64 hivelist
File System Analysis
Finding Suspicious Files
# Using The Sleuth Kit
# List files in an NTFS image
fls -o 2048 disk_image.dd
# Recover deleted files
icat disk_image.dd 65-128-1 > recovered_file.txt
# Timeline analysis
mac-robber /mnt/evidence > bodyfile.txt
mactime -b bodyfile.txt > timeline.csv
Windows Registry Analysis
# Using regripper or python-registry
# Extract registry hives
samparse SYSTEM SAM
Timeline Analysis
Timelines reconstruct the sequence of events. A timeline shows what happened and when, enabling investigators to identify the attack chain.
# Create a super timeline
sudo fls -r -m /evidence /dev/sdb1 > bodyfile
sudo mactime -b bodyfile -d > timeline.csv
# Analyze timeline for suspicious events
grep -i "powershell|wmic|psexec|schtasks" timeline.csv
Real-World Example: Forensics on a Compromised Server
Scenario: A Linux web server is suspected of compromise.
Common Mistakes
Best Practices
Related Tools
Related Articles
Summary
Digital forensics preserves and analyzes digital evidence for investigations. Key principles include the order of volatility, chain of custody, and working from copies. Core techniques include forensic imaging (dd, Guymager), memory analysis (Volatility), file system analysis (TSK), and timeline creation. Proper evidence handling, documentation, and adherence to forensic principles ensure findings are legally admissible.