SLIDE 1 0-‑Knowledge ¡Fuzzing ¡
Vincenzo ¡Iozzo ¡ vincenzo.iozzo@zynamics.com ¡
SLIDE 2 Disclaimer ¡
You ¡don’t ¡want ¡slides ¡like ¡ this, ¡do ¡you? ¡
In ¡this ¡talk ¡you ¡won’t ¡see ¡all ¡those ¡formulas, ¡formal ¡definiEon, ¡code ¡snippets ¡ and ¡bullets. ¡ ¡ From ¡past ¡experiences ¡the ¡speaker ¡learned ¡that ¡all ¡the ¡aforemenEoned ¡ elements ¡are ¡no ¡useful ¡in ¡making ¡people ¡understand ¡your ¡idea. ¡ You ¡instead ¡will ¡see ¡a ¡lot ¡of ¡funny ¡pictures ¡which ¡the ¡speaker ¡hopes ¡will ¡ convey ¡beIer ¡the ¡understanding ¡of ¡the ¡ideas ¡explained ¡in ¡the ¡talk ¡
SLIDE 3
MoEvaEons ¡
SLIDE 4
QuesEons! ¡
SLIDE 5
Fuzzing ¡
SLIDE 6
How ¡it ¡used ¡to ¡be ¡
SLIDE 7
How ¡it ¡is ¡today ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ (aka ¡the ¡reason ¡of ¡this ¡talk) ¡
SLIDE 8
Dumb ¡fuzzing ¡
SLIDE 9
Smart ¡Fuzzing ¡
SLIDE 10
EvoluEonary ¡Based ¡Fuzzing ¡
SLIDE 11
The ¡idea ¡
SLIDE 12
The ¡surface ¡
SLIDE 13
We ¡need ¡a ¡filter ¡
SLIDE 14
CyclomaEc ¡complexity ¡
SLIDE 15
This ¡one ¡
SLIDE 16
Not ¡this ¡one ¡
SLIDE 17 Original ¡formula ¡
¡ ¡ ¡ ¡M ¡= ¡E ¡– ¡N ¡+ ¡2P ¡
Number ¡of ¡edges ¡ Number ¡of ¡nodes ¡ Connected ¡ components ¡
SLIDE 18 Why? ¡CyclomaEc ¡number ¡
¡ ¡ ¡ ¡M ¡= ¡E ¡– ¡N ¡+ ¡P ¡
SLIDE 19
Simplify ¡
SLIDE 20
Formula ¡
M ¡= ¡E ¡– ¡N ¡+ ¡2 ¡
SLIDE 21
Problem ¡
SLIDE 22
Loop ¡detecEon ¡
SLIDE 23
Dominator ¡tree ¡
SLIDE 24
Dominators ¡
SLIDE 25
FuncEon ¡
SLIDE 26
Dominator ¡tree ¡
SLIDE 27
Dominators ¡
SLIDE 28
Implicit ¡loops ¡
SLIDE 29
REIL ¡
SLIDE 30
This ¡one… ¡
SLIDE 31
…to ¡this ¡one ¡
SLIDE 32
Is ¡that ¡enough? ¡
SLIDE 33 Not ¡enough ¡
Of ¡course ¡not, ¡more ¡heurisEcs ¡needed ¡
void *safe_strcpy(void *old_dest, void *src, int size){ void *dst = realloc(old_dest, size +1); strncpy(dst, src, size); return dst; } ¡
SLIDE 34 Add ¡your ¡own ¡
For ¡staEc ¡analysis ¡we ¡use ¡
SLIDE 35
DEMO ¡
SLIDE 36
QuesEons! ¡
SLIDE 37
Data ¡TainEng ¡
SLIDE 38 Example ¡
Taint ¡ Source ¡
Taint ¡ mark ¡
movl 0x4[eax], ebx ¡
SLIDE 39
Dytan ¡
SLIDE 40
PIN ¡
SLIDE 41
Taint ¡sources ¡
SLIDE 42
Markings ¡granularity ¡
SLIDE 43
PropagaEon ¡ ¡ add eax, ebx, edx ¡
SLIDE 44
Output ¡
¡ ¡ ¡ ¡Registers ¡ ¡ ¡ ¡Memory ¡locaEons ¡
SLIDE 45
DEMO ¡
SLIDE 46
QuesEons! ¡
SLIDE 47
In-‑memory ¡fuzzing ¡
SLIDE 48
Example ¡ rep movs esi ¡= ¡0x30f064 ¡ ¡ esi ¡= ¡0x30f0A4 ¡ ¡ Original ¡loc ¡ ¡ Fuzzed ¡loc ¡ ¡
SLIDE 49
Why? ¡
SLIDE 50
Problems ¡
SLIDE 51
ExperEse ¡and ¡paEence ¡
SLIDE 52
Memory ¡instability ¡
SLIDE 53
False ¡posiEves ¡
SLIDE 54
False ¡negaEves ¡
SLIDE 55
MutaEon ¡loop ¡inserEon ¡
SLIDE 56
Snapshot ¡mutaEon ¡restoraEon ¡
SLIDE 57 What ¡do ¡we ¡do? ¡
- Hook ¡image ¡
- Hook ¡funcEons ¡
- Hook ¡instrucEons ¡
- Hook ¡ ¡
SLIDE 58
First ¡approach ¡
SLIDE 59 For ¡instance… ¡
30f064-‑30f068 ¡ ¡ ¡ ¡ABCD ¡
¡0x8a ¡Y ¡0x00 ¡ K ¡
SLIDE 60
Second ¡approach ¡
SLIDE 61 Example ¡
30f064-‑30f068 ¡ ¡ ¡ ¡ABCD ¡ 30f084-‑30f098 ¡
0x89 ¡K ¡D ¡F ¡0x96 ¡ 0x00 ¡J ¡K ¡U ¡Y ¡W ¡0xA7 ¡ 0xB8 ¡0x00 ¡0x10 ¡A ¡T ¡N ¡ 0x00 ¡0xD3 ¡ ¡ ¡
SLIDE 62
Code ¡coverage ¡
SLIDE 63
Score ¡ BBexecuted/BBtotal ¡
Basic ¡Blocks ¡ executed ¡ Total ¡Basic ¡ Blocks ¡ ¡
SLIDE 64 HalEng ¡
¡Cevil ¡= ¡Cgood ¡+ ¡t ¡ Code ¡coverage ¡ evil ¡sample ¡ Code ¡coverage ¡ good ¡sample ¡ User-‑supplied ¡ threshold ¡
SLIDE 65 How?? ¡
Good ¡sample ¡ Score ¡ ¡ Evil ¡sample ¡ Score ¡ ¡
Compare ¡
SLIDE 66
What ¡do ¡we ¡use? ¡ Code ¡coverage ¡ Faults ¡monitor ¡
SLIDE 67
DEMO ¡
SLIDE 68
Future ¡– ¡A ¡reasoner ¡
SLIDE 69
Thanks ¡
SLIDE 70
QuesEons! ¡
SLIDE 71 More ¡Info ¡
viozzo.wordpress.com ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡@_snagg ¡ ¡ ¡ ¡vincenzo.iozzo@zynamics.com ¡