2011 CodeEngn Conference 05
DBI 란 Dynamic Binary Instrumentation 의 약자이다. 이는 실행 중인 어떤 Process 또는 Program 에 특수한 목적으로 사용될 임의의 코드를 삽입하는 방법이다. 이를 이용하여 동적으로 생성된 Code 처리, 특정 코드의 발견, 실행중인 Process 분석 등을 할 수 있다. 주로 컴퓨터 구조 연구, 프로그램, 스레드 분 석에 이용되며, Taint Analysis 에 대한 개념, 각종 Tool 과 사용 방법, 간단한 예제, 최신 취약점 분석 등 을 통하여 DBI 를 알아보도록 한다.
http://codeengn.com/conference/05
7. Winner
• Dynamic Analysis
More precise
Because > works with real values in the run-time
• if ( you think Ollydbg & IDA Disassembler )
Easy to understand
7
8. Source Analysis
• Source Analysis
- Language dependency
- Access high-level information
- Tools : Source insight
8
11. SBI
• Static Binary Instrumentation
- Before the program is run
- Rewrites object code or executable code
- Disassemble -> instrumentation
11
12. DBI
• Dynamic Binary Instrumentation
- Run-time
- By external process, grafted onto the client process
12
13. Winner
• DBI
1. Client program doesn’t require to be prepared
2. Naturally covers all client code
13
14. Usefulness of DBI
• Do not need Recompiling and Relinking
• Find the specific code during execution
• Handle dynamically generated code
• Analyzing running process
14
15. Use
• Trace procedure generating
• Fault tolerance studies
• Emulating new instructions
• Code coverage -> t / all * 100
• Memory-leak detection
• Thread profiling
• And so on . . .
15
16. Before that
• Taint Analysis
Kind of information flow
To see the flow from the external input effect
16
19. Use
• Detecting flaws
if ( tracking user data == available )
I see where untrusted code swimming
• Data Lifetime Analysis
19
20. How ?
• Dynamic Binary Instrumentation Tools
Pin :Win & Linux & MAC, Intermediate Language
DynamoRIO :Win & Linux & MAC
TEMU :Win & Linux, QEMU based
Valgrind : Linux
20
21. How ?
• Use PIN Tool
Windows, Linux, MAC OSX
Custom Code ( C or C++ )
Attach the running file
Extensive API
Pinheads
21
22. Pin ?
• http://pintool.org
One of JIT ( Just In Time ) compiler
Not input bytecode, but a regular executable
Intercept instruction and generates more code and execute
22
23. Pin : Instrumentation Engine
Pintool : Instrumentation Tool
Application :Target Program or Process
23
Pin ?
29. Install
• if ( Install window )
you need to visual c++
• else if ( install linux )
you need to gcc-c++
• else if ( install mac 64bit )
not available
29
30. A Simple Example
30
• Inscount & Itrace & Pinatrace
• Step by modify code
Inscount
M
Itrace
M
Pinatrace
36. insertPredicatedCall ?
36
To avoid generating references to instructions that are predicated when
the predicate is false
Predication is a general architectural feature of the IA-64
39. Vera
• Use vera !
Shmoocon 2011 Danny Quist
Visualizing Executables for Reversing & Analysis
Better OEP detection & IDA Pro Plugin
39
40. Demo !
• if ( Use DBI withVera )
you will see the memory flow ( easily )
• And
you will see the pattern of vulnerable program and patched program
40
42. Zero-day !
1. HookVulnerability Function
strcpy, strcat, sprintf, scanf, fscanf, strstr, strchr
2. And
monitoring ESI
3. Olleh!
It’s possible to modify the parameters
42