foremost
Foremostは、削除されたファイルの復元や、ディスクイメージやメモリダンプから痕跡を抽出する際に役立ち、誤って消してしまった写真の復旧や、CTFのデータからファイルを抜き出すなど、データ復旧作業を支援するSkill。
📜 元の英語説明(参考)
Recover deleted files and carve artifacts from disk images and memory dumps with Foremost. Use when a user asks to extract files from a raw disk image, recover accidentally deleted photos, pull embedded files out of a CTF blob, or carve artifacts from unallocated space.
🇯🇵 日本人クリエイター向け解説
Foremostは、削除されたファイルの復元や、ディスクイメージやメモリダンプから痕跡を抽出する際に役立ち、誤って消してしまった写真の復旧や、CTFのデータからファイルを抜き出すなど、データ復旧作業を支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o foremost.zip https://jpskill.com/download/14913.zip && unzip -o foremost.zip && rm foremost.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14913.zip -OutFile "$d\foremost.zip"; Expand-Archive "$d\foremost.zip" -DestinationPath $d -Force; ri "$d\foremost.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
foremost.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
foremostフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Foremost
概要
Foremost はファイルカービングツールです。生のディスクイメージ、メモリダンプ、または任意のblobをバイト単位でスキャンし、マジックヘッダーとフッターを探し、見つかったファイルをタイプごとに整理されたディレクトリに書き出します。ファイルシステムのメタデータは気にしません。JPEG、PNG、PDF、ZIP、Officeドキュメント、MP3などを識別するディスク上のバイトを探します。そのため、ファイルシステムが忘れてしまったファイルを復元したり、blobに複数の埋め込みファイルが隠されているCTFチャレンジに適したツールです。
手順
ステップ 1: ディスクイメージの作成(ライブデバイスを直接カービングしないこと)
# 必ずイメージから作業し、ソースデバイスを直接操作しないでください
sudo dd if=/dev/sdb of=disk.img bs=4M status=progress conv=noerror,sync
# または dcfldd (ハッシュ機能付きの dd のフォレンジック版) を使用
sudo dcfldd if=/dev/sdb of=disk.img bs=4M hash=sha256 hashlog=disk.sha256
# 作業前に整合性を確認
sha256sum disk.img
cat disk.sha256
ステップ 2: Foremost の実行
# デフォルト実行 — 組み込み設定を使用、すべてのサポートされているタイプ
foremost -i disk.img -o recovered/
# 特定のタイプのみ (jpg, png, pdf, zip, doc, mp3, ...)
foremost -t jpg,png,pdf -i disk.img -o recovered/
# 詳細表示 + クイックモード (ファイルヘッダーのみをスキャン、高速)
foremost -v -q -t all -i disk.img -o recovered/
# 出力ツリー
tree -L 2 recovered/
# recovered/
# ├── audit.txt
# ├── jpg/
# │ ├── 00000001.jpg
# │ └── 00000125.jpg
# ├── pdf/
# │ └── 00000007.pdf
# └── zip/
# └── 00000042.zip
ステップ 3: 監査ファイルの確認
# カービングされたものの概要
cat recovered/audit.txt
# Foremost version 1.5.7 by Jesse Kornblum ...
# Num Name (bs=512) Size File Offset Comment
# 0: 00000001.jpg 185 KB 16384
# 1: 00000007.pdf 1 MB 67108864
# タイプごとのファイル数をカウント
find recovered -type f -not -name audit.txt | awk -F/ '{print $(NF-1)}' | sort | uniq -c
ステップ 4: foremost.conf によるカスタムファイルタイプ
# デフォルト設定をコピー
cp /etc/foremost.conf ./foremost.conf
# シグネチャを追加: extension case max-size header footer
# 例: 'CTFFLAG' で始まり 'END' で終わるカスタム "FLAG" バイナリ
cat >> foremost.conf <<'EOF'
flag y 5000 CTFFLAG END
EOF
# カスタム設定で実行
foremost -c ./foremost.conf -i challenge.bin -o out/
ls out/flag/
ステップ 5: 他のカーバーとの組み合わせ
# scalpel は Foremost の高速なフォークです。Foremost が遅すぎる場合に使用します
sudo apt install scalpel
scalpel -c /etc/scalpel/scalpel.conf -o scalpel-out disk.img
# binwalk — ファームウェアと組み込みファイルシステムに適しています
binwalk -e firmware.bin
# photorec — インタラクティブ、写真/ビデオの復元に強力
sudo photorec /dev/sdb
# strings + file — 最初のトリアージ
strings -a disk.img | less
file recovered/jpg/00000001.jpg
例
例 1: フォーマットされた SD カードから写真を復元する
# SD カードを接続 — マウントしないでください。また、何も書き込まないでください
lsblk
# sdb 1 29.8G 0 disk
# └─sdb1 1 29.8G 0 part
# カードをイメージ化
sudo dd if=/dev/sdb of=sdcard.img bs=4M status=progress
sudo sha256sum sdcard.img > sdcard.sha256
# カードを取り外し、イメージのみから作業
foremost -t jpg,png,raw,mov,mp4 -i sdcard.img -o photos/
ls photos/jpg | wc -l
# 842
# サイズでソートして、実際の写真とサムネイルを見分ける
find photos/jpg -type f -printf '%s %p\n' | sort -nr | head
例 2: CTF — PNG の中に隠されたファイル
# チャレンジ: "この無害な画像の中に何かが隠されています。"
file challenge.png
# challenge.png: PNG image data, 1920 x 1080, ...
# Foremost は、PNG の上部だけでなく、blob 全体をスキャンします
foremost -t all -i challenge.png -o carved/
cat carved/audit.txt
# 0: 00000000.png 2 MB 0
# 1: 00000001.zip 45 KB 2097664
# 2: 00000002.pdf 1 MB 2143000
# カービングされた ZIP を検査
unzip -l carved/zip/00000001.zip
# flag.txt
unzip -p carved/zip/00000001.zip flag.txt
# flag{foremost_carves_everything}
ガイドライン
- ライブでマウントされたデバイスに対して Foremost を実行しないでください。 常に最初にイメージを作成し、イメージをハッシュしてからカービングしてください。
- ソースメディアを書き込み禁止にしてください(物理的な書き込みブロッカー、または少なくとも読み取り専用でマウント)して、証拠の保全性を維持してください。
- カービングはシグネチャベースです。ファイル名やディレクトリ構造を復元することはできません。メタデータは失われます。
- 重複または断片化されたファイルは、うまく再構築されません。断片化が激しいディスクの場合は、最初に
photorecまたはextundelete/testdiskのようなファイルシステムを認識するツールを試してください。 - 出力ディレクトリは事前に存在してはなりません。Foremost は上書きを拒否します。
- Foremost はシングルスレッドであり、大きなイメージでは遅いです。
scalpelは同じジョブのためのより高速なフォークです。 - CTF では、
foremost -t all -i challenge.blobを反射的に試してください。binwalkが見逃すことがある埋め込み ZIP、PDF、および画像を見つけます。 - 復元されたアーティファクトに対して
exiftool、strings、およびfileと組み合わせて、メタデータと隠されたコンテンツを取得します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Foremost
Overview
Foremost is a file carving tool: it scans raw disk images, memory dumps, or any blob byte-by-byte for magic headers and footers, then writes out the recovered files into neat per-type directories. It doesn't care about filesystem metadata — it looks for the on-disk bytes that identify a JPEG, PNG, PDF, ZIP, Office document, MP3, and so on. That makes it the right tool for recovering files the filesystem has forgotten or for CTF challenges where a blob hides multiple embedded files.
Instructions
Step 1: Create a Disk Image (Never Carve the Live Device)
# Always work from an image, never the source device
sudo dd if=/dev/sdb of=disk.img bs=4M status=progress conv=noerror,sync
# Or use dcfldd (forensic fork of dd with hashing)
sudo dcfldd if=/dev/sdb of=disk.img bs=4M hash=sha256 hashlog=disk.sha256
# Verify integrity before working
sha256sum disk.img
cat disk.sha256
Step 2: Run Foremost
# Default run — uses built-in config, all supported types
foremost -i disk.img -o recovered/
# Specific types only (jpg, png, pdf, zip, doc, mp3, ...)
foremost -t jpg,png,pdf -i disk.img -o recovered/
# Verbose + quick mode (scan only file headers, faster)
foremost -v -q -t all -i disk.img -o recovered/
# Output tree
tree -L 2 recovered/
# recovered/
# ├── audit.txt
# ├── jpg/
# │ ├── 00000001.jpg
# │ └── 00000125.jpg
# ├── pdf/
# │ └── 00000007.pdf
# └── zip/
# └── 00000042.zip
Step 3: Review the Audit File
# Summary of what was carved
cat recovered/audit.txt
# Foremost version 1.5.7 by Jesse Kornblum ...
# Num Name (bs=512) Size File Offset Comment
# 0: 00000001.jpg 185 KB 16384
# 1: 00000007.pdf 1 MB 67108864
# Count files by type
find recovered -type f -not -name audit.txt | awk -F/ '{print $(NF-1)}' | sort | uniq -c
Step 4: Custom File Types with foremost.conf
# Copy the default config
cp /etc/foremost.conf ./foremost.conf
# Add a signature: extension case max-size header footer
# Example: a custom "FLAG" binary starting with 'CTFFLAG' and ending with 'END'
cat >> foremost.conf <<'EOF'
flag y 5000 CTFFLAG END
EOF
# Run with the custom config
foremost -c ./foremost.conf -i challenge.bin -o out/
ls out/flag/
Step 5: Combine with Other Carvers
# scalpel is foremost's faster fork; use it when foremost is too slow
sudo apt install scalpel
scalpel -c /etc/scalpel/scalpel.conf -o scalpel-out disk.img
# binwalk — better for firmware and embedded filesystems
binwalk -e firmware.bin
# photorec — interactive, stronger for photo/video recovery
sudo photorec /dev/sdb
# strings + file — first-pass triage
strings -a disk.img | less
file recovered/jpg/00000001.jpg
Examples
Example 1: Recover Photos from a Formatted SD Card
# Plug in the SD card — DO NOT mount and DO NOT write anything to it
lsblk
# sdb 1 29.8G 0 disk
# └─sdb1 1 29.8G 0 part
# Image the card
sudo dd if=/dev/sdb of=sdcard.img bs=4M status=progress
sudo sha256sum sdcard.img > sdcard.sha256
# Unplug the card and work from the image only
foremost -t jpg,png,raw,mov,mp4 -i sdcard.img -o photos/
ls photos/jpg | wc -l
# 842
# Sort by size to spot real photos vs thumbnails
find photos/jpg -type f -printf '%s %p\n' | sort -nr | head
Example 2: CTF — Files Hidden Inside a PNG
# The challenge: "Something is hidden inside this harmless image."
file challenge.png
# challenge.png: PNG image data, 1920 x 1080, ...
# Foremost scans through the whole blob, not just the top PNG
foremost -t all -i challenge.png -o carved/
cat carved/audit.txt
# 0: 00000000.png 2 MB 0
# 1: 00000001.zip 45 KB 2097664
# 2: 00000002.pdf 1 MB 2143000
# Inspect the carved ZIP
unzip -l carved/zip/00000001.zip
# flag.txt
unzip -p carved/zip/00000001.zip flag.txt
# flag{foremost_carves_everything}
Guidelines
- Never run Foremost against a live mounted device. Always image first, hash the image, then carve.
- Write-block the source media (physical write blocker, or at minimum mount read-only) to preserve chain of custody.
- Carving is signature-based — it cannot recover file names or directory structure. Metadata is lost.
- Overlapping or fragmented files are reconstructed poorly. For heavily fragmented disks, try
photorecor a filesystem-aware tool likeextundelete/testdiskfirst. - The output directory must NOT exist beforehand — Foremost refuses to overwrite it.
- Foremost is single-threaded and slow on big images.
scalpelis a faster fork for the same job. - For CTFs, always try
foremost -t all -i challenge.blobas a reflex — it finds embedded ZIPs, PDFs, and images thatbinwalksometimes misses. - Pair with
exiftool,strings, andfileon the recovered artifacts to pull metadata and hidden content.