Abstract Self Modifying Machines Hubert Godfroy joint work with - - PowerPoint PPT Presentation

abstract self modifying machines
SMART_READER_LITE
LIVE PREVIEW

Abstract Self Modifying Machines Hubert Godfroy joint work with - - PowerPoint PPT Presentation

Abstract Self Modifying Machines Hubert Godfroy joint work with Jean-Yves Marion Loria Nancy October 14, 2014 1/32 Plan Introduction Framework Applications 2/32 Plan Introduction Framework Applications 3/32 Program? Data? A


slide-1
SLIDE 1

Abstract Self Modifying Machines

Hubert Godfroy

joint work with Jean-Yves Marion Loria Nancy

October 14, 2014

1/32

slide-2
SLIDE 2

Plan

Introduction Framework Applications

2/32

slide-3
SLIDE 3

Plan

Introduction Framework Applications

3/32

slide-4
SLIDE 4

Program? Data?

◮ A program is something which can be executed. ◮ A data is something which can be read and write

4/32

slide-5
SLIDE 5

Program? Data?

◮ A program is something which can be executed. ◮ A data is something which can be read and write ◮ In most langages, programs are distinct from data. ◮ Example : C, JAVA, OCaml

4/32

slide-6
SLIDE 6

Program? Data?

◮ A program is something which can be executed. ◮ A data is something which can be read and write ◮ In most langages, programs are distinct from data. ◮ Example : C, JAVA, OCaml ◮ There is exceptions... ◮ Programs with exec function have self-modifying behaviors ◮ Example : Python

4/32

slide-7
SLIDE 7

Program? Data?

◮ A program is something which can be executed. ◮ A data is something which can be read and write ◮ In most langages, programs are distinct from data. ◮ Example : C, JAVA, OCaml ◮ There is exceptions... ◮ Programs with exec function have self-modifying behaviors ◮ Example : Python

Low level case: nothing is forbidden!

◮ Programs and data are totally indistinguishable ◮ They belong to the same space (memory)

4/32

slide-8
SLIDE 8

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42) 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 jump 1

5/32

slide-9
SLIDE 9

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 jump 1

5/32

slide-10
SLIDE 10

Example

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 jump 1

5/32

slide-11
SLIDE 11

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1)) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 2

5/32

slide-12
SLIDE 12

Example

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 2

5/32

slide-13
SLIDE 13

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 (E(jump 7) + 42) 10 2

5/32

slide-14
SLIDE 14

Example

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 (E(jump 7) + 42) 10 1

5/32

slide-15
SLIDE 15

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 jump 7 10

5/32

slide-16
SLIDE 16

Example

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 jump 7 10

5/32

slide-17
SLIDE 17

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 jump 7 10

5/32

slide-18
SLIDE 18

Example

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 jump 7 10

5/32

slide-19
SLIDE 19

Example

PoïPoï 1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 print hello world 9 jump 7 10

5/32

slide-20
SLIDE 20

General problematics

Compilation & certification

◮ From non SM programs to SM programs

(obfuscation/optimisation)

◮ Certify compilation

6/32

slide-21
SLIDE 21

General problematics

Compilation & certification

◮ From non SM programs to SM programs

(obfuscation/optimisation)

◮ Certify compilation

Recover high-level semantics from low-level SM semantics

◮ Recover non SM program from SM program... ◮ ...wrt existing models of self-modification (wave semantics)

6/32

slide-22
SLIDE 22

General problematics

Compilation & certification

◮ From non SM programs to SM programs

(obfuscation/optimisation)

◮ Certify compilation

Recover high-level semantics from low-level SM semantics

◮ Recover non SM program from SM program... ◮ ...wrt existing models of self-modification (wave semantics)

Program abstraction

◮ Find abstract model specifically taking about self-modification.

6/32

slide-23
SLIDE 23

Plan

Introduction Framework Applications

7/32

slide-24
SLIDE 24

Current frameworks

◮ Turing machine ◮ RAM (Cook & Reckhow, 1973) ◮ Cellular automaton (Neumann, 1966) ◮ Blob (Jones, 2010) ◮ RASP (Elgot & Robinson, 1964) ◮ SRM (Marion, 2012)

8/32

slide-25
SLIDE 25

Language ASM2

Language over data in D, addresses in A and registers in R : ∀r ∈ R, r : A → D

Abstract machine

◮ Register pointer: RP ∈ R ◮ Instruction pointer: IP ∈ A ◮ Executable zone: X ∈ ℘(R)

X D Memory r1 r2 r3 r4 r5 r6 r7 r8 d1

1 · ... · d1 n

d2

1 · ... · d2 n

d3

1 · ... · d3 n

d4

1 · ... · d4 n

d5

1 · ... · d5 n

d6

1 · ... · d6 n

d7

1 · ... · d7 n

d8

1 · ... · d8 n

9/32

slide-26
SLIDE 26

Instruction

The set of data D contains codes of the following instructions: Instruction Meaning move r, d Write the data d at the end of D[r] input r Write the top of the input at the end of D[r] pop r Pop the data on the top of D[r] jump a Go to the instruction at address a case r Conditional jump depending on D[r] exec r Control transfer to register RP = r and IP = 0 activate r Activate D[r] inactivate r Inactivate X[r]

10/32

slide-27
SLIDE 27

Instruction activate

X D r r4 r5 r6 r1 r2 r3 u1 u2 u3 u u4 u5 u6

RP = r3 RP IP = activate r

11/32

slide-28
SLIDE 28

Instruction activate

X D r r4 r5 r6 r1 r2 r3 u1 u2 u3 u u4 u5 u6

RP = r3 RP IP = activate r

11/32

slide-29
SLIDE 29

Instruction inactivate

X D r r4 r5 r6 r1 r2 r3 u1 u2 u3 u u4 u5 u6

RP = r3 RP IP = inactivate r

12/32

slide-30
SLIDE 30

Instruction inactivate

X D r r4 r5 r6 r1 r2 r3 u1 u2 u3 u u4 u5 u6

RP = r3 RP IP = inactivate r

12/32

slide-31
SLIDE 31

Instruction exec

X D r4 r5 r6 r1 r2 r3 u1 u2 u3 u4 u5 u6 r7 r8 u7 u8

RP = r3 RP IP = exec r

13/32

slide-32
SLIDE 32

Instruction exec

X D r4 r5 r6 r1 r2 r3 u1 u2 u3 u4 u5 u6 r7 r8 u7 u8

RP = r3 RP IP = exec r

13/32

slide-33
SLIDE 33

Example: decrypting code

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 jump 1

14/32

slide-34
SLIDE 34

Example: decrypting code

1 move 10 2 2 jz 10 6 3 move(10 − 10) (10 − 10) − 42 4 move 10 (10 − 1) 5 jump 2 6 jump 8 7 stop 8 (E(print hello world) + 42) 9 (E(jump 7) + 42) 10 jump 1

14/32

slide-35
SLIDE 35

Cinematic

a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 a14 stop a15 (E(print hello world) + 42) a16 (E(exec r2) + 42) a17 exec r1 D X r3 r4 r1 r2 15/32

slide-36
SLIDE 36

Cinematic

a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 a14 stop a15 (E(print hello world) + 42) a16 (E(exec r2) + 42) a17 exec r1 D X r3 r4 r1 r2 15/32

slide-37
SLIDE 37

Cinematic

a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 a14 stop a15 (E(print hello world) + 42) a16 (E(exec r2) + 42) a17 exec r1 D X r3 r4 r1 r2 15/32

slide-38
SLIDE 38

Cinematic

a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 a14 stop a15 print hello world a16 exec r2 a17 D X r3 r4 r1 r2 15/32

slide-39
SLIDE 39

Cinematic

a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 a14 stop a15 print hello world a16 exec r2 a17 D X r3 r4 r1 r2 15/32

slide-40
SLIDE 40

Cinematic

a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 a14 stop a15 print hello world a16 exec r2 a17 D X r3 r4 r1 r2 15/32

slide-41
SLIDE 41

Computation

◮ Valuation vR ∈ V with R ⊂ R:

vR = {r | r ∈ R}

◮ State s ∈ S:

(RP, IP, X, vX

  • p∈P

, vD)

◮ Transition ⊲ ∈ ℘(S2) ◮ Interpretation of p (set of traces):

p

def

= {s1 · · · sn ∈ S∗ | s1 = (p, v) ∧ ∀i ∈ 1, n − 1 si ⊲ si+1}

16/32

slide-42
SLIDE 42

Plan

Introduction Framework Applications Measure Program extraction Abstraction

17/32

slide-43
SLIDE 43

Plan

Introduction Framework Applications Measure Program extraction Abstraction

18/32

slide-44
SLIDE 44

Writing relation

Given a trace τ ∈ p

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Writing relation: τ∈ ℘(N2) i′ τ i ⇐ ⇒ step i′ writes the code of an instruction which will be run at step i

19/32

slide-45
SLIDE 45

Writing relation

Given a trace τ ∈ p

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Writing relation: τ∈ ℘(N2) i′ τ i ⇐ ⇒ step i′ writes the code of an instruction which will be run at step i

Example

Steps 2 and 11 write on address 5.

19/32

slide-46
SLIDE 46

Writing relation

Given a trace τ ∈ p

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Writing relation: τ∈ ℘(N2) i′ τ i ⇐ ⇒ step i′ writes the code of an instruction which will be run at step i

Example

Steps 2 and 11 write on address 5.

19/32

slide-47
SLIDE 47

Example

Program:

r1 a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 r2 a14 stop r3 a15 D(E(print hello world) + 42) a16 D(E(exec r2) + 42) r4 a17 exec r1 20/32

slide-48
SLIDE 48

Example

Program:

r1 a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 r2 a14 stop r3 a15 D(E(print hello world) + 42) a16 D(E(exec r2) + 42) r4 a17 exec r1

Trace:

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

20/32

slide-49
SLIDE 49

Example

Program:

r1 a1 inactivate r4 a2 move r4 2 a3 pop r4 a4 case r4 a5 jump a7 a6 jump a11 a7 move r3 r3 | 10 − r4 | 10 − 42 a8 pop r3 a9 move r4 r4 | 10 − 1 a10 pop r4 a11 jump a4 a12 activate r4 a13 exec r4 r2 a14 stop r3 a15 D(E(print hello world) + 42) a16 D(E(exec r2) + 42) r4 a17 exec r1

Trace:

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

20/32

slide-50
SLIDE 50

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-51
SLIDE 51

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-52
SLIDE 52

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-53
SLIDE 53

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-54
SLIDE 54

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-55
SLIDE 55

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-56
SLIDE 56

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-57
SLIDE 57

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-58
SLIDE 58

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-59
SLIDE 59

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-60
SLIDE 60

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-61
SLIDE 61

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-62
SLIDE 62

Trace interpretation

The monotone level ητ(i): “ The number of necessary self-modifications before executing step i” ητ(1)

def

= 1 ητ(i)

def

= ητ(i − 1) if nobody wrote i ητ(i)

def

= max{ητ(i − 1), ητ(i′) + 1} if i′ τ i.

1 2 3 4 5 2 3 4 5 2 6 8 9 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 ητ = 1 ητ = 2 ητ = 3

21/32

slide-63
SLIDE 63

Waves

A wave of level n: wn

def

= {i | ητ(i) = n}

22/32

slide-64
SLIDE 64

Waves

A wave of level n: wn

def

= {i | ητ(i) = n}

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

22/32

slide-65
SLIDE 65

Waves

A wave of level n: wn

def

= {i | ητ(i) = n}

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

22/32

slide-66
SLIDE 66

Waves

A wave of level n: wn

def

= {i | ητ(i) = n}

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

  • w1

w2

22/32

slide-67
SLIDE 67

Waves

A wave of level n: wn

def

= {i | ητ(i) = n}

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

  • w1

w2

w1 w2

22/32

slide-68
SLIDE 68

Sum up

◮ Measure self-modification.

→ the writing relation.

◮ Interpretation wrt self-modification

→ the trace-oriented notion of wave.

23/32

slide-69
SLIDE 69

Sum up

◮ Measure self-modification.

→ the writing relation.

◮ Interpretation wrt self-modification

→ the trace-oriented notion of wave.

Qestion

Reconstruct non self-modifying program?

23/32

slide-70
SLIDE 70

Plan

Introduction Framework Applications Measure Program extraction Abstraction

24/32

slide-71
SLIDE 71

Intuition

Qestion

How do I switch from a wave to another?

25/32

slide-72
SLIDE 72

Intuition

Qestion

How do I switch from a wave to another?

Answer

When I execute something I wrote.

25/32

slide-73
SLIDE 73

Intuition

Qestion

How do I switch from a wave to another?

Answer

When I execute something I wrote.

ASM2 answer

When I execute a register which was not activated when I began. → A good witness of a wave is thus X when the wave begins.

25/32

slide-74
SLIDE 74

Witness

Given a trace τ = s1 · · · sn, a wave w = i, j of τ, the witness of w is progτ w

def

= pmin w where ∀i, si = (pi, vDi) progτ w is a snapshot of the executable memory at the beginning of w.

26/32

slide-75
SLIDE 75

Witness

Given a trace τ = s1 · · · sn, a wave w = i, j of τ, the witness of w is progτ w

def

= pmin w where ∀i, si = (pi, vDi) progτ w is a snapshot of the executable memory at the beginning of w.

Soundness

si · · · sj ∈ progτ(w) .

Idea

All registers executed in w are already present in progτ(w):

  • therwise a register have to be activated (so writen) and we change
  • f wave when it is executed.

26/32

slide-76
SLIDE 76

Plan

Introduction Framework Applications Measure Program extraction Abstraction

27/32

slide-77
SLIDE 77

Abstract execution

Given a trace τ ∈ p

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

28/32

slide-78
SLIDE 78

Abstract execution

Given a trace τ ∈ p

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

  • w1

w2

28/32

slide-79
SLIDE 79

Abstract execution

Given a trace τ ∈ p

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

  • w1

w2

we group steps into waves: w1 · w2

28/32

slide-80
SLIDE 80

Abstract execution

Given a trace τ ∈ p

1 2 3 4 5 7 8 9 10 11 4 5 7 8 9 10 11 4 6 15 16 14

ητ = 1 ητ = 2

  • w1

w2

we group steps into waves: w1 · w2 and recover program for each wave: p1 · p2. This is the abstract execution α(τ).

28/32

slide-81
SLIDE 81

Abstract semantics

Construct a correct abstract semantics wrt α:

29/32

slide-82
SLIDE 82

Abstract semantics

Construct a correct abstract semantics wrt α: Abstract semantics of p p# : set of sequences of programs

29/32

slide-83
SLIDE 83

Abstract semantics

Construct a correct abstract semantics wrt α: Abstract semantics of p p# : set of sequences of programs ⊲# : transition function in ℘(P2)

29/32

slide-84
SLIDE 84

Abstract semantics

Construct a correct abstract semantics wrt α: Abstract semantics of p p# : set of sequences of programs ⊲# : transition function in ℘(P2) such that α(p) ⊆ p#

29/32

slide-85
SLIDE 85

Abstract semantics

Abstract transition ⊲# ∈ ℘(PP): p ⊲# p′ ⇐ ⇒ p′ is the witness of the 2nd wave of a τ ∈ p Abstract interpretation p#: p# def = {p1 · · · pn ∈ P∗ | p1 = p ∧ ∀i ∈ 1, n − 1 , pi ⊲# pi+1}

30/32

slide-86
SLIDE 86

Example: p#

Valuations v1, v2, v3, v4 ∈ V

p p1 p2 p3 p4 p5 p6 p7

v1 v2 v3 v4 v1, v2 v3, v4 v1, v3, v4 v2 ⋆

31/32

slide-87
SLIDE 87

Example: p#

Valuations v1, v2, v3, v4 ∈ V

p p1 p2 p3 p4 p5 p6 p7

v1 v2 v3 v4 v1, v2 v3, v4 v1, v3, v4 v2 ⋆

31/32

slide-88
SLIDE 88

Example: p#

Valuations v1, v2, v3, v4 ∈ V

p p1 p2 p3 p4 p5 p6 p7

v1 v2 v3 v4 v1, v2 v3, v4 v1, v3, v4 v2 ⋆

31/32

slide-89
SLIDE 89

Example: p#

Valuations v1, v2, v3, v4 ∈ V

p p1 p2 p3 p4 p5 p6 p7

v1 v2 v3 v4 v1, v2 v3, v4 v1, v3, v4 v2 ⋆

α(p) ⊆ p#

31/32

slide-90
SLIDE 90

Conclusion

We have...

◮ built abstract machine for self-modification, ◮ extracted non self-modifying programs for each waves, ◮ constructed abstract views from self-modifying programs.

32/32

slide-91
SLIDE 91

Conclusion

We have...

◮ built abstract machine for self-modification, ◮ extracted non self-modifying programs for each waves, ◮ constructed abstract views from self-modifying programs.

We will...

◮ define non monotone waves, ◮ improve symmetry of the definition (read/write), ◮ take advantage of intermediate granularity.

32/32

slide-92
SLIDE 92

Bibliography

  • M. D. Preda, R. Giacobazzi, and S. Debray.

Modeling metamorphism by abstract interpretation. Theoretical Computer Science, 2012.

  • D. Reynaud.

Analyse de codes auto-modifiants pour la sécurité informatique. PhD thesis, INPL, 2010.

  • C. C. Elgot and A. Robinson.

Random-access stored-program machines, an approach to programming languages. Journal of the Association for Computing Machinery, 11(4):365–399, October 1964. C.-K. Hur and D. Dreyer. A kripke logical relation between ml and assembly. Principles of programming languages, 2011.

32/32

slide-93
SLIDE 93

Annexe: non monotone waves

The set of waves: Wτ

def

= N/∼τ The wave relation ∼τ:

◮ ⋆ τ i if i is writen by nobody ◮ ⋆ ∼τ ⋆ ◮ i ∼τ j ⇐

⇒ ∃i′ ∼τ j′, i′ τ i ∧ j′ τ j

Properties

∼τ is an equivalence relation.

32/32

slide-94
SLIDE 94

Annexe: abstract interpretation

⊲# p

def

= {p′|∃ τ = s1 · · · sn+1 ∈ p , p′ = prog(sn+1)∧∀i, j ∈ 1, n , i ∼τ j}

T # X

def

= X ∪ {p1 · · · pnpn+1 | p1 · · · pn ∈ X ∧ ⊲# pn = pn+1} p# def = Fix{p} T #

32/32