SlideShare a Scribd company logo
1 of 64
Download to read offline
Dynamic Behavior Analysis Using
Binary Instrumentation
Jonathan Salwan
jsalwan@quarkslab.com
St'Hack
Bordeaux – France
March 27 2015
Keywords: program analysis, DBI, DBA, Pin, concrete execution,
symbolic execution, DSE, taint analysis, context snapshot,
Z3 theorem prover and behavior analysis.
2
● I am a junior security researcher at Quarkslab
working on tools development for programs analysis
● I have a strong interest in all low level computing
● I like to play with weird things even though it
sometimes seems useless
Who Am I?
3
● Few words about the goal of this stuff
● Short review of the Security Day Lille's talk
– Really short introduction
– Covering a function using DSE approach
– Some words about vulnerabilities hunting
● Objectives of this talk
– Build specific analysis to find specific bugs
● Analysis for use-after-free detection
● Analysis for heap overflow detection
● Analysis for stack overflow detection
●
Analysis for format string detection
● Analysis for {wrtite, read}-what-where detection
– Few words about generic analysis
– Few words about the Triton project !!
● Conclusion
● Q&A
Roadmap Of This Talk
4
● First Of All – The Goal Of This Stuff
5
● Main goal:
– I want to analyze a binary dynamically
– I want to find unexpected behaviors in its execution to find potential
vulnerabilities
● Even if these bugs do not crash the program
● First Of All – The Goal Of This Stuff
ba 05 00 00 00 be
00 58 40 00 31 ff
89 4c 24 10 e8 1c
fb ff ff 31 f6 48
89 c2 bf 01 00 00
00 31 c0 e8 3b fd
ff ff 8b 05 35 67
20 00 8b 4c 24 10
Be 30 58 40 00 31
ba 05 00 00 00 be
00 58 40 00 31 ff
89 4c 24 10 e8 1c
fb ff ff 31 f6 48
89 c2 bf 01 00 00
00 31 c0 e8 3b fd
ff ff 8b 05 35 67
20 00 8b 4c 24 10
Be 30 58 40 00 31
Execution
Behavior
Analysis
binary
Analysis 1 Analysis 2
6
● Short Review Of The
Security Day Lille's Talk
7
● In the last talk [0], we saw how it was possible to
cover a function in memory using a dynamic
symbolic execution approach
– We generate and inject concrete values in
memory in order to go through all paths
● Short Review Of The
Security Day Lille's Talk
[0] http://shell-storm.org/talks/SecurityDay2015_dynamic_symbolic_execution_Jonathan_Salwan.pdf
8
● Basically, we:
– Target a function
– Take a context snapshot at the first instruction
– Switch to a dynamic symbolic execution in order to build
the path constraint (PC)
– Restore the snapshot and generate another concrete
value to go through another path
– Repeat this operation until all paths are taken
● Short Review Of The
Security Day Lille's Talk
9
● In a nutshell, we got something like this:
● Short Review Of The
Security Day Lille's Talk
Restore context
Snapshot
Restore
SnapshotTarget
function / basic block
Dynamic Symbolic Execution Possible paths in the target
10
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
Control flow graph
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
11
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
1st
iterationTake a snapshot
12
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
1st
iteration
PC = T : {ρin}Add to scope
13
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin}
¬π1
14
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1}
Add to scope
15
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
Add to scope
16
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
1st
iteration
Restore the snapshot
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
17
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
Add to scope
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
18
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 : {ρin}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
π1
19
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 : {ρin, ρ2}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
Add to scope
20
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
¬π2
21
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
Add to scope
22
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
Restore the snapshot
23
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
Add to scope
3th
iteration
PC = T : {ρin}
24
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
3th
iteration
PC = T : {ρin}
PC = π1 : {ρin}
π1
25
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
3th
iteration
PC = T : {ρin}
PC = π1 : {ρin, ρ2}
Add to scope
26
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
3th
iteration
PC = T : {ρin}
PC = π1 π∧ 2 : {ρin, ρ2}
π2
27
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
3th
iteration
PC = T : {ρin}
PC = π1 π∧ 2 : {ρin, ρ2, ρ3}
Add to scope
28
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
3th
iteration
PC = T : {ρin}
PC = π1 π∧ 2 : {ρin, ρ2, ρ3, ρout}
Add to scope
29
● Dynamic Symbolic Execution
● The Dynamic Symbolic Execution process looks like this:
ρin
ρ1 ρ2
ρout
ρ3
π1
π2
2nd
iteration
PC = T : {ρin}
PC = π1 ¬π∧ 2: {ρin, ρ2, ρout}
1st
iteration
PC = T : {ρin}
PC = ¬π1 : {ρin, ρ1, ρout}
3th
iteration
PC = T : {ρin}
PC = π1 π∧ 2 : {ρin, ρ2, ρ3, ρout}
There is no more branches,
so the restore process is over
PC1 = T : {ρin}
PC2 = ¬π1 : {ρin, ρ1, ρout}
PC3 = π1 ¬π∧ 2: {ρin, ρ2, ρout}
PC4 = π1 π∧ 2 : {ρin, ρ2, ρ3, ρout}
30
● Symbolic Execution Guided By The
Taint Analysis
31
● Symbolic Execution Guided By The
Taint Analysis
● Taint analysis provides information about which registers and memory
addresses are controllable by the user at each program point:
– Assists the symbolic engine to setup the symbolic variables (a
symbolic variable is a memory area that the user can control)
– May assist the symbolic engine to perform some symbolic
optimizations
– At each branch instruction, we directly know if the user can go through
both branches (this is mainly used for code coverage)
32
● Symbolic Execution Guided By The
Taint Analysis
What user can control ?
Can I take both branches ?
33
● Symbolic Execution Guided By The
Taint Analysis
ZF is controllable, so I can choose the branch
Tainted memory area
Spread the taint
34
● Few Words About Fuzzing
35
● Few Words About Fuzzing
● Generally, the main objective is to cover a maximum of code by injecting
different input samples and wait for a side effect like a segmentation fault
– When a segmentation fault occurs, it means that we probably found a
bug
– The main issue is that some bugs do not make the program crash
Never triggered
Never triggered
Side effect → Segfault
Side effect → SegfaultNo side effect, no crash
How can I find it?
Program
Iteration 2 Iteration 1
bug
Program
Coverage
Entry point
36
● Is Covering All The Paths Enough To
Find Vulnerabilities?
37
Ignored values
Ignored values
● Is Covering All The Paths Enough To
Find Vulnerabilities?
Values set
Execution (time)
Set of values ignored in the path
Set of possible values used in the path
State of variables during the execution
Values that trigger a vulnerability
●
No! Code coverage != State coverage. A variable can hold several values during the execution and some of
these may not trigger any bug.
● We must generate all concrete values that a path can hold to cover all the possible states.
– Imply a lot of overload in the worst case
●
Below, a Cousot style graph which represents some possible states of a variable during the execution in a
path.
38
Ignored values
Ignored values
● A Bug May Not Make The
Program Crash
Values set
Execution (time)
Set of values ignored in the path
Set of possible values used in the path
State of the variable during the execution
Values that trigger a vulnerability
● Another important point is that a bug may not make the program crash
● Lots of fuzzers are based on the fact that a bug may have side effect like a SIGSEGV
– That's why we must implement some behavior analysis to find bugs which does not
make the program crash
May not cause a crash
39
● OK, now that the introduction is over,
let's start the talk!
40
● Covering a function is not enough to find vulnerabilities
– We must apply some “behavior analysis” at runtime using binary
instrumentation
● Really hard to build a generic analysis which find all kind of bugs
● So, we must build specific analysis to find specific bugs
● What kind of bugs we want to find? In this talk we will see how to
find these kind of bugs:
– Use-after-free
– Overflow on heap / stack
– Format string
– {write, read}-what-where
Objective Of This Talk
41
● Use-After-Free Analysis
42
● An use-after-free mainly occurs when there is a LOAD/STORE on an already freed area
●
First, we maintain an allocation map (TA) and a free map (TF) of <Δ,S> items where Δ is the base address
of the allocation and S its size. <Δ,S> represents an area
– Monitor the malloc (*alloc) function(s)
● Δ is provided by the EAX register at the malloc return
● S is provided by the argument of the malloc call
● We add a new <Δ,S> in TA and delete the <Δ,S> in TF if it exist.
– If Δnew TF∈ ∧ Snew ≠ Sold → <Δold,Sold>TF is divided in two items where the first item will be in TA
and the second item will still be in TF
– When a free occurs we move the <Δ,S> from TA to TF
– When a LOAD/STORE occurs, we check if there is a Δ in TA or TF and applies these following rules:
●
If Δ TA∈ → valid memory access
●
If Δ TA Δ TF∉ ∧ ∉ → invalid memory access
●
If Δ TA Δ TF∉ ∧ ∈ → use-after-free
Use-After-Free Analysis
Allocate Used Freed Used
Execution
43
● Heap Overflow Analysis
44
●
Maintain an allocation map (TA) of <Δ,S> where Δ is
the base address of the allocation and S its size
(<Δ,S> represents an area)
●
Monitor all STORE / LOAD and checkup if Δ TA∈
● We denote β ∈ ℕ0 the iteration number and <Δβ,Sβ>
the area description over each loop iteration
● When a loop applies a linear STORE, we apply
these rules:
– If β * Δ∈ ℕ ∧ β = Δβ-1 β < S → OK∧
– If β * Δ∈ ℕ ∧ β ≠ Δβ-1 β >= S → Heap overflow∧
Heap Overflow Analysis
Execution
Nb
Instruction
STORE instruction
1
5
6
Loop
Compare and
Branch instruction
Memory
<Δ, S>
STORE outside an
allocated area
45
● Stack Overflow Analysis
46
● Two possible analysis:
– Overflow outside the stack frame
– Overflow between two variables of a same stack frame
● We will focus on this analysis
Stack Overflow Analysis
int a, b, i;
a = 0x90909090;
b = 0x91919191;
for (i = 0; i <= sizeof(b); i++) /* off-by-one */
*(((unsigned char *)(&b))+i) = 'E';
Same stack frame
One byte wrote outside the b area
How can I detect this off-by-one?
47
● We must:
– Isolate all stack frames
● Routine may be given by Pin or monitor all call/ret
● Then, the area is given by the prologue
– Find how many variables are in the stack frame
● We use the A-Locs (Abstract Locations) methods from the Value-Set-Analysis
paper [0]
– Assign an area <ID,Δ,S> for each variable where ID ∈ is the unique stackℕ
frame id, Δ the base address of the variable and S the size of the variable
● Like heap overflow analysis, check if there is a change of area <ID,Δ,S> during a
linear STORE
Stack Overflow Analysis
[0] Analyzing Memory Accesses in x86 Executables by Gogul Balakrishnan and Thomas Reps
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.129.1920&rep=rep1&type=pdf
Each stack frame must
have a unique ID
48
Stack Overflow Analysis
01. 4006d4: mov qword ptr [rbp-0x10], 0x0 (dest: 7fffdae70d10) (stack frame ID: 3)
02. 4006dc: mov qword ptr [rbp-0x18], 0x0 (dest: 7fffdae70d08) (stack frame ID: 3)
03. 4006e4: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70d1c) (stack frame ID: 3)
04. 40071f: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70d1c) (stack frame ID: 5)
05. 400742: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70d1c) (stack frame ID: 5)
06. 400640: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70cdc) (stack frame ID: 9)
07. 400669: mov dword ptr [rbp-0x8], 0x90909090 (dest: 7fffdae70cd8) (stack frame ID: 10)
08. 400670: mov dword ptr [rbp-0xc], 0x91919191 (dest: 7fffdae70cd4) (stack frame ID: 10)
09. 400677: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70cdc) (stack frame ID: 10)
10.
11. id stack frame: 3 Num var: 3
12. id stack frame: 5 Num var: 1
13. id stack frame: 9 Num var: 1
14. id stack frame: 10 Num var: 3
1 var
● If there is two assignments on a same <ID,Δ> → Interpret this as one variable area
(take a look at line .04 and .05)
● However, if there is two assignments on <ID,Δ> and <ID,Δ+n> → Interpret this as two
variables areas and we must refine the first area
49
Stack Overflow Analysis
● As the heap overflow analysis, we must monitor each
loop which applies a linear STORE and check if there
is a change of area
● We denote β ∈ ℕ0 the iteration number and
<IDβ,Δβ,Sβ> the area description over each loop
iteration
● If β * X∈ ℕ ∧ β = Xβ-1 ∧ Δβ = Δβ-1 → OK
● If β * X∈ ℕ ∧ β ≠ Xβ-1 → Overflow outside the stack
frame
● If β * Δ∈ ℕ ∧ β ≠ Δβ-1 → Overflow between two variables
0x400517
0x7fffffffdc12 0x7fffffffdc13 0x7fffffffdc140x7fffffffdc110x7fffffffdc10
<3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc14, 4>
Execution
Nb
Instruction
STORE instruction
1
5
6
Loop
Compare and
Branch instruction
Stack
<x,Δ1,S> <x,Δ2,S>
50
Stack Overflow Analysis
●
The main weakness of this approach is the false positives in a specific case
●
Lots of developers use the memset function to fill structures
● Let assume A,B S such that A→<1,Δ,4>, B→<1,Δ+4,4> and S→<1,Δ,8>∈
● When the memset function is applied, the analysis will detect a stack
overflow from the area A to B
f(){
struct s_foo S;
memset(&S, 0, sizeof(struct s_foo));
…
}
51
● Format String Analysis
52
● This analysis mainly relies on the Taint Engine
● We monitor all functions susceptible to use string formats
– Based on the calling convention, when a CALL occurs we get
the function's arguments
– If the first argument points on a tainted area, it means that the
user can control the format string
● Implies a format string bug
Format String Analysis
RDI: string
CALL
RDI: string
RSI: va_arg1
CALL
RDI: string
RSI: va_arg1
RDX: va_arg2
CALL
printf(ptr)
printf(ptr, arg1)
printf(ptr, arg1, arg2)
RDI is an address. Does this address contains tainted bytes?
53
● {Write, Read}-What-Where Analysis
54
● This analysis mainly relies on the Taint Engine
● We must monitor all STORE/LOAD instruction and check if the destination/source is tainted
● LOAD:
– If reg is tainted → read-where bug
● STORE:
– If reg is tainted → write-where bug
– If both operands are tainted (reg, reg) → write-what-where bug
{Write, Read}-What-Where Analysis
Memory
LOAD STORE
mov r, [ ] Mov [ ], r/imm
Tainted?
regreg
Unsafe
Safe
Yes
No
55
● Conclusion
56
● Covering a function or its state is not enough
● We must apply some behavior analysis during the execution
to find bugs which do not make the program to crash
● Building a generic algorithm to find all kind of bugs is hard
– We must build specific analysis to find specific bugs
● Lots of developments must be done before starting to work
on the analysis part
– Some analysis may reposes on the result of engines like the
write-what-where or format string bugs which are based on the
Taint Engine
Conclusion
57
● The Triton project !The Triton Project
58
● The Triton project !The Triton Project
● Triton provides some engines to improve analysis given by the Pin framework
● Developed in close collaboration with Florent Saudel
● Basically the Triton's engines are:
– A Taint engine
● Mainly used to know what variables and part of memory are controllable by the user at each program point
– A Symbolic state engine
● Mainly used to build symbolic expression for each register/memory at each program point
– A Snapshot engine
● Mainly used to replay traces directly in memory without running again the program
– It also provides an Intermediate Representation in SMT2-LIB
● Mainly used to solve equations with a theorem prover
– It provides an interface with Z3 to solve symbolic expression like the paths condition
– Then, it also applies all analysis described in this talk
● The Triton project will be detailed and released at SSTIC 2015
59
● Final Words
60
● Recap:
– It possible to cover a function in memory using snapshot and dynamic
symbolic execution
– It possible to find bugs without side effect (like SIGSEGV)
● Some bugs do not crash the program
– Really hard to make generic algorithms to find all kind of bugs
● We must build specific analysis for each bugs category
– Use symbolic execution for code coverage and dynamic behavior
analysis to find vulnerabilities in paths
● Increase your chance to find bugs
– Triton project announcement
Final Words
61
● Contact
– Mail: jsalwan@quarkslab.com
– Twitter: @JonathanSalwan
● Thanks
– I would like to thank the st'hack's staff and especially Florian Gaultier for the invitation
and his hard work. Thanks also to Jean-Christophe Delaunay, Serge Guelton and
Eloi Vanderbeken for the proofreading
Thanks For Your Attention
Question(s)?
62
●
How did you detect the loops?
● The main problem was for the stack and the heap overflow analysis
● Detect loops at runtime is a kind of challenge
– Lots of papers apply a first pass of static analysis to build CFG and
locates the loops
● Actually, what we did is a kind of “hack” and we did not found the
good way yet...
● At runtime, we maintains a map of <Δ:n> where Δ is the address of
the current instruction and n *∈ ℕ the number of hits
●
Generally a loop ends by a branch instruction and contains more
than 1 hits (n)
●
We apply some heuristics based on these “tricks”
●
One of the problem with this, is that we can't detect a loop of 1
iteration. However, should we consider this as a loop?
●
Even if we don't apply runtime analysis, all results of the trace can
be stored in a database and further processed
Q&A - Problems Encountered
Addr Nb Inst
4004e4 1 push rbp
4004e5 1 mov rbp, rsp
4004e8 1 mov dword ptr [rbp-0x14], edi
4004eb 1 mov qword ptr [rbp-0x20], rsi
4004ef 1 mov dword ptr [rbp-0x10], 0x11111111
4004f6 1 mov dword ptr [rbp-0x8], 0x22222222
4004fd 1 mov dword ptr [rbp-0xc], 0x33333333
400504 1 mov dword ptr [rbp-0x4], 0x0
40050b 1 jmp 0x40051e
40050d 5 mov eax, dword ptr [rbp-0x4]
400510 5 lea rdx, ptr [rbp-0x10]
400514 5 add rax, rdx
400517 5 mov byte ptr [rax], 0x2e
40051a 5 add dword ptr [rbp-0x4], 0x1
40051e 6 cmp dword ptr [rbp-0x4], 0x4
400522 6 jbe 0x40050d
400524 1 mov eax, 0x0
400529 1 pop rbp
40052a 1 ret
Probably a loop
63
● Does your analysis imply overheads?
● Yes, of course as a lots of tools
● By default DBI increases the time of the execution. Add others
analysis and you got an overhead of 500% to 1000%
● For example, Triton processes 5,120,000 of expressions (with
dataflow, SMT translation, symbolic state,...) around 140 seconds
with 12Go of consumed RAM
– Tested on a Lenovo x230 - i7-3520M CPU @ 2.90GHz
● Still unworkable on a whole binary as Firefox, chromium, etc...
– That is why we target specific functions
Q&A - Benchmarks
64
● Do you have some future ideas?
● Yes:
– First of all: still working on the Triton design
– Optimize the symbolic execution processing using a semantics' dictionary
(poke Florent)
– Optimize the memory usage caused by the execution using a custom remote
allocation implemented as a kernel module
– Use abstract interpretation in specific cases (poke Eloi)
– Build a real runtime models checking
– Search how can we parallelize the execution (fork at each branch?)
– Manage the memory snapshotting using memory versioning
– IDA plugin
– And still lots of secret ideas :)
Q&A – Future Work?

More Related Content

What's hot

Fast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
Fast and Precise Symbolic Analysis of Concurrency Bugs in Device DriversFast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
Fast and Precise Symbolic Analysis of Concurrency Bugs in Device DriversPantazis Deligiannis
 
Clock driven scheduling
Clock driven schedulingClock driven scheduling
Clock driven schedulingKamal Acharya
 
Synthesizing Concurrent Schedulers for Irregular Algorithms
Synthesizing Concurrent Schedulers for Irregular AlgorithmsSynthesizing Concurrent Schedulers for Irregular Algorithms
Synthesizing Concurrent Schedulers for Irregular AlgorithmsDonald Nguyen
 
[Question Paper] Embedded System (Revised Course) [June / 2014]
[Question Paper] Embedded System (Revised Course) [June / 2014][Question Paper] Embedded System (Revised Course) [June / 2014]
[Question Paper] Embedded System (Revised Course) [June / 2014]Mumbai B.Sc.IT Study
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksMukesh Chinta
 
Commonly used Approaches to Real Time Scheduling
Commonly used Approaches to Real Time SchedulingCommonly used Approaches to Real Time Scheduling
Commonly used Approaches to Real Time SchedulingRaaz Karkee
 
Priority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasksPriority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasksKamal Acharya
 
Command Line Interface - Control Chamber
Command Line Interface - Control ChamberCommand Line Interface - Control Chamber
Command Line Interface - Control ChamberWorachart Pirunruk
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the MetalC4Media
 
Operating System - FCFS and Priority Scheduling Algorithm and Code
Operating System - FCFS and Priority Scheduling Algorithm and Code Operating System - FCFS and Priority Scheduling Algorithm and Code
Operating System - FCFS and Priority Scheduling Algorithm and Code Tamir Azrab
 
Numerical analysis m5 l1slides
Numerical analysis  m5 l1slidesNumerical analysis  m5 l1slides
Numerical analysis m5 l1slidesSHAMJITH KM
 
[Question Paper] Embedded System (Revised Course) [June / 2016]
[Question Paper] Embedded System (Revised Course) [June / 2016][Question Paper] Embedded System (Revised Course) [June / 2016]
[Question Paper] Embedded System (Revised Course) [June / 2016]Mumbai B.Sc.IT Study
 

What's hot (20)

Fast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
Fast and Precise Symbolic Analysis of Concurrency Bugs in Device DriversFast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
Fast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
 
Replikativ
ReplikativReplikativ
Replikativ
 
Clock driven scheduling
Clock driven schedulingClock driven scheduling
Clock driven scheduling
 
Synthesizing Concurrent Schedulers for Irregular Algorithms
Synthesizing Concurrent Schedulers for Irregular AlgorithmsSynthesizing Concurrent Schedulers for Irregular Algorithms
Synthesizing Concurrent Schedulers for Irregular Algorithms
 
Periodic
PeriodicPeriodic
Periodic
 
Run time
Run timeRun time
Run time
 
[Question Paper] Embedded System (Revised Course) [June / 2014]
[Question Paper] Embedded System (Revised Course) [June / 2014][Question Paper] Embedded System (Revised Course) [June / 2014]
[Question Paper] Embedded System (Revised Course) [June / 2014]
 
Vft
VftVft
Vft
 
Ch7
Ch7Ch7
Ch7
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
 
Dconf2015 d2 t4
Dconf2015 d2 t4Dconf2015 d2 t4
Dconf2015 d2 t4
 
Commonly used Approaches to Real Time Scheduling
Commonly used Approaches to Real Time SchedulingCommonly used Approaches to Real Time Scheduling
Commonly used Approaches to Real Time Scheduling
 
Priority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasksPriority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasks
 
Command Line Interface - Control Chamber
Command Line Interface - Control ChamberCommand Line Interface - Control Chamber
Command Line Interface - Control Chamber
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the Metal
 
Operating System - FCFS and Priority Scheduling Algorithm and Code
Operating System - FCFS and Priority Scheduling Algorithm and Code Operating System - FCFS and Priority Scheduling Algorithm and Code
Operating System - FCFS and Priority Scheduling Algorithm and Code
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Numerical analysis m5 l1slides
Numerical analysis  m5 l1slidesNumerical analysis  m5 l1slides
Numerical analysis m5 l1slides
 
Operating System
Operating SystemOperating System
Operating System
 
[Question Paper] Embedded System (Revised Course) [June / 2016]
[Question Paper] Embedded System (Revised Course) [June / 2016][Question Paper] Embedded System (Revised Course) [June / 2016]
[Question Paper] Embedded System (Revised Course) [June / 2016]
 

Viewers also liked

Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)
Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)
Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)James Clause
 
Risk Management Webinar
Risk Management WebinarRisk Management Webinar
Risk Management Webinarjanemangat
 
Code Instrumentation, Dynamic Tracing
Code Instrumentation, Dynamic TracingCode Instrumentation, Dynamic Tracing
Code Instrumentation, Dynamic TracingMartin Děcký
 
Covering a function using a Dynamic Symbolic Execution approach
Covering a function using a Dynamic Symbolic Execution approach Covering a function using a Dynamic Symbolic Execution approach
Covering a function using a Dynamic Symbolic Execution approach Jonathan Salwan
 
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentationnullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentationn|u - The Open Security Community
 
Binary instrumentation - dc9723
Binary instrumentation - dc9723Binary instrumentation - dc9723
Binary instrumentation - dc9723Iftach Ian Amit
 
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...GangSeok Lee
 
2010 02 instrumentation_and_runtime_measurement
2010 02 instrumentation_and_runtime_measurement2010 02 instrumentation_and_runtime_measurement
2010 02 instrumentation_and_runtime_measurementPTIHPA
 
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...Ajin Abraham
 
GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)Jaroslav Bachorik
 
«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...
«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...
«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...OWASP Russia
 

Viewers also liked (12)

Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)
Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)
Demand-Driven Structural Testing with Dynamic Instrumentation (ICSE 2005)
 
Risk Management Webinar
Risk Management WebinarRisk Management Webinar
Risk Management Webinar
 
Code Instrumentation, Dynamic Tracing
Code Instrumentation, Dynamic TracingCode Instrumentation, Dynamic Tracing
Code Instrumentation, Dynamic Tracing
 
Covering a function using a Dynamic Symbolic Execution approach
Covering a function using a Dynamic Symbolic Execution approach Covering a function using a Dynamic Symbolic Execution approach
Covering a function using a Dynamic Symbolic Execution approach
 
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentationnullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
nullcon 2011 - Automatic Program Analysis using Dynamic Binary Instrumentation
 
Binary instrumentation - dc9723
Binary instrumentation - dc9723Binary instrumentation - dc9723
Binary instrumentation - dc9723
 
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
 
Valgrind
ValgrindValgrind
Valgrind
 
2010 02 instrumentation_and_runtime_measurement
2010 02 instrumentation_and_runtime_measurement2010 02 instrumentation_and_runtime_measurement
2010 02 instrumentation_and_runtime_measurement
 
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
 
GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)
 
«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...
«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...
«Вредоносные браузерные расширения и борьба с ними», Александра Сватикова (Од...
 

Similar to Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis Using Binary Instrumentation

Kinetic Dependence Graphs
Kinetic Dependence GraphsKinetic Dependence Graphs
Kinetic Dependence GraphsDonald Nguyen
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clustersBurak Himmetoglu
 
Introduction to nand2 tetris
Introduction to nand2 tetrisIntroduction to nand2 tetris
Introduction to nand2 tetrisYodalee
 
APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...
APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...
APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...SohamChatterjee47
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++Chen-Han Hsiao
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Chapter 3- Software Project Management(Reduced).ppt
Chapter 3- Software Project Management(Reduced).pptChapter 3- Software Project Management(Reduced).ppt
Chapter 3- Software Project Management(Reduced).pptpayelguria1
 
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander NasonovMultiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonoveurobsdcon
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdfishan743441
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialTo Sum It Up
 

Similar to Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis Using Binary Instrumentation (20)

Scrum - twice as much, twice as fast
Scrum - twice as much, twice as fastScrum - twice as much, twice as fast
Scrum - twice as much, twice as fast
 
Kinetic Dependence Graphs
Kinetic Dependence GraphsKinetic Dependence Graphs
Kinetic Dependence Graphs
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clusters
 
Introduction to nand2 tetris
Introduction to nand2 tetrisIntroduction to nand2 tetris
Introduction to nand2 tetris
 
APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...
APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...
APznzaZSEwUJhKEim-rOA-Svk6nc1xZygCeBBAW4QZluPqM0dLSELK_S9YNDE8po44L2LgB6Is5VJ...
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++2014-06-26 - A guide to undefined behavior in c and c++
2014-06-26 - A guide to undefined behavior in c and c++
 
Cpmprt
CpmprtCpmprt
Cpmprt
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Unit i
Unit iUnit i
Unit i
 
Chapter 3- Software Project Management(Reduced).ppt
Chapter 3- Software Project Management(Reduced).pptChapter 3- Software Project Management(Reduced).ppt
Chapter 3- Software Project Management(Reduced).ppt
 
Scratch pcduino
Scratch pcduinoScratch pcduino
Scratch pcduino
 
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander NasonovMultiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonov
 
OS_Ch7
OS_Ch7OS_Ch7
OS_Ch7
 
Algorithms
Algorithms Algorithms
Algorithms
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
markomanolis_phd_defense
markomanolis_phd_defensemarkomanolis_phd_defense
markomanolis_phd_defense
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
 

More from StHack

Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"
Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"
Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"StHack
 
Sthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cash
Sthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cashSthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cash
Sthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cashStHack
 
Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...
Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...
Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...StHack
 
Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...
Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...
Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...StHack
 
Sthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practice
Sthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practiceSthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practice
Sthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practiceStHack
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack
 
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injectionStHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injectionStHack
 
StHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coin
StHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coinStHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coin
StHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coinStHack
 
StHack 2014 - Benjamin "@gentilkiwi" Delpy Mimikatz
StHack 2014 - Benjamin "@gentilkiwi" Delpy MimikatzStHack 2014 - Benjamin "@gentilkiwi" Delpy Mimikatz
StHack 2014 - Benjamin "@gentilkiwi" Delpy MimikatzStHack
 
StHack 2014 - Jerome "@funoverip" Nokin Turning your managed av into my botnet
StHack 2014 - Jerome "@funoverip" Nokin  Turning your managed av into my botnetStHack 2014 - Jerome "@funoverip" Nokin  Turning your managed av into my botnet
StHack 2014 - Jerome "@funoverip" Nokin Turning your managed av into my botnetStHack
 
StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101StHack
 

More from StHack (11)

Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"
Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"
Sthack 2015 - Ramon Vicens & Victor Acin - Cyber threats "the reality"
 
Sthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cash
Sthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cashSthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cash
Sthack 2015 - David Berard & Vincent Fargues - Attack the cache to get some cash
 
Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...
Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...
Sthack 2015 - Wilfrid "@WilfridBlanc" Blanc & Adrien Revol - Cybersécurité In...
 
Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...
Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...
Sthack 2015 - Aris "@aris_ada" Adamantiadis - DUAL_EC_DRBG : Une histoire de ...
 
Sthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practice
Sthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practiceSthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practice
Sthack 2015 - Renaud "@nono2357" Lifchitz - Quantum computing in practice
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injectionStHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
 
StHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coin
StHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coinStHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coin
StHack 2013 - Nicolas "@baldanos" Oberli Please insert inject more coin
 
StHack 2014 - Benjamin "@gentilkiwi" Delpy Mimikatz
StHack 2014 - Benjamin "@gentilkiwi" Delpy MimikatzStHack 2014 - Benjamin "@gentilkiwi" Delpy Mimikatz
StHack 2014 - Benjamin "@gentilkiwi" Delpy Mimikatz
 
StHack 2014 - Jerome "@funoverip" Nokin Turning your managed av into my botnet
StHack 2014 - Jerome "@funoverip" Nokin  Turning your managed av into my botnetStHack 2014 - Jerome "@funoverip" Nokin  Turning your managed av into my botnet
StHack 2014 - Jerome "@funoverip" Nokin Turning your managed av into my botnet
 
StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101
 

Recently uploaded

Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 

Recently uploaded (20)

Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 

Sthack 2015 - Jonathan "@JonathanSalwan" Salwan - Dynamic Behavior Analysis Using Binary Instrumentation

  • 1. Dynamic Behavior Analysis Using Binary Instrumentation Jonathan Salwan jsalwan@quarkslab.com St'Hack Bordeaux – France March 27 2015 Keywords: program analysis, DBI, DBA, Pin, concrete execution, symbolic execution, DSE, taint analysis, context snapshot, Z3 theorem prover and behavior analysis.
  • 2. 2 ● I am a junior security researcher at Quarkslab working on tools development for programs analysis ● I have a strong interest in all low level computing ● I like to play with weird things even though it sometimes seems useless Who Am I?
  • 3. 3 ● Few words about the goal of this stuff ● Short review of the Security Day Lille's talk – Really short introduction – Covering a function using DSE approach – Some words about vulnerabilities hunting ● Objectives of this talk – Build specific analysis to find specific bugs ● Analysis for use-after-free detection ● Analysis for heap overflow detection ● Analysis for stack overflow detection ● Analysis for format string detection ● Analysis for {wrtite, read}-what-where detection – Few words about generic analysis – Few words about the Triton project !! ● Conclusion ● Q&A Roadmap Of This Talk
  • 4. 4 ● First Of All – The Goal Of This Stuff
  • 5. 5 ● Main goal: – I want to analyze a binary dynamically – I want to find unexpected behaviors in its execution to find potential vulnerabilities ● Even if these bugs do not crash the program ● First Of All – The Goal Of This Stuff ba 05 00 00 00 be 00 58 40 00 31 ff 89 4c 24 10 e8 1c fb ff ff 31 f6 48 89 c2 bf 01 00 00 00 31 c0 e8 3b fd ff ff 8b 05 35 67 20 00 8b 4c 24 10 Be 30 58 40 00 31 ba 05 00 00 00 be 00 58 40 00 31 ff 89 4c 24 10 e8 1c fb ff ff 31 f6 48 89 c2 bf 01 00 00 00 31 c0 e8 3b fd ff ff 8b 05 35 67 20 00 8b 4c 24 10 Be 30 58 40 00 31 Execution Behavior Analysis binary Analysis 1 Analysis 2
  • 6. 6 ● Short Review Of The Security Day Lille's Talk
  • 7. 7 ● In the last talk [0], we saw how it was possible to cover a function in memory using a dynamic symbolic execution approach – We generate and inject concrete values in memory in order to go through all paths ● Short Review Of The Security Day Lille's Talk [0] http://shell-storm.org/talks/SecurityDay2015_dynamic_symbolic_execution_Jonathan_Salwan.pdf
  • 8. 8 ● Basically, we: – Target a function – Take a context snapshot at the first instruction – Switch to a dynamic symbolic execution in order to build the path constraint (PC) – Restore the snapshot and generate another concrete value to go through another path – Repeat this operation until all paths are taken ● Short Review Of The Security Day Lille's Talk
  • 9. 9 ● In a nutshell, we got something like this: ● Short Review Of The Security Day Lille's Talk Restore context Snapshot Restore SnapshotTarget function / basic block Dynamic Symbolic Execution Possible paths in the target
  • 10. 10 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: Control flow graph ρin ρ1 ρ2 ρout ρ3 π1 π2
  • 11. 11 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 1st iterationTake a snapshot
  • 12. 12 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 1st iteration PC = T : {ρin}Add to scope
  • 13. 13 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin} ¬π1
  • 14. 14 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1} Add to scope
  • 15. 15 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} Add to scope
  • 16. 16 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 1st iteration Restore the snapshot PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout}
  • 17. 17 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} Add to scope 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout}
  • 18. 18 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 : {ρin} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} π1
  • 19. 19 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 : {ρin, ρ2} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} Add to scope
  • 20. 20 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} ¬π2
  • 21. 21 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} Add to scope
  • 22. 22 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} Restore the snapshot
  • 23. 23 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} Add to scope 3th iteration PC = T : {ρin}
  • 24. 24 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} 3th iteration PC = T : {ρin} PC = π1 : {ρin} π1
  • 25. 25 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} 3th iteration PC = T : {ρin} PC = π1 : {ρin, ρ2} Add to scope
  • 26. 26 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} 3th iteration PC = T : {ρin} PC = π1 π∧ 2 : {ρin, ρ2} π2
  • 27. 27 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} 3th iteration PC = T : {ρin} PC = π1 π∧ 2 : {ρin, ρ2, ρ3} Add to scope
  • 28. 28 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} 3th iteration PC = T : {ρin} PC = π1 π∧ 2 : {ρin, ρ2, ρ3, ρout} Add to scope
  • 29. 29 ● Dynamic Symbolic Execution ● The Dynamic Symbolic Execution process looks like this: ρin ρ1 ρ2 ρout ρ3 π1 π2 2nd iteration PC = T : {ρin} PC = π1 ¬π∧ 2: {ρin, ρ2, ρout} 1st iteration PC = T : {ρin} PC = ¬π1 : {ρin, ρ1, ρout} 3th iteration PC = T : {ρin} PC = π1 π∧ 2 : {ρin, ρ2, ρ3, ρout} There is no more branches, so the restore process is over PC1 = T : {ρin} PC2 = ¬π1 : {ρin, ρ1, ρout} PC3 = π1 ¬π∧ 2: {ρin, ρ2, ρout} PC4 = π1 π∧ 2 : {ρin, ρ2, ρ3, ρout}
  • 30. 30 ● Symbolic Execution Guided By The Taint Analysis
  • 31. 31 ● Symbolic Execution Guided By The Taint Analysis ● Taint analysis provides information about which registers and memory addresses are controllable by the user at each program point: – Assists the symbolic engine to setup the symbolic variables (a symbolic variable is a memory area that the user can control) – May assist the symbolic engine to perform some symbolic optimizations – At each branch instruction, we directly know if the user can go through both branches (this is mainly used for code coverage)
  • 32. 32 ● Symbolic Execution Guided By The Taint Analysis What user can control ? Can I take both branches ?
  • 33. 33 ● Symbolic Execution Guided By The Taint Analysis ZF is controllable, so I can choose the branch Tainted memory area Spread the taint
  • 34. 34 ● Few Words About Fuzzing
  • 35. 35 ● Few Words About Fuzzing ● Generally, the main objective is to cover a maximum of code by injecting different input samples and wait for a side effect like a segmentation fault – When a segmentation fault occurs, it means that we probably found a bug – The main issue is that some bugs do not make the program crash Never triggered Never triggered Side effect → Segfault Side effect → SegfaultNo side effect, no crash How can I find it? Program Iteration 2 Iteration 1 bug Program Coverage Entry point
  • 36. 36 ● Is Covering All The Paths Enough To Find Vulnerabilities?
  • 37. 37 Ignored values Ignored values ● Is Covering All The Paths Enough To Find Vulnerabilities? Values set Execution (time) Set of values ignored in the path Set of possible values used in the path State of variables during the execution Values that trigger a vulnerability ● No! Code coverage != State coverage. A variable can hold several values during the execution and some of these may not trigger any bug. ● We must generate all concrete values that a path can hold to cover all the possible states. – Imply a lot of overload in the worst case ● Below, a Cousot style graph which represents some possible states of a variable during the execution in a path.
  • 38. 38 Ignored values Ignored values ● A Bug May Not Make The Program Crash Values set Execution (time) Set of values ignored in the path Set of possible values used in the path State of the variable during the execution Values that trigger a vulnerability ● Another important point is that a bug may not make the program crash ● Lots of fuzzers are based on the fact that a bug may have side effect like a SIGSEGV – That's why we must implement some behavior analysis to find bugs which does not make the program crash May not cause a crash
  • 39. 39 ● OK, now that the introduction is over, let's start the talk!
  • 40. 40 ● Covering a function is not enough to find vulnerabilities – We must apply some “behavior analysis” at runtime using binary instrumentation ● Really hard to build a generic analysis which find all kind of bugs ● So, we must build specific analysis to find specific bugs ● What kind of bugs we want to find? In this talk we will see how to find these kind of bugs: – Use-after-free – Overflow on heap / stack – Format string – {write, read}-what-where Objective Of This Talk
  • 42. 42 ● An use-after-free mainly occurs when there is a LOAD/STORE on an already freed area ● First, we maintain an allocation map (TA) and a free map (TF) of <Δ,S> items where Δ is the base address of the allocation and S its size. <Δ,S> represents an area – Monitor the malloc (*alloc) function(s) ● Δ is provided by the EAX register at the malloc return ● S is provided by the argument of the malloc call ● We add a new <Δ,S> in TA and delete the <Δ,S> in TF if it exist. – If Δnew TF∈ ∧ Snew ≠ Sold → <Δold,Sold>TF is divided in two items where the first item will be in TA and the second item will still be in TF – When a free occurs we move the <Δ,S> from TA to TF – When a LOAD/STORE occurs, we check if there is a Δ in TA or TF and applies these following rules: ● If Δ TA∈ → valid memory access ● If Δ TA Δ TF∉ ∧ ∉ → invalid memory access ● If Δ TA Δ TF∉ ∧ ∈ → use-after-free Use-After-Free Analysis Allocate Used Freed Used Execution
  • 44. 44 ● Maintain an allocation map (TA) of <Δ,S> where Δ is the base address of the allocation and S its size (<Δ,S> represents an area) ● Monitor all STORE / LOAD and checkup if Δ TA∈ ● We denote β ∈ ℕ0 the iteration number and <Δβ,Sβ> the area description over each loop iteration ● When a loop applies a linear STORE, we apply these rules: – If β * Δ∈ ℕ ∧ β = Δβ-1 β < S → OK∧ – If β * Δ∈ ℕ ∧ β ≠ Δβ-1 β >= S → Heap overflow∧ Heap Overflow Analysis Execution Nb Instruction STORE instruction 1 5 6 Loop Compare and Branch instruction Memory <Δ, S> STORE outside an allocated area
  • 46. 46 ● Two possible analysis: – Overflow outside the stack frame – Overflow between two variables of a same stack frame ● We will focus on this analysis Stack Overflow Analysis int a, b, i; a = 0x90909090; b = 0x91919191; for (i = 0; i <= sizeof(b); i++) /* off-by-one */ *(((unsigned char *)(&b))+i) = 'E'; Same stack frame One byte wrote outside the b area How can I detect this off-by-one?
  • 47. 47 ● We must: – Isolate all stack frames ● Routine may be given by Pin or monitor all call/ret ● Then, the area is given by the prologue – Find how many variables are in the stack frame ● We use the A-Locs (Abstract Locations) methods from the Value-Set-Analysis paper [0] – Assign an area <ID,Δ,S> for each variable where ID ∈ is the unique stackℕ frame id, Δ the base address of the variable and S the size of the variable ● Like heap overflow analysis, check if there is a change of area <ID,Δ,S> during a linear STORE Stack Overflow Analysis [0] Analyzing Memory Accesses in x86 Executables by Gogul Balakrishnan and Thomas Reps http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.129.1920&rep=rep1&type=pdf Each stack frame must have a unique ID
  • 48. 48 Stack Overflow Analysis 01. 4006d4: mov qword ptr [rbp-0x10], 0x0 (dest: 7fffdae70d10) (stack frame ID: 3) 02. 4006dc: mov qword ptr [rbp-0x18], 0x0 (dest: 7fffdae70d08) (stack frame ID: 3) 03. 4006e4: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70d1c) (stack frame ID: 3) 04. 40071f: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70d1c) (stack frame ID: 5) 05. 400742: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70d1c) (stack frame ID: 5) 06. 400640: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70cdc) (stack frame ID: 9) 07. 400669: mov dword ptr [rbp-0x8], 0x90909090 (dest: 7fffdae70cd8) (stack frame ID: 10) 08. 400670: mov dword ptr [rbp-0xc], 0x91919191 (dest: 7fffdae70cd4) (stack frame ID: 10) 09. 400677: mov dword ptr [rbp-0x4], 0x0 (dest: 7fffdae70cdc) (stack frame ID: 10) 10. 11. id stack frame: 3 Num var: 3 12. id stack frame: 5 Num var: 1 13. id stack frame: 9 Num var: 1 14. id stack frame: 10 Num var: 3 1 var ● If there is two assignments on a same <ID,Δ> → Interpret this as one variable area (take a look at line .04 and .05) ● However, if there is two assignments on <ID,Δ> and <ID,Δ+n> → Interpret this as two variables areas and we must refine the first area
  • 49. 49 Stack Overflow Analysis ● As the heap overflow analysis, we must monitor each loop which applies a linear STORE and check if there is a change of area ● We denote β ∈ ℕ0 the iteration number and <IDβ,Δβ,Sβ> the area description over each loop iteration ● If β * X∈ ℕ ∧ β = Xβ-1 ∧ Δβ = Δβ-1 → OK ● If β * X∈ ℕ ∧ β ≠ Xβ-1 → Overflow outside the stack frame ● If β * Δ∈ ℕ ∧ β ≠ Δβ-1 → Overflow between two variables 0x400517 0x7fffffffdc12 0x7fffffffdc13 0x7fffffffdc140x7fffffffdc110x7fffffffdc10 <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc10, 4> <3, 0x7fffffffdc14, 4> Execution Nb Instruction STORE instruction 1 5 6 Loop Compare and Branch instruction Stack <x,Δ1,S> <x,Δ2,S>
  • 50. 50 Stack Overflow Analysis ● The main weakness of this approach is the false positives in a specific case ● Lots of developers use the memset function to fill structures ● Let assume A,B S such that A→<1,Δ,4>, B→<1,Δ+4,4> and S→<1,Δ,8>∈ ● When the memset function is applied, the analysis will detect a stack overflow from the area A to B f(){ struct s_foo S; memset(&S, 0, sizeof(struct s_foo)); … }
  • 52. 52 ● This analysis mainly relies on the Taint Engine ● We monitor all functions susceptible to use string formats – Based on the calling convention, when a CALL occurs we get the function's arguments – If the first argument points on a tainted area, it means that the user can control the format string ● Implies a format string bug Format String Analysis RDI: string CALL RDI: string RSI: va_arg1 CALL RDI: string RSI: va_arg1 RDX: va_arg2 CALL printf(ptr) printf(ptr, arg1) printf(ptr, arg1, arg2) RDI is an address. Does this address contains tainted bytes?
  • 54. 54 ● This analysis mainly relies on the Taint Engine ● We must monitor all STORE/LOAD instruction and check if the destination/source is tainted ● LOAD: – If reg is tainted → read-where bug ● STORE: – If reg is tainted → write-where bug – If both operands are tainted (reg, reg) → write-what-where bug {Write, Read}-What-Where Analysis Memory LOAD STORE mov r, [ ] Mov [ ], r/imm Tainted? regreg Unsafe Safe Yes No
  • 56. 56 ● Covering a function or its state is not enough ● We must apply some behavior analysis during the execution to find bugs which do not make the program to crash ● Building a generic algorithm to find all kind of bugs is hard – We must build specific analysis to find specific bugs ● Lots of developments must be done before starting to work on the analysis part – Some analysis may reposes on the result of engines like the write-what-where or format string bugs which are based on the Taint Engine Conclusion
  • 57. 57 ● The Triton project !The Triton Project
  • 58. 58 ● The Triton project !The Triton Project ● Triton provides some engines to improve analysis given by the Pin framework ● Developed in close collaboration with Florent Saudel ● Basically the Triton's engines are: – A Taint engine ● Mainly used to know what variables and part of memory are controllable by the user at each program point – A Symbolic state engine ● Mainly used to build symbolic expression for each register/memory at each program point – A Snapshot engine ● Mainly used to replay traces directly in memory without running again the program – It also provides an Intermediate Representation in SMT2-LIB ● Mainly used to solve equations with a theorem prover – It provides an interface with Z3 to solve symbolic expression like the paths condition – Then, it also applies all analysis described in this talk ● The Triton project will be detailed and released at SSTIC 2015
  • 60. 60 ● Recap: – It possible to cover a function in memory using snapshot and dynamic symbolic execution – It possible to find bugs without side effect (like SIGSEGV) ● Some bugs do not crash the program – Really hard to make generic algorithms to find all kind of bugs ● We must build specific analysis for each bugs category – Use symbolic execution for code coverage and dynamic behavior analysis to find vulnerabilities in paths ● Increase your chance to find bugs – Triton project announcement Final Words
  • 61. 61 ● Contact – Mail: jsalwan@quarkslab.com – Twitter: @JonathanSalwan ● Thanks – I would like to thank the st'hack's staff and especially Florian Gaultier for the invitation and his hard work. Thanks also to Jean-Christophe Delaunay, Serge Guelton and Eloi Vanderbeken for the proofreading Thanks For Your Attention Question(s)?
  • 62. 62 ● How did you detect the loops? ● The main problem was for the stack and the heap overflow analysis ● Detect loops at runtime is a kind of challenge – Lots of papers apply a first pass of static analysis to build CFG and locates the loops ● Actually, what we did is a kind of “hack” and we did not found the good way yet... ● At runtime, we maintains a map of <Δ:n> where Δ is the address of the current instruction and n *∈ ℕ the number of hits ● Generally a loop ends by a branch instruction and contains more than 1 hits (n) ● We apply some heuristics based on these “tricks” ● One of the problem with this, is that we can't detect a loop of 1 iteration. However, should we consider this as a loop? ● Even if we don't apply runtime analysis, all results of the trace can be stored in a database and further processed Q&A - Problems Encountered Addr Nb Inst 4004e4 1 push rbp 4004e5 1 mov rbp, rsp 4004e8 1 mov dword ptr [rbp-0x14], edi 4004eb 1 mov qword ptr [rbp-0x20], rsi 4004ef 1 mov dword ptr [rbp-0x10], 0x11111111 4004f6 1 mov dword ptr [rbp-0x8], 0x22222222 4004fd 1 mov dword ptr [rbp-0xc], 0x33333333 400504 1 mov dword ptr [rbp-0x4], 0x0 40050b 1 jmp 0x40051e 40050d 5 mov eax, dword ptr [rbp-0x4] 400510 5 lea rdx, ptr [rbp-0x10] 400514 5 add rax, rdx 400517 5 mov byte ptr [rax], 0x2e 40051a 5 add dword ptr [rbp-0x4], 0x1 40051e 6 cmp dword ptr [rbp-0x4], 0x4 400522 6 jbe 0x40050d 400524 1 mov eax, 0x0 400529 1 pop rbp 40052a 1 ret Probably a loop
  • 63. 63 ● Does your analysis imply overheads? ● Yes, of course as a lots of tools ● By default DBI increases the time of the execution. Add others analysis and you got an overhead of 500% to 1000% ● For example, Triton processes 5,120,000 of expressions (with dataflow, SMT translation, symbolic state,...) around 140 seconds with 12Go of consumed RAM – Tested on a Lenovo x230 - i7-3520M CPU @ 2.90GHz ● Still unworkable on a whole binary as Firefox, chromium, etc... – That is why we target specific functions Q&A - Benchmarks
  • 64. 64 ● Do you have some future ideas? ● Yes: – First of all: still working on the Triton design – Optimize the symbolic execution processing using a semantics' dictionary (poke Florent) – Optimize the memory usage caused by the execution using a custom remote allocation implemented as a kernel module – Use abstract interpretation in specific cases (poke Eloi) – Build a real runtime models checking – Search how can we parallelize the execution (fork at each branch?) – Manage the memory snapshotting using memory versioning – IDA plugin – And still lots of secret ideas :) Q&A – Future Work?