[cb16] バイナリロックスターになる:binary ninjaによるプログラム解析入門 by...
TRANSCRIPT
![Page 1: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/1.jpg)
バイナリロック になるBinary Ninjaによるプログラム解析入門
![Page 2: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/2.jpg)
この講演で話さないこと
![Page 3: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/3.jpg)
この講演で話すこと
![Page 4: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/4.jpg)
ファジング….
現在の最新技法
バイナ
リ
ソース
コード
問題
読解とスクリプティングによる逆アセン
ブル
コードの読解
ビットコードの解析
Bindead, REIL,
BAPによる静的解析
動的計測
静的および動的解析
コンパイラ
ソースコードアナライザ
McSem
a
![Page 5: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/5.jpg)
IDAは完璧ではない
![Page 6: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/6.jpg)
問題
バイナ
リ
ソース
コード
問題
● 確固たるツールの選択肢の不足
● コード読解は役に立ち続ける
● コンパイラとLLVMのツールの性能は向上している (
この分野はたくさんのイカしたプロジェクトがある!)
● ほとんどのツールは意味的推論が欠如している
● 逆コンパイラは広く利用されているが、自動的に推論することが困難である
● 多くのプログラム解析フレームワークは使いづらい –自分の分析との対話に使用可能なフレームワークが欠如している
● バイナリを取り扱うためのインタラクティブかつ使用可能な中間言語(IL)フレームワークの本当に良い選択肢はない
![Page 7: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/7.jpg)
Binary,
interactive IL
frameworks.
![Page 8: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/8.jpg)
Binary Ninja & Binja IL
![Page 9: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/9.jpg)
Binja: 木に基づく構造● Binary Ninja ILは
LowLevelILInstructionの表現にまとめた
● LLILIは無限長の木構造による命令(配置)
● 中間記法。作用先のオペランドは左辺に置かれる。(e.g. x86 ``mov eax, 0`` vs. LLIL ``eax = 0``)
● 副作用がない
● 再帰的下向き解析
![Page 10: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/10.jpg)
Binja: 木に基づく構造
● ジャンプテーブルの境界を見つけるためのシンボリック解析(抽象解釈)
● 逆アセンブルとそれら自身の中間言語を用いて関数の終了、中断などを決定する。
![Page 11: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/11.jpg)
binja_memcpy.py: IL
/bin/bash
![Page 12: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/12.jpg)
binja_memcpy.py: IL
/bin/bash
![Page 13: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/13.jpg)
binja_memcpy.py: IL
/bin/bash
レジスタの状態!
![Page 14: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/14.jpg)
binja_memcpy.py: API
![Page 15: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/15.jpg)
binja_memcpy.py: API
![Page 16: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/16.jpg)
binja_memcpy.py: API
![Page 17: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/17.jpg)
binja_memcpy.py: API
![Page 18: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/18.jpg)
binja_memcpy.py: Output
![Page 19: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/19.jpg)
Binja API● Python, C and C++ API (いかにもありそうな!)
● LLVMに組み込まれたいくつかの解析機能がなくなっている(たとえば、統合されたCFG走査、Uses、SSA、変数の特徴を伴
う記録)
● 分岐:関数の終端(出口)を伴う基本ブロック
● 記録状態を得る、ある簡単な範囲の解析
● api.binary.ninja/search.html
![Page 20: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/20.jpg)
シンボリック実行● とても正確
● 時間、データ、メモリを使い、時には実行不能
● アイディア!私たちが何について出来るかについてのみ推測する
● 複雑なデータを抽象的なドメインに適用する!
● ドメイン:型、符号、範囲、色、など
![Page 21: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/21.jpg)
実践的 (学術的) & プログラム解析
● 具体的な値の集合が不正確に抽象化される
● ガロア接続の定式化具体的 <-> 抽象的
具体なデータ
関心のある抽象的な特徴
![Page 22: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/22.jpg)
抽象化!int x = 5
int y = argc + x
int z
a
![Page 23: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/23.jpg)
抽象解釈int x = 5
int y = argc + x
int z
aint
抽象領域:型
![Page 24: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/24.jpg)
抽象解釈int x = 5
int y = argc + x
a
int z
int
= +
= +
符号解析
![Page 25: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/25.jpg)
実践的 (学術的) & プログラム解析
● xの値は不正確である
● コンパイラは不正確に抽象化する。
int x;
int[] a = new int[10];
a[2 * x] = 3; 1. 精密さを付与する –つまり、抽象値の範囲は [0, 9]
1. 抽象化ドメインと値によるシンボリック実行
● 制御フロー解析の要求
![Page 26: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/26.jpg)
抽象化ドメイン & 符号解析
int a,b,c;
a = 42;
b = 87;
if (input) {
c = a
+ b;
} else {
c = a
- b;
}
● 抽象値への変数マップ
![Page 27: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/27.jpg)
抽象化ドメイン & 符号解析
● Binary Ninja plugin
● 経路依存 –抽象値の格子の構築
● 近似値を下回る
● CFG節毎に1つの抽象状態
● 分数による正確性の喪失を避ける
![Page 28: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/28.jpg)
デモ!
● 例題プログラムの解析
● PHP CVE-2016-6289
![Page 29: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/29.jpg)
スクリプト!
● memcpy, headless
python API スクリプト
● 深さ優先探索、経路依存CFGテンプレート
● 符号解析、抽象ドメインプラグイン
https://github.com/q
uend/
abstractanalysis
![Page 31: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/31.jpg)
結論
● 感謝!○ Vector35
○ Trail of Bits
○ Ryan Stortz (@withzombies)
● 参考資料○ binary.ninja/
○ github.com/quend/abstractanalysis
○ santos.cs.ksu.edu/schmidt/Escuela03/WSSA/talk1p.pdf
○ 静的プログラム解析の書籍!cs.au.dk/~amoeller/spa/spa.pdf
忘れないで:分析する前にこれを刈り込んで下さい。
![Page 32: [CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine](https://reader033.vdocuments.pub/reader033/viewer/2022052406/587756c61a28ab84388b7775/html5/thumbnails/32.jpg)
アジェンダ
1) IDA は完璧ではない2) Binary Ninja IL
3) 実践的(学術的)&プログラム解析a) 抽象解釈
4) Binary Ninjaプラグインのデモ5) 結論