kavklaw@llm $ cat forensics-stego-guide.md
โฑ๏ธ 25 min read ยท Analyze files, extract hidden data, and solve forensics CTF challenges
Most of these tools come pre-installed on Kali Linux. If you're on another distro (Ubuntu, Debian, Arch), install them individually:
# Core analysis tools (likely already on your system)
sudo apt install file binutils # file, strings, xxd
# File extraction & carving
sudo apt install binwalk foremost scalpel
# Metadata
sudo apt install libimage-exiftool-perl # exiftool
# Image steganography
sudo apt install steghide # JPEG/BMP/WAV/AU stego
sudo gem install zsteg # PNG/BMP LSB analysis
# Stegsolve (Java GUI โ download the JAR directly)
# wget https://github.com/Giotino/stegsolve/releases/latest/download/stegsolve.jar
# Run: java -jar stegsolve.jar
# Network forensics
sudo apt install wireshark tshark tcpflow
# Memory forensics
pip3 install volatility3
# Audio analysis
sudo apt install audacity sox
On Kali, most of these are already available. If a command isn't found, install the package above and you're set.
Got a mystery file in a CTF? Run this triage in under 60 seconds:
# Step 1: What IS this file?
# file identifies file types by examining internal signatures, not the extension
file mystery_file
# mystery_file: PNG image data, 1920 x 1080, 8-bit/color RGBA
# Step 2: Any strings hiding in there?
# strings extracts human-readable text from any file (even binaries)
strings mystery_file | head -50
strings -n 10 mystery_file | grep -iE "flag|ctf|key|password|secret"
# Step 3: Any embedded files?
# binwalk scans for files hidden inside other files (ZIP in a PNG, etc.)
binwalk mystery_file
binwalk -e mystery_file # Extract anything found
# Step 4: Check metadata
# exiftool reads hidden metadata (author, GPS, software, dates, comments)
exiftool mystery_file
# Step 5: Steganography checks (data hidden within normal-looking files)
steghide extract -sf mystery_file.jpg -p "" # JPEG/BMP/WAV/AU stego โ try empty password
zsteg mystery_file.png # PNG/BMP โ check for data in pixel bits
stegsolve # Visual bit-plane analysis (GUI)
# Step 6: Hex analysis
# xxd shows the raw bytes โ useful for checking file headers and hidden data
xxd mystery_file | head -20 # Check header/magic bytes
xxd mystery_file | tail -20 # Check footer/appended data
This covers 80% of CTF forensics challenges. Don't worry if some of these tools are unfamiliar โ each one is broken down below.
These three concepts are fundamentally different, and confusing them is a classic beginner mistake:
ENCODING โ transforms data for compatibility (NOT security). Reversible without any key/secret:
echo "Hello" | base64 # SGVsbG8=
echo "SGVsbG8=" | base64 -d # Hello
echo -n "Hello" | xxd -p # 48656c6c6f (hex encoding)
Also: URL encoding, ASCII, Unicode, ROT13, binary.
ENCRYPTION โ transforms data for CONFIDENTIALITY (requires a key). Reversible only WITH the correct key:
echo "Hello" | openssl enc -aes-256-cbc -a -salt -pass pass:MyKey
# U2FsdGVkX1+... (ciphertext โ meaningless without the key)
Symmetric: AES, DES, ChaCha20 (same key encrypts + decrypts). Asymmetric: RSA, ECC (public key encrypts, private key decrypts).
STEGANOGRAPHY โ HIDES data within other data. The carrier file looks normal. Examples:
In CTFs, you'll encounter all three. The challenge is figuring out WHICH technique was used, not necessarily breaking strong crypto.
The file command is your first tool. It identifies file types by examining magic bytes (the first few bytes of a file), not the file extension.
# Basic file identification
file mystery.bin
# mystery.bin: PNG image data, 800 x 600, 8-bit/color RGB
# The extension might be wrong!
file secret.txt
# secret.txt: Zip archive data, at least v2.0 to extract
# โ It's not a text file โ it's a ZIP disguised with .txt extension!
# Check multiple files at once
file *
# MIME type output (useful for scripting)
file --mime-type mystery.bin
# mystery.bin: image/png
# strings โ extract human-readable text from binary files
strings mystery.bin # Default: 4+ character strings
strings -n 8 mystery.bin # Minimum 8 characters
strings -e l mystery.bin # Little-endian 16-bit (Unicode)
strings -e b mystery.bin # Big-endian 16-bit (Unicode)
# Search for specific patterns
strings mystery.bin | grep -i "flag"
strings mystery.bin | grep -i "password"
strings mystery.bin | grep -oP "CTF{.*?}" # Flag format
strings mystery.bin | grep -oP "[A-Za-z0-9+/=]{20,}" | while read b; do echo "$b" | base64 -d 2>/dev/null; echo; done
# โ Find and decode base64 strings
# Look at the end of files (data often appended after the legitimate content)
tail -c 1000 mystery.jpg | strings
Every file format starts with specific bytes called "magic bytes" or "file signatures." Corrupted, modified, or hidden files can be identified by examining these bytes.
# View hex dump
xxd mystery.bin | head -20 # First 20 lines
xxd mystery.bin | tail -20 # Last 20 lines (check for appended data)
hexdump -C mystery.bin | head # Alternative hex viewer
Common magic bytes (file signatures):
PNG: 89 50 4E 47 0D 0A 1A 0A (โฐPNG....)
JPEG: FF D8 FF (รฟรรฟ)
GIF: 47 49 46 38 (GIF8)
BMP: 42 4D (BM)
PDF: 25 50 44 46 (%PDF)
ZIP: 50 4B 03 04 (PK..)
RAR: 52 61 72 21 (Rar!)
GZIP: 1F 8B (..)
7z: 37 7A BC AF (7z..)
ELF: 7F 45 4C 46 (.ELF)
EXE: 4D 5A (MZ)
PCAP: D4 C3 B2 A1 (libpcap)
SQLite: 53 51 4C 69 74 65 (SQLite)
File footer signatures:
PNG: 49 45 4E 44 AE 42 60 82 (IENDยฎB`โ)
JPEG: FF D9 (รฟร)
PDF: 25 25 45 4F 46 (%%EOF)
Fix corrupted magic bytes:
# Fix corrupted magic bytes
# Challenge gives you a file that doesn't open?
# Check if the header is corrupted:
xxd mystery.bin | head -1
# 00000000: 0000 4e47 0d0a 1a0a ...
# โ Should be 8950 for PNG! First 2 bytes are wrong
# Fix with hex editor or python:
printf '\x89\x50' | dd of=mystery.bin bs=1 count=2 conv=notrunc
# Or with Python:
python3 -c "
data = open('mystery.bin','rb').read()
fixed = b'\x89\x50' + data[2:]
open('fixed.png','wb').write(fixed)
"
# Check for data after file footer
# JPEG files end with FF D9. Anything after that is suspicious:
python3 -c "
data = open('image.jpg','rb').read()
end = data.find(b'\xff\xd9')
if end != -1 and end + 2 < len(data):
extra = data[end+2:]
print(f'Found {len(extra)} bytes after JPEG footer!')
open('hidden_data.bin','wb').write(extra)
"
๐ก Pro Tip: In CTFs, corrupted file headers are a classic challenge. Iffilesays "data" (unknown), check the first few bytes withxxdand compare against known magic bytes. Fix the header and the file opens, revealing the flag.
Binwalk scans a file for embedded files and executable code. It's one of the first tools to reach for in firmware analysis and CTF forensics.
# Scan for embedded files (don't extract)
binwalk mystery.bin
# DECIMAL HEXADECIMAL DESCRIPTION
# 0 0x0 PNG image, 800 x 600
# 491520 0x78000 Zip archive data
# 491634 0x78072 End of Zip archive
# โ There's a ZIP file hidden inside the PNG!
# Extract embedded files
binwalk -e mystery.bin
# Creates: _mystery.bin.extracted/ directory
# Inside: the extracted ZIP, PNG, and any other embedded files
# Recursive extraction (extract files within files)
binwalk -eM mystery.bin
# -M = matryoshka mode (recursive, like Russian nesting dolls)
# Entropy analysis (find encrypted/compressed sections)
binwalk -E mystery.bin
# High entropy (close to 1.0) = encrypted or compressed data
# Low entropy = plaintext or structured data
# Sudden entropy changes = file boundaries
# Scan for specific signatures
binwalk -R "\x89PNG" mystery.bin # Find PNG headers
binwalk -R "flag{" mystery.bin # Find flag strings
# Custom extraction with dd
# If binwalk finds something at offset 0x78000:
dd if=mystery.bin of=extracted.zip bs=1 skip=$((0x78000))
# Binwalk for firmware analysis:
binwalk firmware.bin
# Often reveals: bootloader, kernel, filesystem (squashfs, jffs2, cramfs)
binwalk -e firmware.bin
# Extracts the filesystem โ browse for configs, passwords, keys
File carving recovers files from raw data (disk images, memory dumps, network captures) by searching for file headers and footers, without relying on filesystem metadata (the file tables that normally track where files are stored). Think of it like finding whole pages in a shredded book by recognizing how pages start and end.
# foremost โ header/footer-based file carver
foremost -i disk_image.dd -o recovered/
foremost -i mystery.bin -o recovered/
# Creates directories: jpg/ png/ pdf/ zip/ etc.
# Each containing recovered files
# Customize foremost config for specific file types
cat /etc/foremost.conf
# You can add custom header/footer signatures
# scalpel โ faster, more configurable carver
scalpel -c /etc/scalpel/scalpel.conf -o recovered/ disk_image.dd
# Edit scalpel.conf to enable/disable specific file types:
# Uncomment the types you want to carve:
# jpg y 200000000 \xff\xd8\xff\xe0\x00\x10 \xff\xd9
# png y 200000000 \x89\x50\x4e\x47 \x49\x45\x4e\x44
# pdf y 200000000 \x25\x50\x44\x46 \x25\x25\x45\x4f\x46
# photorec โ the most powerful file carver (from TestDisk suite)
photorec disk_image.dd
# Interactive menu:
# 1. Select media type
# 2. Select partition type
# 3. Select filesystem type
# 4. Choose where to save recovered files
# Recovers hundreds of file types automatically
# bulk_extractor โ extracts useful information from disk images
bulk_extractor -o output/ disk_image.dd
# Extracts: email addresses, URLs, credit card numbers, phone numbers,
# network packets, JPEG images, GPS coordinates, etc.
Images are the most common steganography carrier in CTFs. Data can be hidden in multiple ways: metadata, appended data, least significant bits (the smallest bit in each color value, where a change is invisible to the human eye), color channels, or alpha transparency.
# Extract hidden data (with passphrase)
steghide extract -sf image.jpg -p "password"
# Extract with empty passphrase (common in CTFs!)
steghide extract -sf image.jpg -p ""
# Check if data is embedded (without extracting)
steghide info image.jpg
# Embed data (for understanding how it works)
steghide embed -cf cover.jpg -ef secret.txt -p "password"
# Brute force the passphrase with stegcracker
stegcracker image.jpg /usr/share/wordlists/rockyou.txt
# steghide supports JPEG, BMP, WAV, and AU cover files. For PNG, use zsteg/stegsolve
# zsteg โ detect LSB steganography in PNG and BMP images
zsteg image.png
# Output:
# b1,r,lsb,xy .. text: "flag{hidden_in_the_pixels}"
# b1,rgb,lsb,xy .. file: "PK\x03\x04" (ZIP archive)
# โ Found flag in red channel LSB!
# Check all channels and bit planes
zsteg -a image.png
# Extract specific payload
zsteg -e "b1,r,lsb,xy" image.png > extracted.txt
# Understanding zsteg output:
# b1 = bit 1 (LSB), b2 = bit 2, etc.
# r = red, g = green, b = blue, rgb = all channels
# lsb = least significant bit first
# xy = read pixels left-to-right, top-to-bottom
java -jar stegsolve.jar
Features:
Common stegsolve workflow: (1) Load the image, (2) Click through bit planes with โ โ arrows, (3) Look for hidden text, QR codes, or patterns in low bit planes, (4) If you have two images: use Image Combiner โ XOR.
# LSB (Least Significant Bit) steganography hides data in the lowest bit
# of each pixel's color value. Changing the LSB is invisible to the human eye.
# How it works:
# Original pixel: R=148 (10010100), G=200 (11001000), B=73 (01001001)
# Modified pixel: R=149 (10010101), G=200 (11001000), B=72 (01001000)
# โ bit=1 โ bit=0 โ bit=0
# Hidden bits: 1, 0, 0 โ part of a hidden message
# Extract LSB data with Python
from PIL import Image
img = Image.open("stego.png")
pixels = img.load()
width, height = img.size
binary = ""
for y in range(height):
for x in range(width):
r, g, b = pixels[x, y][:3]
binary += str(r & 1) # Extract LSB of red channel
# Convert binary to text
message = ""
for i in range(0, len(binary), 8):
byte = binary[i:i+8]
if len(byte) == 8:
char = chr(int(byte, 2))
if char == '\x00': # Null terminator
break
message += char
print(message)
# Other image stego tools:
# openstego โ Java-based stego tool
# jsteg โ JPEG steganography (DCT coefficients)
# Invisible Secrets โ Windows GUI tool
# OutGuess โ JPEG steganography
# pngcheck โ validate PNG structure (detect corrupted chunks)
๐ก Pro Tip: When you see an image in a CTF, always run this sequence:fileโexiftoolโstringsโbinwalkโsteghide(JPEG) orzsteg(PNG) โstegsolve. This covers 95% of image stego challenges. If nothing works, check if the image dimensions or palette are unusual โ data might be hidden in extra pixels or custom palette entries.
Audio files can hide information in spectrograms, frequency domains, waveform patterns, or embedded metadata.
Spectrogram analysis โ the most common audio stego technique. Open the audio in Audacity or Sonic Visualiser โ View โ Spectrogram. Hidden images/text appear as visual patterns!
Common tools: Audacity (free audio editor), Sonic Visualiser (specialized analysis), sox (command-line).
# Create a spectrogram image from audio:
sox audio.wav -n spectrogram -o spectrogram.png
# Check audio metadata
exiftool audio.mp3
exiftool audio.wav
# Strings in audio files (comments, hidden text)
strings audio.wav | grep -i flag
strings audio.mp3 | grep -i flag
# DTMF (Dual-Tone Multi-Frequency) โ the beep tones a phone makes when
# you press buttons. Each digit has a unique frequency pair; multimon-ng
# decodes the tones back into the numbers that were "dialed"
multimon-ng -t wav audio.wav
# Output: DTMF: 1 2 3 4 5 6 7 8 โ phone number or code
# SSTV (Slow-Scan Television) โ a method of transmitting images as audio
# signals (used by ham radio operators). Decode the audio back into an image:
sstv -d audio.wav -o output.png
# LSB audio steganography (similar to image LSB but on audio samples)
python3 -m wavsteg -r -i stego.wav -o extracted.txt -n 1 # 1 LSB per sample
# Check for embedded files in audio
binwalk audio.wav
# Reversed audio โ play backwards to hear hidden message
sox audio.wav reversed.wav reverse
Other techniques to check: Morse code (dots and dashes โ use online decoder). WAV files have a well-defined RIFF header โ extra chunks or data after the audio data may contain hidden content.
PDFs are complex documents that can contain embedded files, JavaScript, hidden text layers, and obfuscated content.
# Basic PDF analysis
file document.pdf
strings document.pdf | head -50
strings document.pdf | grep -i "flag\|password\|secret"
# pdftotext โ extract text (including hidden text layers)
pdftotext document.pdf output.txt
cat output.txt
# PDF metadata
exiftool document.pdf
pdfinfo document.pdf
# Extract embedded files from PDF
binwalk document.pdf
binwalk -e document.pdf
# pdf-parser โ analyze PDF structure
python3 pdf-parser.py document.pdf
python3 pdf-parser.py -f document.pdf # Filter for specific elements
python3 pdf-parser.py -o 5 document.pdf # Examine object #5
# peepdf โ interactive PDF analysis (find malicious content)
peepdf -i document.pdf
Useful peepdf commands: info (document info), tree (structure), js_analyse (find JavaScript), extract raw 5 > out.bin (extract stream from object #5).
# qpdf โ PDF manipulation (remove encryption, linearize)
qpdf --decrypt protected.pdf decrypted.pdf
qpdf --show-encryption protected.pdf
# PDF password cracking
pdfcrack -f protected.pdf -w /usr/share/wordlists/rockyou.txt
Common PDF tricks in CTFs:
Archive files (ZIP, RAR, 7z, tar.gz) are frequent CTF challenges. Common tricks include nested archives, password protection, corrupted headers, and hidden files.
# Basic ZIP examination
unzip -l archive.zip # List contents without extracting
unzip -t archive.zip # Test archive integrity
zipinfo archive.zip # Detailed ZIP information
# Password-protected ZIPs
unzip archive.zip # Prompts for password
# Crack with fcrackzip:
fcrackzip -u -D -p /usr/share/wordlists/rockyou.txt archive.zip
# -u = unzip to verify (important!)
# -D = dictionary mode
# -p = wordlist path
# Crack with john:
zip2john archive.zip > hash.txt
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
# Crack with hashcat:
zip2john archive.zip > hash.txt
# Extract hash, then:
hashcat -m 17200 hash.txt /usr/share/wordlists/rockyou.txt # PKZIP
hashcat -m 13600 hash.txt /usr/share/wordlists/rockyou.txt # WinZip
# ZIP known-plaintext attack (bkcrack)
# If you know part of a file inside the encrypted ZIP:
bkcrack -C encrypted.zip -c known_file.txt -p known_plaintext.txt
# Recovers internal keys โ decrypt all files!
# Even works with partial known plaintext (as few as 12 bytes)
# Nested archives (matryoshka)
# Challenge might have: flag.zip โ inside.tar.gz โ deeper.7z โ flag.txt
# Recursive extraction:
binwalk -eM archive.zip
# Or manually:
unzip archive.zip && cd extracted/
tar xzf inside.tar.gz && cd inside/
7z x deeper.7z
# RAR cracking
rar2john archive.rar > hash.txt
john hash.txt --wordlist=rockyou.txt
# ZIP bombs (be careful!)
# A small ZIP that expands to an enormous size
# Check before extracting: unzip -l archive.zip
# Look for suspiciously large uncompressed sizes
# CRC32 attack on small files
# If ZIP contains a very small file (1-6 bytes), you can brute force
# the content using the CRC32 checksum stored in the ZIP header
# Tool: https://github.com/kmyk/zip-crc-cracker
# exiftool โ the Swiss Army knife of metadata
exiftool image.jpg
# Shows: camera model, GPS coordinates, creation date, software,
# author, thumbnail images, color profiles, and MUCH more
# Specific metadata fields
exiftool -GPSLatitude -GPSLongitude image.jpg # GPS location
exiftool -Author -Creator image.pdf # Document author
exiftool -all image.jpg # Every possible field
# Check for hidden metadata
exiftool -v3 image.jpg # Verbose mode (raw data dumps)
# Thumbnail extraction (may differ from the main image!)
exiftool -b -ThumbnailImage image.jpg > thumbnail.jpg
# Sometimes the thumbnail is from a DIFFERENT photo (evidence tampering!)
# Metadata in different formats
exiftool document.docx # Office documents have rich metadata
exiftool audio.mp3 # ID3 tags (artist, album, comments)
exiftool video.mp4 # Creation date, GPS, device info
# Remove all metadata (for operational security)
exiftool -all= -overwrite_original image.jpg
# Compare metadata between two files
exiftool -a -G image1.jpg > meta1.txt
exiftool -a -G image2.jpg > meta2.txt
diff meta1.txt meta2.txt
# CTF metadata tricks:
# 1. Flag hidden in EXIF comment field
# 2. GPS coordinates that encode a message (convert to text)
# 3. Modified creation/modification dates that spell something
# 4. Custom XMP fields with hidden data
# 5. Thumbnail that shows the original (uncropped) image
Network forensics involves analyzing captured network traffic. This traffic is saved in PCAP files (Packet Capture โ a standard format that records every network packet that crossed the wire). You'll use these to reconstruct events, extract transferred files, and find hidden communications. Wireshark is the standard GUI tool for PCAP analysis โ it shows every packet with protocol details, lets you filter and search, and can reassemble entire conversations.
wireshark capture.pcap
Essential Wireshark display filters:
http # HTTP traffic only
dns # DNS queries
tcp.stream eq 5 # Follow specific TCP stream
frame contains "flag" # Search for string in packets
http.request.method == "POST" # POST requests (may contain creds)
ftp-data # FTP file transfers
smtp # Email traffic
ip.addr == 192.168.1.100 # Traffic to/from specific IP
Extract files from PCAP: Wireshark โ File โ Export Objects โ HTTP/SMB/TFTP/FTP/etc.
# Command-line PCAP analysis with tshark
tshark -r capture.pcap -q -z io,stat,1 # Traffic statistics
tshark -r capture.pcap -T fields -e http.request.uri # Extract HTTP URLs
tshark -r capture.pcap -T fields -e dns.qry.name | sort -u # DNS queries
tshark -r capture.pcap -Y "http.request.method==POST" -T json # POST data
# Extract HTTP objects
tshark -r capture.pcap --export-objects http,exported_files/
# Follow TCP streams (reconstruct conversations)
tshark -r capture.pcap -z follow,tcp,ascii,0 # Stream 0
tshark -r capture.pcap -z follow,tcp,ascii,1 # Stream 1
# tcpflow โ extract all TCP streams as files
tcpflow -r capture.pcap -o output/
# scapy โ Python packet manipulation
from scapy.all import *
packets = rdpcap("capture.pcap")
for pkt in packets:
if pkt.haslayer(Raw):
print(pkt[Raw].load)
Also consider NetworkMiner (Windows/Mono) for automatic PCAP analysis (extracts files, images, credentials, messages, DNS, sessions).
Common CTF PCAP analysis patterns:
Memory forensics analyzes RAM dumps (snapshots of a computer's memory) to extract running processes, network connections, passwords, encryption keys, and more. This is powerful because RAM often contains data that was never saved to disk, like decrypted passwords and active network sessions.
# Volatility 3 โ the standard memory forensics framework
# Install: pip3 install volatility3
# Identify the OS profile (Volatility 3 auto-detects)
vol -f memory.dmp windows.info
# List running processes
vol -f memory.dmp windows.pslist
vol -f memory.dmp windows.pstree # Tree view (parent-child)
vol -f memory.dmp windows.psscan # Find hidden/terminated processes
# Network connections
vol -f memory.dmp windows.netscan
# Shows: PID, local address, remote address, state
# Look for: connections to suspicious IPs, unusual ports
# Command-line history
vol -f memory.dmp windows.cmdline
# Shows what commands each process was started with
# Might reveal: passwords in arguments, file paths, attacker tools
# Environment variables
vol -f memory.dmp windows.envars
# Dump a specific process (extract its executable)
vol -f memory.dmp windows.dumpfiles --pid 1234
# Extract files from memory
vol -f memory.dmp windows.filescan # List all file objects in memory
vol -f memory.dmp windows.dumpfiles --virtaddr 0xFFFF...
# Registry analysis
vol -f memory.dmp windows.registry.hivelist # List loaded registry hives
vol -f memory.dmp windows.registry.printkey --key "Software\Microsoft\Windows\CurrentVersion\Run"
# โ Check autorun entries for persistence
# Password extraction
vol -f memory.dmp windows.hashdump # SAM database password hashes
vol -f memory.dmp windows.lsadump # LSA secrets
vol -f memory.dmp windows.cachedump # Cached domain credentials
# Browser history and credentials
vol -f memory.dmp windows.iehistory # Internet Explorer history (Volatility 2 plugin; not available in Volatility 3)
# Linux memory analysis
vol -f memory.dmp linux.bash # Bash history
vol -f memory.dmp linux.pslist # Process list
vol -f memory.dmp linux.check_syscall # Check for rootkits
# Strings search in memory dump
strings memory.dmp | grep -i "flag{"
strings memory.dmp | grep -i "password"
strings -e l memory.dmp | grep -i "flag" # Unicode strings
# Timeline analysis (chronological events)
vol -f memory.dmp timeliner.TimeLiner
๐ก Pro Tip: In CTF memory forensics challenges, always runwindows.pslistfirst (orlinux.pslistfor Linux). Look for unusual process names, processes with suspicious parent-child relationships, or known attacker tools (mimikatz, meterpreter, nc). Then dump those processes and analyze them. If this feels overwhelming, don't worry โ you'll only see a few of these commands in most CTF challenges. Start withpslistandcmdline, and you'll cover most beginner-level memory forensics problems.
# Disk forensics examines storage media for evidence
# Disk imaging (create a forensic copy)
dd if=/dev/sda of=disk.dd bs=4M status=progress
# Or with dcfldd (forensic-aware dd):
dcfldd if=/dev/sda of=disk.dd hash=sha256 hashlog=hash.txt
# Mount a disk image
sudo mount -o ro,noexec,loop disk.dd /mnt/evidence
# -o ro โ read-only (don't modify evidence!)
# -o noexec โ don't execute any binaries
# Analyze filesystem
fls -r disk.dd # List all files (including deleted!)
icat disk.dd INODE_NUM # Extract file by inode number (recover deleted files)
# Autopsy โ GUI forensic analysis (built on Sleuth Kit)
autopsy
# Web-based interface for browsing disk images
# Features: file recovery, timeline analysis, keyword search, hash analysis
# Sleuth Kit command-line tools:
mmls disk.dd # List partitions
fsstat -o OFFSET disk.dd # Filesystem statistics
fls -o OFFSET -r disk.dd # List files in partition
istat -o OFFSET disk.dd INODE # File metadata (timestamps, size, blocks)
# Recovering deleted files:
# When a file is "deleted," only the directory entry is removed.
# The actual data remains on disk until overwritten.
fls -d disk.dd # List deleted entries (-d flag)
icat disk.dd DELETED_INODE > recovered_file
# File system specific:
# NTFS: MFT (Master File Table) contains all file metadata
# Look for: $MFT, $LogFile, $UsnJrnl for timeline reconstruction
# ext4: inodes, journal, superblock
# FAT: directory entries, FAT table, data area
Forensics Triage Pipeline
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
mystery_file
โ
โผ
โโโโโโโโโโโโ "data"? โโโโโโโโโโโโโ
โ file โโโโโโโโโโโโโโถโ Fix magic โโโโถ Retry
โ command โ โ bytes โ
โโโโโโฌโโโโโโ โโโโโโโโโโโโโ
โ known type
โผ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ strings โ โ exiftool โ โ binwalk โ โ xxd โ
โ grep flagโ โ metadata โ โ embedded โ โ header/ โ
โ โ โ comments โ โ files โ โ footer โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโดโโโโโโโโโ
โผ โผ
Image/Audio? Archive/PCAP/Memory?
steghide/zsteg unzip/wireshark/volatility
Recognizing common patterns accelerates your CTF solving speed. Here are the most frequent challenge types:
# Pattern 1: Corrupted File Header
# file says "data" โ check hex โ fix magic bytes โ file opens โ flag inside
xxd challenge.bin | head -1
# Fix the first 2-8 bytes to match the expected file format
# Pattern 2: Data Appended After File Footer
# Normal-looking image โ extra data after JPEG's FF D9 or PNG's IEND
binwalk image.jpg
# Extract the appended data โ it's another file, a flag, or encoded text
# Pattern 3: LSB Steganography in PNG
# Normal-looking PNG โ flag hidden in least significant bits
zsteg image.png
# Or extract manually with Python/stegsolve
# Pattern 4: JPEG with steghide
# JPEG image โ steghide with empty password or simple password
steghide extract -sf image.jpg -p ""
stegcracker image.jpg rockyou.txt
# Pattern 5: Spectrogram in Audio
# WAV/MP3 file โ view spectrogram โ text/image visible
# Open in Audacity โ Spectrogram view
# Pattern 6: Nested Archives (Matryoshka)
# ZIP โ TAR โ GZ โ ZIP โ ... โ flag.txt
# Automate with: while true; do extract; done (recursive)
# Pattern 7: Memory Dump Analysis
# .vmem/.raw/.dmp file โ Volatility โ process list โ find suspicious process
# โ dump process โ analyze binary โ flag
# Pattern 8: PCAP Analysis
# Network capture โ follow TCP streams โ reconstruct file transfers
# Or: DNS exfiltration โ decode subdomain names โ flag
# Pattern 9: Base64/Hex/Binary Encoding Chain
# strings output shows: encoded data โ decode base64 โ hex โ binary โ flag
echo "Q1RGe2ZsYWd9" | base64 -d # CTF{flag}
# Pattern 10: EXIF Metadata
# Flag hidden in image EXIF comment, GPS coordinates, or custom fields
exiftool challenge.jpg | grep -i "comment\|description\|flag"
# Pattern 11: File Type Mismatch
# File extension doesn't match content โ rename with correct extension
file mystery.txt # "mystery.txt: PNG image data"
mv mystery.txt mystery.png && eog mystery.png
# Pattern 12: QR Code Hidden in Image
# After stego extraction or bit-plane analysis โ QR code appears
# Scan with: zbarimg extracted_qr.png
# Pattern 13: Whitespace Steganography
# Text file looks empty or normal โ hidden data in spaces/tabs
# Tool: stegsnow
stegsnow -C message.txt
# Or check for zero-width characters (Unicode steganography)
file โ identify the file typestrings โ look for readable cluesxxd โ check magic bytes and structureexiftool โ examine metadatabinwalk โ check for embedded filesโ Mistake #1: Trusting the file extension.
A.txtfile might be a ZIP. A.jpgmight be a PNG. Always usefileto check the actual type based on magic bytes. Rename with the correct extension before proceeding.
โ Mistake #2: Not trying empty passwords.
In CTFs,steghidewith an empty password (-p "") is extremely common. Always try it before reaching for password cracking tools. Also try the challenge name, the filename, and "password" as passwords.
โ Mistake #3: Forgetting to check the end of the file.
Data appended after a file's legitimate footer (after JPEG'sFF D9or PNG'sIEND) is a classic hiding technique.binwalkcatches this, but manualxxd | tailinspection is also valuable.
โ Mistake #4: Only using one stego tool.
steghideonly works on JPEG/BMP.zstegonly works on PNG/BMP.stegsolveis visual only. Use the right tool for the right format, and try multiple tools โ each detects different hiding methods.
โ Mistake #5: Ignoring audio spectrograms.
If you get a WAV or MP3 file that sounds like noise, static, or even normal music, always check the spectrogram in Audacity. Hidden images and text in spectrograms are one of the most common audio stego techniques.
โ Mistake #6: Not reading challenge hints.
CTF challenge descriptions and titles often hint at the technique. "Invisible" suggests steganography. "Layers" suggests image bit planes or nested archives. "Echo" might mean audio stego. "Dead memory" means memory forensics. Read the hints!
โ Mistake #7: Skipping strings on binary files.
Runningstringsis trivial and often reveals flags, passwords, or clues hiding in plain sight within binary data. Always do it, even if the file type seems obvious.
binwalk scans binary files for embedded signatures (ZIP, gzip, ELF, JPEG, etc.) and can extract them with binwalk -e file. It's the first tool to run on any unknown file in a CTF.$ steghide image.jpg
steghide extract -sf image.jpg extracts hidden data from a JPEG or BMP file. If password-protected, add -p password. Use steghide info image.jpg first to check if data is embedded.zsteg detects LSB steganography in PNG and BMP files. Run zsteg image.png to check all bit planes. steghide doesn't support PNG โ this is a common CTF mistake.file command check to identify file types?file command reads magic bytes โ signature patterns at the start of files. For example, FF D8 FF = JPEG, 89 50 4E 47 = PNG, 50 4B 03 04 = ZIP. This is why renaming a .exe to .jpg doesn't fool forensic tools.file reports as a PNG, but the image looks normal. What should you try first?strings image.png | less (hidden text), exiftool image.png (metadata/comments), binwalk -e image.png (embedded files), and zsteg image.png (LSB stego). Run all of them โ flags can hide anywhere.vol3 -f dump.raw windows.pslist lists all processes. windows.pstree shows the parent-child hierarchy. For hidden processes, use windows.psscan which scans pool tags instead of the active process list.FF D9 or PNG's IEND chunk) is invisible to image viewers but detectable with binwalk or xxd | tail. This is one of the most common CTF stego techniques.sonic-visualiser offers even more advanced spectrogram options.