Skip to content

Foremost

60 commands

Recovers files from disk images and raw data by carving their headers and footers, even without a file system.

  • file carving
  • recovery
  • DFIR

Install Foremost

sudo apt install foremost

Basic Usage3

foremost -h

Displays the help screen with a summary of available command line options

foremost -V

Displays the current version information and copyright details of the tool

foremost [image_file]

Carves recoverable files from a disk image using default settings and signatures

Link

Input Handling1

foremost -i [input_file]

Explicitly specifies the input file or image to be processed for file carving

Link

Output Control5

foremost -o [output_dir] -i [image_file]

Specifies a custom output directory to store the recovered files and report

Link
foremost -T -i [image_file]

Appends a timestamp to the output directory name to prevent overwriting previous results

Link
foremost -v -i [image_file]

Enables verbose mode to display detailed processing information to the screen

Link
foremost -Q -i [image_file]

Enables quiet mode to suppress output messages and protect privacy during processing

Link
foremost -o /tmp/recovery -i [image_file]

Directs output to a temporary filesystem to avoid writing to evidence handling drives

Link

File Type Carving18

foremost -t all -i [image_file]

Attempts to carve all supported file types defined in the configuration

Link
foremost -t jpg -i [image_file]

Restricts file carving specifically to JPEG image files

Link
foremost -t png -i [image_file]

Restricts file carving specifically to PNG image files

Link
foremost -t gif -i [image_file]

Restricts file carving specifically to GIF image files

Link
foremost -t pdf -i [image_file]

Restricts file carving specifically to PDF documents

Link
foremost -t doc -i [image_file]

Restricts file carving specifically to legacy Microsoft Word documents

Link
foremost -t ole -i [image_file]

Carves OLE compound files like PowerPoint, Word, Excel, and MSI installers

Link
foremost -t zip -i [image_file]

Carves ZIP archives and formats based on ZIP containers like Jar and Office XML

Link
foremost -t html -i [image_file]

Carves HTML files which is useful for reconstructing web browsing history

Link
foremost -t exe -i [image_file]

Carves Windows PE executables which is critical for malware analysis

Link
foremost -t jpg,pdf -i [image_file]

Carves only JPEG images and PDF documents simultaneously

Link
foremost -t wav,rif -i [image_file]

Targets audio files specifically for voice recorder forensics

Link
foremost -t bmp -i [image_file]

Recovers uncompressed bitmap images often found in older systems or steganography

Link
foremost -t htm -i [image_file]

Separately targets HTM extensions if distinguished from HTML in config

Link
foremost -t cpp,c,h -i [image_file]

Attempts to recover C/C++ source code files based on headers if configured

Link
foremost -t gz,tgz -i [image_file]

Recovers GZIP compressed files common in Unix/Linux environments

Link
foremost -t ppt,xls,doc -i [image_file]

Specifically targets pre-2007 Microsoft Office binary formats

Link
foremost -t pptx,xlsx,docx -i [image_file]

Specifically targets modern XML-based Microsoft Office formats (requires config)

Link

Configuration & Tuning4

foremost -c [config_file] -i [image_file]

Uses a specific configuration file with custom headers and footers

Link
foremost -b [size] -i [image_file]

Sets the block size used for reading the input file to optimize performance

Link
foremost -k [size] -i [image_file]

Sets the chunk size for checking headers which helps with alignment

Link
foremost -s [sectors] -i [image_file]

Skips the specified number of blocks before starting the extraction process

Link

Audit & Logging2

foremost -w -i [image_file]

Writes an audit file only without actually extracting any files to disk

Link
foremost -q -i [image_file]

Enables Quick mode to search only at sector boundaries for faster processing

Link

Advanced Options4

foremost -d -i [image_file]

Enables indirect block detection for Unix file systems to handle fragmentation

Link
foremost -a -i [image_file]

Writes all headers found even if no footer is detected which allows partial recovery

Link
foremost -T -v -q -i [image_file]

Combines timestamp, verbose, and quick mode for rapid on-site triage

Link
foremost -d -T -i [image_file]

Uses indirect block detection with timestamped output for Linux partitions

Link

Combined Workflows2

foremost -v -T -t all -i [image_file]

Carves all files with verbose logging and timestamped output for case management

Link
foremost -Q -o [dir] -t jpg,png -i [image_file]

Quietly extracts only common image formats to a specific directory

Link

Incident Response4

foremost -t exe,elf -o [dir] -i [image_file]

Targets executable binaries for Windows and Linux to isolate potential malware

Link
foremost -t rar,zip,7z -i [image_file]

Focuses on archive formats often used by attackers for data exfiltration

Link
foremost -t sxw,sxc,sxi -i [image_file]

Targets OpenOffice documents useful for Linux desktop investigations

Link
foremost -t wmv,wma -i [image_file]

Recovers Windows Media formats to identify unauthorized media usage

Link

Digital Forensics3

foremost -s 63 -t all -i [image_file]

Skips the standard track 0 area to start carving at the first partition start

Link
foremost -c foremost.conf -v -w -i [image_file]

Validates a custom config file against an image with verbose audit logging

Link
foremost -s 100 -b 512 -i [image_file]

Skips the first 100 blocks on a legacy media with small block size

Link

Blue Team Validation2

foremost -t log -i [image_file]

Attempts to recover deleted log files to reconstruct event timelines

Link
foremost -v -i [image_file] > carving.log 2>&1

Redirects verbose output to a log file for post-incident documentation

Link

Data Recovery2

foremost -a -t mpg,avi,mov -i [image_file]

Forcefully recovers video fragments without footers from DVR systems

Link
foremost -b 4096 -t all -i [image_file]

Adjusts block size to 4096 bytes for modern advanced format drives

Link

Advanced Carving1

foremost -k 1024 -q -i [image_file]

Uses a larger chunk size with quick mode for rapid memory artifact assessment

Link

Configuration2

foremost -c /etc/foremost.conf -t all -i [image_file]

Explicitly calls the system-wide configuration file for standard processing

Link
foremost -c local.conf -o specialized -i [image_file]

Uses a local config for proprietary file headers outputting to a named folder

Link

Advanced Workflows2

foremost -o ./audit_run -w -t all -i [image_file]

Performs a dry run to estimate recoverable data types without writing files

Link
foremost -t all -i - < [image_file]

Accepts input from stdin allowing for piping from other tools like netcat or dd

Link

Pipeline Workflow1

foremost -o raw_carve -i [image_file] && zip -r case.zip raw_carve

Chains foremost execution with zip to immediately archive the recovered evidence

Link

Triage1

foremost -q -t jpg -T -i [image_file]

Runs a quick mode scan for JPEGs with timestamping for rapid media triage

Link

Validation1

foremost -w -c custom_headers.conf -i [image_file]

Audits a disk image against custom headers to verify signature effectiveness

Link

Forensics1

foremost -o evidence/ -v -d -i [image_file]

Combines indirect block detection and verbose mode into a dedicated evidence folder

Link

Full Recovery1

foremost -t all -a -v -T -i [image_file]

Runs the most aggressive recovery mode with all types, header-only writing, and logs

Link