
DDisasm は、高速で逆アセンブル結果のアセンブリコードを再アセンブル可能なほど正確な逆アセンブラです。DDisasm は、datalog (souffle) 宣言型論理プログラミング言語を用いて実装されており、逆アセンブルのルールとヒューリスティックをコンパイルします。この逆アセンブラはまずELF/PEファイル情報を解析し、可能な命令のスーパーセットをデコードして、初期のdatalog ファクトセットを作成します。これらのファクトを解析して、コード位置、シンボル化、関数境界を特定します。この分析結果である洗練されたdatalog ファクトセットは、バイナリ分析とリバースエンジニアリングのための GTIRB 中間表現に変換されます。GTIRB pretty printer を使用して、GTIRBを再アセンブル可能なアセンブリコードに整形出力することができます。
バイナリフォーマット:
命令セットアーキテクチャ (ISAs):
Dockerを使用してDdisasmのプリビルド版を実行できます:
docker pull grammatech/ddisasm:latest
Ddisasmはバイナリを GTIRB 表現に逆アセンブルするために使用できます。 リポジトリに含まれているサンプルの一つで試してみましょう。
まず、Ddisasm Dockerコンテナを起動します:
docker run -v $PWD/examples:/examples -it grammatech/ddisasm:latest
Dockerコンテナ内で、サンプルの一つをビルドしましょう:
apt update && apt install gcc -y
cd /examples/ex1
gcc ex.c -o ex
それでは、バイナリを逆アセンブルします:
ddisasm ex --ir ex.gtirb
GTIRB表現を取得したら、GTIRB や gtirb-rewriting を使用してバイナリにプログラム的な変更を加えることができます。
次に、gtirb-pprinter(Dockerイメージに含まれています)を使用してバイナリの新しいバージョンを生成できます:
gtirb-pprinter ex.gtirb -b ex_rewritten
内部的には、gtirb-pprinter はアセンブリファイルを生成し、コンパイラ/アセンブラ(例:gcc)を呼び出して新しいバイナリを生成します。gtirb-pprinter は、コンパイルオプション、ライブラリ依存関係、バージョンリンカスクリプトなど、新しいバイナリを生成するために必要なすべてのコマンドラインオプションの生成を処理します。
また、gtirb-pprinter を使用して手動変更用のアセンブリリストを生成することもできます:
gtirb-pprinter ex.gtirb --asm ex.s
このアセンブリリストは手動で再コンパイルできます:
gcc -nostartfiles ex.s -o ex_rewritten
詳細については、ドキュメント をご覧ください。
CONTRIBUTING.md を参照してください。
@inproceedings {flores-montoya2020,
author = {Antonio Flores-Montoya and Eric Schulte},
title = {Datalog Disassembly},
booktitle = {29th USENIX Security Symposium (USENIX Security 20)},
year = {2020},
isbn = {978-1-939133-17-5},
pages = {1075--1092},
url = {https://www.usenix.org/conference/usenixsecurity20/presentation/flores-montoya},
publisher = {USENIX Association},
month = aug,
}
@misc{schulte2020gtirb,
title={GTIRB: Intermediate Representation for Binaries},
author={Eric Schulte and Jonathan Dorn and Antonio Flores-Montoya and Aaron Ballman and Tom Johnson},
year={2020},
eprint={1907.02859},
archivePrefix={arXiv},
primaryClass={cs.PL}
}
@INPROCEEDINGS{11023516,
author={Flores-Montoya, Antonio and Lim, Junghee and Seitz, Adam and Sood, Akshay and Raff, Edward and Holt, James},
booktitle={2025 IEEE Symposium on Security and Privacy (SP)},
title={Disassembly as Weighted Interval Scheduling with Learned Weights},
year={2025},
volume={},
number={},
pages={3033-3050},
keywords={Measurement;Privacy;Accuracy;Heuristic algorithms;Reverse engineering;Binary codes;Benchmark testing;Scheduling;Inference algorithms;Security;disassembly;reverse engineering;learning;binary analysis},
doi={10.1109/SP61157.2025.00192}}