本文へスキップ
Skillpedia
セキュリティ6.5k · #14094

binwalk-extract

できること

このガイドは、ファームウェアイメージをファイルシステムに展開し、確認できるようにする方法を扱います。確認を許可されたファームウェアを扱うセキュリティアナリスト向けです。

使う場面

  • ✓生のファームウェアイメージがあり、確認のためにファイルシステムを抽出する必要があるとき。
  • ✓ファームウェアイメージに圧縮または暗号化された領域があるようで、それらを区別する必要があるとき。
  • ✓標準的でないファイルシステム形式のため、特別なツールが必要なファームウェアイメージがあるとき。

スキルのリンク

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/iot/binwalk-extract/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/iot/binwalk-extract/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私たちの機器の1つから、ファームウェアイメージを取得しました。展開して、ファイルシステムに何が入っているかを教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、既知のファイルシグネチャをイメージから探し、エントロピーを測定して圧縮や暗号化の領域を見分けます。そして、読み取り可能なファイルシステムを抽出します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Firmware Extraction with binwalk

Turn a raw binary image into a navigable filesystem tree. binwalk handles most common containers; firmware-mod-kit covers special-case squashfs variants; manual mounting handles the rest.

Prerequisites

  • Raw firmware binary (from firmware-acquisition skill).
  • Tools: binwalk (≥ 2.3), sasquatch (non-standard squashfs decompressor), jefferson (JFFS2 extractor), ubireader (UBI/UBIFS), mtd-utils, firmware-mod-kit (FMK), 7-zip, lzma, xz-utils.
# Kali / Debian install
sudo apt-get install -y binwalk firmware-mod-kit mtd-utils
pip3 install jefferson ubireader

# sasquatch (handles non-standard squashfs compression: LZMA, XZ, ZLIB with vendor patches)
git clone https://github.com/devttys0/sasquatch && cd sasquatch
./build.sh && sudo cp sasquatch /usr/local/bin/

Step 1 — Identify + Entropy Survey

FW=/workspace/evidence/iot/<target>/firmware/flash_full.bin

# Quick filetype + offset scan
binwalk "$FW"

# Entropy analysis: flat line near 1.0 = encrypted/compressed; structured = filesystem
binwalk -E "$FW"
# Output plot to PNG for report
binwalk -E --save "$FW"     # saves <fw>.png beside the binary

# High entropy region with no signature = encrypted blob — note offset + size
# Low-to-medium entropy with known FS signature = squashfs/jffs2/cramfs — extract

Reading the entropy graph

Entropy range Interpretation
0.0–0.3 Mostly zero-fill / padding — skip
0.5–0.8 Structured data (FS headers, ELF) — extract
0.8–0.95 Compressed data (gzip, lzma, zlib) — normal
0.95–1.0 flat AES/RSA encrypted or already-compressed blob — flag for key hunt

Step 2 — Recursive Extraction

OUTDIR=/workspace/evidence/iot/<target>/extracted

# Recursive extraction (-M), follow symlinks (-r), output to dedicated dir (-C)
binwalk -eM -C "$OUTDIR" "$FW"

# Inspect what was carved
find "$OUTDIR" -maxdepth 4 -type f | head -60
ls -lah "$OUTDIR"/_*

Common extraction outputs

_flash_full.bin.extracted/
  squashfs-root/          ← mounted squashfs rootfs
  40          ← raw uImage kernel (strip 64-byte header for vmlinuz)
  40.7z       ← carved archive at offset 0x40
  A00000      ← raw block at offset 0xA00000

Step 3 — Squashfs (standard + vendor variants)

SQFS=$(find "$OUTDIR" -name "*.squashfs" -o -name "squashfs-root.img" 2>/dev/null | head -1)

# Standard unsquashfs
unsquashfs -d /tmp/squashfs_root "$SQFS"

# Non-standard (Broadcom LZMA, TP-Link XZ, vendor-patched):
sasquatch -d /tmp/squashfs_root "$SQFS"

# If both fail, force a specific compression type:
sasquatch -p 1 -le -d /tmp/squashfs_root "$SQFS"   # little-endian
sasquatch -p 1 -be -d /tmp/squashfs_root "$SQFS"   # big-endian

# Verify extraction
ls /tmp/squashfs_root/{bin,etc,lib,usr,var} 2>/dev/null

Step 4 — JFFS2

JFFS2_IMG=$(find "$OUTDIR" -name "*.jffs2" 2>/dev/null | head -1)

# Method A: jefferson (Python, handles most variants)
jefferson "$JFFS2_IMG" -d /tmp/jffs2_root

# Method B: kernel loop mount (requires modprobe jffs2 + mtdram)
sudo modprobe mtdram total_size=65536 erase_size=256
sudo modprobe mtdblock
sudo dd if="$JFFS2_IMG" of=/dev/mtd0
sudo mount -t jffs2 /dev/mtdblock0 /mnt/jffs2

Step 5 — UBIFS (NAND-based devices)

UBI_IMG=$(find "$OUTDIR" -name "*.ubi" -o -name "*.ubifs" 2>/dev/null | head -1)

# ubireader_extract_files: most direct path
ubireader_extract_files -o /tmp/ubifs_root "$UBI_IMG"

# For raw UBI volume images, ubiextract:
sudo modprobe ubi
sudo ubiattach -m 0 -d 0 /dev/ubi_ctrl
sudo mount -t ubifs /dev/ubi0_0 /mnt/ubifs

Step 6 — Manual Carving (when binwalk misses)

# Find filesystem magic bytes manually
python3 -c "
import sys
data = open('$FW','rb').read()
sigs = {b'hsqs': 'SquashFS LE', b'sqsh': 'SquashFS BE',
        b'\\x19\\x85': 'JFFS2', b'UBI#': 'UBI', b'\\x27\\x05\\x19\\x56': 'uImage'}
for sig, name in sigs.items():
    off = 0
    while True:
        idx = data.find(sig, off)
        if idx == -1: break
        print(f'  {name} @ 0x{idx:08x}')
        off = idx + 1"

# Carve a specific region for separate analysis
dd if="$FW" bs=1 skip=$((0xA00000)) count=$((0x600000)) of=/tmp/carved_rootfs.bin

# Run binwalk on the carved piece
binwalk -eM -C /tmp/carved_extract /tmp/carved_rootfs.bin

Step 7 — Nested Archive Handling

# Device firmware often wraps: .zip/.tar → signed header → lz
よくある質問

エントロピー分析とは何ですか?

データのランダム性を測定する方法です。構造化されたファイルシステムと、暗号化されたかたまりを見分けるのに役立ちます。

抽出には何のツールを使いますか?

このガイドはbinwalkを使い、特別なファイルシステム形式には別のツールも使います。

抽出の後は何をしますか?

ガイドは、抽出したファイルの静的な確認を次の手順として挙げています。たとえば、埋め込まれた認証情報の有無を確認します。

詳細

作者による元の説明

Firmware image extraction with binwalk and firmware-mod-kit — recursive archive carving, squashfs/jffs2/ubifs mounting, entropy analysis to detect packed/encrypted regions, and nested container handling. Entry point for all static filesystem analysis after a raw binary image is acquired.

repo: BitterSecurity/Decepticon

人気

GitHubのスター
6.5k
ランキング
#14094
ライセンス
Apache-2.0
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル