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

More Related Content

PDF
エンジニアから飛んでくるマサカリを受け止める心得
PDF
リクルートのWebサービスを支える「RAFTEL」
PDF
【15-B-7】無意味なアラートからの脱却 ~ Datadogを使ってモダンなモニタリングを始めよう ~
PDF
Linux KVM環境におけるGPGPU活用最新動向
PPT
次世代DaoフレームワークDoma
PDF
モジュールの凝集度・結合度・インタフェース
PDF
Datadog Agent on CloudRunによるGCPトレービリティ向上
ODP
Unity ネイティブプラグインの作成について
エンジニアから飛んでくるマサカリを受け止める心得
リクルートのWebサービスを支える「RAFTEL」
【15-B-7】無意味なアラートからの脱却 ~ Datadogを使ってモダンなモニタリングを始めよう ~
Linux KVM環境におけるGPGPU活用最新動向
次世代DaoフレームワークDoma
モジュールの凝集度・結合度・インタフェース
Datadog Agent on CloudRunによるGCPトレービリティ向上
Unity ネイティブプラグインの作成について

What's hot (20)

PDF
【Unity】Scriptable object 入門と活用例
PDF
ツール比較しながら語る O/RマッパーとDBマイグレーションの実際のところ
PPT
ドメインロジックの実装方法とドメイン駆動設計
PDF
正しいものを正しく作る塾-設計コース
PDF
Androidの表示レイヤーと画面常駐型アプリの話
PPTX
CyberChefの使い方(HamaCTF2019 WriteUp編)
PPTX
SPAセキュリティ入門~PHP Conference Japan 2021
PPTX
Dependency injection presentation
PDF
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
PPTX
FIWARE Orion Context Broker コンテキスト情報管理 (Orion 3.4.0対応)
PDF
正規表現リテラルは本当に必要なのか?
PDF
ピクサー USD 入門 新たなコンテンツパイプラインを構築する
PDF
Dependency injection in CakePHP
PDF
golang.tokyo #6 (in Japanese)
PDF
WebIDLを見てみる
PDF
例外設計における大罪
PDF
セキュリティを楽しむ(CTFとbugbountyの始め方)
PDF
ReDosトラック内発表資料
PPTX
さくっと理解するSpring bootの仕組み
PDF
Responsableを使ったadr実装
【Unity】Scriptable object 入門と活用例
ツール比較しながら語る O/RマッパーとDBマイグレーションの実際のところ
ドメインロジックの実装方法とドメイン駆動設計
正しいものを正しく作る塾-設計コース
Androidの表示レイヤーと画面常駐型アプリの話
CyberChefの使い方(HamaCTF2019 WriteUp編)
SPAセキュリティ入門~PHP Conference Japan 2021
Dependency injection presentation
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
FIWARE Orion Context Broker コンテキスト情報管理 (Orion 3.4.0対応)
正規表現リテラルは本当に必要なのか?
ピクサー USD 入門 新たなコンテンツパイプラインを構築する
Dependency injection in CakePHP
golang.tokyo #6 (in Japanese)
WebIDLを見てみる
例外設計における大罪
セキュリティを楽しむ(CTFとbugbountyの始め方)
ReDosトラック内発表資料
さくっと理解するSpring bootの仕組み
Responsableを使ったadr実装
Ad

More from CODE BLUE (20)

PDF
[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
PDF
[cb22] Tales of 5G hacking by Karsten Nohl
PDF
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
PDF
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
PDF
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
PDF
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
PDF
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
PDF
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
PPTX
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
PPTX
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
PDF
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
PDF
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
PDF
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
PDF
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
PDF
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
PDF
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
[cb22] Tales of 5G hacking by Karsten Nohl
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
Ad

[CB16] バイナリロックスターになる:Binary Ninjaによるプログラム解析入門 by Sophia D’Antoine

Editor's Notes

  • #3: This talk isn’t about a new fantastical analysis platform. This talk isn’t about how one tool is better than another. This talk isn’t about a new silver bullet.
  • #4: This talk is about making simple and advanced static analysis techniques easy and available to everyone...
  • #5: Joern - source code analyzer There’s a lot available, but we all know we’re going to ignore all of them and go straight for IDA. Why? Because IDA is interactive and tweakable and customizable.
  • #6: Let’s face it...IDA isn’t perfect. I’m sure most of you have taken a shot at doing some automated analysis in IDA. Maybe you wanted to identify all the dynamically bounded memcpys. IDA has a python API, how hard could it be? Okay, let’s start by getting all the cross references to memcpy. Easy enough in the IDA API, we just iterate over the xrefs. Now, we need to see if the size parameter of memcpy is constant. So we look up the calling convention of our architecture and look up the 3rd parameter. Our architecture is x86-32, so that means we need model the stack. So now we jump back to the top of the basic block and start implementing instructions. Let’s start by implementing the pushes...oh wait, then we need to do the moves...but now we need to remember that ESP *and* EBP are stack pointers...etc etc. That’s a lot of work for such a simple analysis. There has to be a better way.
  • #7: Cannot reason. Mcsema is not really that great
  • #10: ``class LowLevelILInstruction`` Low Level Intermediate Language Instructions are infinite length tree-based instructions. Tree-based instructions use infix notation with the left hand operand being the destination operand. Infix notation is thus more natural to read than other notations (e.g. x86 ``mov eax, 0`` vs. LLIL ``eax = 0``).
  • #11: ``class LowLevelILInstruction`` Low Level Intermediate Language Instructions are infinite length tree-based instructions. Tree-based instructions use infix notation with the left hand operand being the destination operand. Infix notation is thus more natural to read than other notations (e.g. x86 ``mov eax, 0`` vs. LLIL ``eax = 0``).
  • #12: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #13: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #14: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #15: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #16: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #17: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #18: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #19: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #20: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #21: Memcpy example with binary ninja here https://gist.github.com/withzombies/75d12d8fa1237213beb7e82acbfc3b40
  • #22: http://santos.cs.ksu.edu/schmidt/Escuela03/WSSA/talk1p.pdf In one sense, every analysis based on abstract interpretation is a “predicate abstraction.” But the “logic” is weak — it supports conjunction (u) but not necessarily disjunction (t).
  • #26: http://santos.cs.ksu.edu/schmidt/Escuela03/WSSA/talk1p.pdf
  • #27: https://cs.au.dk/~amoeller/spa/spa.pdf Here, the analysis could conclude that a and b are positive numbers in all possible executions at the end of the program. The sign of c is either positive or negative depending on the concrete execution, so the analysis must report ? for that variable. Altogether we have an abstract domain consisting of the five abstract values {+, -, 0, ?, ⊥}, which we can organize as follows with the least precise information at the top and the most precise information at the bottom: ? + 0 − The ordering reflects the fact that ⊥ represents the empty set of integer values and ? represents the set of all integer values. This abstract domain is an example of a lattice. We continue the development of the sign analysis in Section 5.2, but we first need the mathematical foundation in place.
  • #28: https://cs.au.dk/~amoeller/spa/spa.pdf Here, the analysis could conclude that a and b are positive numbers in all possible executions at the end of the program. The sign of c is either positive or negative depending on the concrete execution, so the analysis must report ? for that variable. Altogether we have an abstract domain consisting of the five abstract values {+, -, 0, ?, ⊥}, which we can organize as follows with the least precise information at the top and the most precise information at the bottom: ? + 0 − The ordering reflects the fact that ⊥ represents the empty set of integer values and ? represents the set of all integer values. This abstract domain is an example of a lattice. We continue the development of the sign analysis in Section 5.2, but we first need the mathematical foundation in place.