← Back to Tools
Forensics

Foremost

File carving tool that recovers deleted files based on file headers and footers.

Category
Forensics
Platform
Linux / Kali
Type
CLI / Open Source
Skill Level
Beginner → Intermediate

What is Foremost?

Foremost is a file carving tool originally developed by the US Air Force Office of Special Investigations. It recovers deleted or hidden files from disk images, memory dumps, or raw storage devices by scanning for known file headers and footers — without needing a filesystem. It is commonly used in CTF forensics challenges and real-world incident response to retrieve images, documents, and archives from evidence images.

⚠ Legal Notice

Only use on systems you own or have explicit written permission to test. Unauthorized use violates Pakistan's PECA 2016 and international cybercrime laws.

Installation

# Update packages
sudo apt update

# Install (if not already on Kali)
sudo apt install foremost -y

# Verify installation
foremost -h

Basic Usage

# Carve all supported file types from a disk image
foremost -i image.dd -o ./output/

# Carve only specific file types (jpg and png)
foremost -t jpg,png -i image.dd -o ./output/

# Carve from a raw device (e.g. USB drive)
sudo foremost -i /dev/sdb -o ./recovered/

# Run in verbose mode to see progress
foremost -v -i image.dd -o ./output/

# Carve from a .pcap network capture
foremost -i capture.pcap -o ./extracted/

# View the audit log after carving
cat ./output/audit.txt

Supported File Types (-t flag)

Common Use Cases

Further Reading

Practice on legal targets like TryHackMe, HackTheBox, or hackzia.site labs. Always read the official documentation before using in a live engagement.