GO KALI FREE

Foremost

Forensics

Beginnerlow risk

Foremost is a forensic data recovery program that recovers files based on their headers, footers, and internal data structures.

Installation

sudo apt install foremost

Basic Syntax

foremost -i <input> -o <output>

Quick Facts

Full Name
Foremost File Carving Tool
License
Public Domain
Author
United States Air Force
Written In
C
Platforms
Linux, macOS, Windows (Cygwin)
Category
File Carving / Data Recovery
First Release
2001
Key Feature
Header/Footer Based File Recovery

Tool Overview

Foremost is a forensic file carving tool originally developed by the United States Air Force Office of Special Investigations. It recovers files from disk images by scanning for known file headers, footers, and internal data structures.

Foremost works by reading through a raw disk image or partition dump and identifying file boundaries based on signature matching. Once a file header is found, Foremost carves the data until the corresponding footer is reached or a maximum file size limit is hit.

While Foremost is fast and lightweight, it is limited to recovering contiguous file data and cannot handle fragmented files. For more comprehensive recovery, tools like PhotoRec or Scalpel may be more appropriate.

Quick Reference Commands

Verified quick-reference commands for Foremost
CommandPurpose
foremost -i <image> -o <new-output-directory>Carve default file types from an image.
foremost -t jpg,pdf -i <image> -o <new-output-directory>Restrict carving to selected types.
foremost -w -i <image> -o <new-output-directory>Create only the audit report.
foremost -q -i <image> -o <new-output-directory>Use quick sector-start searching.
foremost | Kali Linux Tools

Common Commands

foremost image.ddCarve files from an image using the default config, writing to ./output
foremost -i image.dd -o outputExplicitly set the input file and output directory
foremost -t jpg -i image.ddRecover only JPEG files from the image
foremost -t jpg,pdf,doc -i image.dd -o recoveredCarve a comma-separated list of file types into a custom directory
foremost -t all -i image.dd -o outputAttempt to recover every file type known to foremost
foremost -i /dev/sdb -o carvedCarve directly from a raw block device
foremost -v -t png -i image.ddVerbose mode: log all messages to the screen while carving PNGs
foremost -T -t jpg -i image.ddAppend a timestamp to the output directory so it is not overwritten
foremost -c /etc/foremost.conf -i image.ddUse a specific configuration file defining headers/footers
foremost -w -i image.dd -o audit_onlyOnly write the audit.txt file; do not extract files to disk
foremost -a -t jpg -i image.ddWrite all headers and perform no error detection (recover corrupted files)
foremost -q -i image.ddQuick mode: search only on 512-byte boundaries for speed
foremost -Q -i image.dd -o outputQuiet mode: suppress on-screen output messages
foremost -d -i image.ddTurn on indirect block detection (for UNIX file systems)
foremost -b 1024 -i image.ddSet the block size used during the search (default 512)
foremost -s 1024 -i image.ddSkip the first N bytes of the input before beginning the search
foremost -t pdf -o pdfs -i disk.imgExtract all PDF documents from a disk image
foremost -t exe,zip,rar -i memory.ddCarve executables and archives from a memory dump
foremost -t jpg,gif,png,bmp -i image.dd -o imagesRecover common image formats into an images directory
foremost -t ole -i image.ddRecover OLE/legacy Microsoft Office documents (doc/xls/ppt)
foremost -v -T -t all -i /dev/sda1 -o /path/to/outputVerbose, timestamped, full carve of a partition to a set output path
sudo foremost -i /dev/sdb -o /mnt/recoveryRun with elevated privileges to read a raw device
cat output/audit.txtReview the audit log summarizing every file foremost carved
foremost -hPrint usage and the full list of options
foremost -VDisplay copyright/version information and exit

Step-by-Step Guide

  1. 1Secure a forensic copy of the target storage media
  2. 2Launch the carving process specifying your input image and output directory
  3. 3Navigate to the newly populated output folders
  4. 4Examine the carved files to see what was recovered
  5. 5Log your findings for evidence documentation

Warnings

Use Cases

Deleted File Recovery

Recover files that have been deleted from storage media by carving them based on file signatures.

Disk Image Analysis

Extract files from forensic disk images created with dd or other imaging tools.

Evidence Collection

Salvage files from damaged or corrupted storage media for forensic investigation.

Data Loss Investigation

Recover accidentally lost files from formatted or corrupted partitions.

Key Features

Related Tools

Autopsy

Forensics

Learn how to use Autopsy, the free digital forensics software, in a hands-on practice case. Start with a verified disk image, run ingest modules, look for deleted files, and use keyword hits and timeline entries to build a report.

ExifTool

Forensics

ExifTool is a platform-independent tool for reading, writing, and editing metadata in a wide variety of files including images, audio, and video.

Binwalk

Forensics

Learn how to use Binwalk to scan a firmware image, read the signature table, extract embedded filesystems, and spot encrypted regions — a beginner tutorial for Kali Linux.

Steghide

Forensics

Steghide is a steganography tool designed to hide confidential data inside various types of image and audio files without altering their outward appearance.

Volatility

Forensics

Volatility is an advanced open-source memory forensics framework used for incident response and malware analysis, allowing extraction of digital artifacts from volatile memory (RAM) samples.

ADB

Reverse Engineering

ADB, or Android Debug Bridge, is a versatile command-line tool that acts as a client-server program, facilitating communication between your development machine (the client) and an Android device (running the adbd daemon) via a server process binding TCP port 5037. It ships as part of the Android SDK Platform Tools, and on Kali Linux, it's available as the `android-tools-adb` package. ADB is the standard device bridge for Android mobile pentesting and forensics, enabling actions like deploying Frida servers, pulling APKs, and capturing detailed logcat output for analysis.

Related Cybersecurity Guides

Security Operations · Advanced

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.

Security Operations · Advanced

Detection Engineering: Creating Security Alerts and Rules

Learn detection engineering principles including rule development, Sigma rules, testing methodologies, false positive management, and building a detection program for security operations.

Security Operations · Advanced

Incident Response: Structured Approach to Security Breaches

Learn the incident response lifecycle including preparation, detection, containment, eradication, recovery, and lessons learned with practical frameworks and real-world scenarios.

Security · Intermediate

Credential Stuffing: Automated Account Takeover Attacks

Learn about credential stuffing attacks that use leaked credentials from data breaches to automate account takeover across different services.

Frequently Asked Questions

What is Foremost used for?

Foremost is a forensic file carving tool used to recover deleted or lost files from disk images based on their headers, footers, and internal data structures. It is commonly used in incident response and digital forensics.

Can Foremost recover fragmented files?

No, Foremost recovers only contiguous file data. Fragmented files may be partially recovered or not recovered at all. For fragmented file recovery, consider tools like PhotoRec or Scalpel.

What file types does Foremost support?

Foremost supports dozens of file types including JPG, GIF, PNG, PDF, DOC, ZIP, RAR, MP3, MP4, ELF, and more. The full list is configurable in the foremost.conf configuration file.

Is Foremost the same as PhotoRec?

Both are file carving tools, but Foremost focuses on header/footer matching while PhotoRec uses a more comprehensive approach including journal-based recovery and filesystem-aware carving.

Tags

#forensics#data-carving#recovery

Output Explanation

Generates a folder structure containing the salvaged files, automatically sorted into subdirectories based on their file extensions.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.