The English version is written after Japanese version.
- dockerをインストールし、
docker
とdocker-compose
コマンドが使えることを確認してください。
- eclipseを以下のURLからダウンロードしてください。
- 以下のURLからこのgitリポジトリをダウンロードしてください。
- https://github.com/usaribbon/firmddle_docker/archive/refs/heads/main.zip
- もしくは
git clone https://github.com/usaribbon/firmddle_docker.git
- 先程ダウンロードしたeclipseのtar.gzファイルを、firmddle_docker/raw_firmwares/eclipse/のディレクトリにコピーしてください。
- ダウンロードしたgitリポジトリに移動し、以下のようなディレクトリ構造になっていることを確認してください。
.
├── docker-compose.yml
├── gui
│ └── Dockerfile
└── raw_firmwares ←docker上では/mnt/raw_firmwares/としてマウントされます
├── eclipse
│ └── eclipse-committers-2022-06-R-linux-gtk-x86_64.tar.gz
├── elf
├── extracted
├── ghidraprj
├── raw
- gitリポジトリ内で以下のコマンドを実行し、dockerをビルド&起動させてください。
docker-compose build
docker-compose up -d
- (Windows)iptablesの関係でStep7,9で初回ビルドは失敗してしまいます。その際はdockerを再起動して、もう一度ビルドコマンドを実行してみてください。
- ホストPCのWEBブラウザから
http://127.0.0.1:8080/
にアクセスしてdockerコンテナに入ってください。(環境によって接続までに数分〜数十分かかる場合があります) - ファイルマネージャーから
/root/firmusa/ghidra_10.1.5_PUBLIC_20220726/ghidraRun
にアクセスし、Ghidraを起動してください。
- 分割したいファームウェアを、gitリポジトリのraw_firmwares/raw/に置いてください。dockerには/mnt/raw_firmwares/としてマウントされています。
- docker上で
/root/firmware-mod-kit/extract_elf.sh
を実行してください。/mnt/raw_firmwares/に置かれているファームウェアの分割が始まります。 - 分割されたファームウェアは、/mnt/raw_firmwares/extracted/に置かれます。
- 「ファームウェアを分割する」の手順を実行した後、
/root/firmware-mod-kit/import_elf_ghidra.sh
を実行してください。 - 分割したファームウェアがGhidraにインポートされていきます。ファームウェアのサイズが大きい場合、インポートに時間がかかる場合があります。
- ファームウェアごとにGhidraプロジェクトが作成され、/mnt/raw_firmwares/ghidraprj/に保存されます。
- ファイルマネージャーから
/root/firmusa/ghidra_10.1.5_PUBLIC_20220726/ghidraRun
にアクセスし、Ghidraを起動してください。 - Ghidraから、File -> Open Projectを選択して
/mnt/raw_firmwares/ghidraprj/好きなファームウェア名.gpr
を開きます。
- /root/firmusa/ghidra_10.1.5_PUBLIC_20220726/ghidraRun を実行してGhidraを起動してください。
- NewProjectを選択します。
- プロジェクト内の全ファイルに対してスクリプトを適用したいときは、下記のコマンドを実行してください
/root/firmusa/ghidra_10.1.5_PUBLIC/support/analyzeHeadless /mnt/raw_firmwares/ghidraprj binary2 -scriptPath /root/ghidra_scripts -postScript Yoda_API_Headless.java -process -recursive
- スクリプトを適用した結果は、dockerの
/mnt/raw_firmwares/logs/
、またはホストPCのこのgitリポジトリ/raw_firmwares/logs/
に保存されています。
- Install docker and make sure
docker
anddocker-compose
commands are available.
- Download eclipse from the following URL
- Download this git repository from the following URL
- https://github.com/usaribbon/firmddle_docker/archive/refs/heads/main.zip
- Or
git clone https://github.com/usaribbon/firmddle_docker.git
- Copy the eclipse tar.gz file you just downloaded to the directory firmddle_docker/raw_firmwares/eclipse/
- Go to the git repository you downloaded and make sure the directory structure looks like this
.
├── docker-compose.yml
├── gui
│ └── Dockerfile
└── raw_firmwares ←mounted as /mnt/raw_firmwares/ on docker
├── eclipse
│ └── eclipse-committers-2022-06-R-linux-gtk-x86_64.tar.gz
├── elf
├── extracted
├── ghidraprj
├── raw
- Execute the following command in the git repository to build and start docker.
docker-compose build
docker-compose up -d
- (Windows) Due to iptables, the first build will fail in Step 7 and 9. In that case, restart docker and run the build command again.
- Please access
http://127.0.0.1:8080/
from a web browser on the host PC to enter the docker container. (It may take several minutes to several tens of minutes to connect depending on the environment.) - Access
/root/firmusa/ghidra_10.1.5_PUBLIC_20220726/ghidraRun
from the file manager and start Ghidra.
- Place the firmware you want to split in the git repository raw_firmwares/raw/. docker has it mounted as /mnt/raw_firmwares/
- Run
/root/firmware-mod-kit/extract_elf.sh
on docker. The firmware placed in /mnt/raw_firmwares/ will start to be split. - The split firmware will be placed in /mnt/raw_firmwares/extracted/
- After performing the steps in "Splitting Firmware," run
/root/firmware-mod-kit/import_elf_ghidra.sh
. - The split firmware will be imported into Ghidra. If the firmware is large, the import may take some time.
- A Ghidra project will be created for each firmware and saved in /mnt/raw_firmwares/ghidraprj/.
- Access
/root/firmusa/ghidra_10.1.5_PUBLIC_20220726/ghidraRun
from the file manager and start Ghidra. - From Ghidra, select File -> Open Project and open
/mnt/raw_firmwares/ghidraprj/firmware_name.gpr
of your choice.
- Run Ghidra by executing
/root/firmusa/ghidra_10.1.5_PUBLIC_20220726/ghidraRun
- Select NewProject.
- If you want to apply the script to all files in the project, run the following command
/root/firmusa/ghidra_10.1.5_PUBLIC/support/analyzeHeadless /mnt/raw_firmwares/ghidraprj binary2 -scriptPath /root/ghidra_scripts - postScript Yoda_API_Headless.java -process -recursive
. - The results of applying the scripts are stored in
/mnt/raw_firmwares/logs/
on docker or inthis git repository/raw_firmwares/logs/
on the host PC. The results are stored in the host PC.