A Novel Obfusca/on: Class Hierarchy Fla9ening Christophe - - PowerPoint PPT Presentation
A Novel Obfusca/on: Class Hierarchy Fla9ening Christophe - - PowerPoint PPT Presentation
A Novel Obfusca/on: Class Hierarchy Fla9ening Christophe Foket, Bjorn De Su9er, Bart Coppens & Koen De Bosschere Computer Systems Lab Ghent
Outline ¡
- Bytecode ¡obfusca/on ¡
- Class ¡hierarchy ¡fla9ening ¡
- Evalua/on ¡
- Conclusions ¡
2 ¡
Binary ¡soQware ¡
Bytecode ¡is ¡vulnerable ¡
3 ¡
Binary ¡soQware ¡ Bytecode ¡soQware ¡
Bytecode ¡is ¡vulnerable ¡
4 ¡
Bytecode ¡obfusca/on ¡
5 ¡
an/-‑reverse ¡ engineering ¡ Goal ¡ an/-‑code ¡liQing ¡ an/-‑code ¡injec/on ¡ Goal ¡
Bytecode ¡soQware ¡
Bytecode ¡obfusca/on ¡
6 ¡
an/-‑reverse ¡ engineering ¡ Goal ¡ an/-‑code ¡liQing ¡ an/-‑code ¡injec/on ¡ Goal ¡
Bytecode ¡soQware ¡
remove ¡inheritance ¡ rela/ons ¡between ¡classes ¡
Class ¡hierarchy ¡fla9ening ¡
Example ¡
7 ¡
class ¡Main ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡ShapeWindow ¡w ¡= ¡new ¡ShapeWindow(…); ¡ ¡ ¡ ¡ ¡Circle ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡Rectangle ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:add>(c); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:add>(r); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:paint>(); ¡ ¡ ¡ ¡ ¡c.<Circle:draw>(); ¡ ¡ ¡ ¡ ¡r.<Rectangle:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Example ¡
8 ¡
class ¡Main ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common ¡w ¡= ¡new ¡ShapeWindow(…); ¡ ¡ ¡ ¡ ¡Common ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡Common ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡ ¡ ¡w.<Common:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡1: ¡subtree ¡selec/on ¡
9 ¡
class ¡Main ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡ShapeWindow ¡w ¡= ¡new ¡ShapeWindow(…); ¡ ¡ ¡ ¡ ¡Circle ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡Rectangle ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:add>(c); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:add>(r); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:paint>(); ¡ ¡ ¡ ¡ ¡c.<Circle:draw>(); ¡ ¡ ¡ ¡ ¡r.<Rectangle:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡2: ¡interface ¡inser/on ¡
10 ¡
- one ¡interface ¡per ¡subtree ¡
- acts ¡as ¡a ¡common ¡super ¡type ¡
- declares ¡all ¡instance ¡methods ¡ ¡
declared ¡in ¡all ¡classes ¡of ¡the ¡ ¡ subtree ¡ ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡3: ¡subtree ¡type ¡abstrac/on ¡
11 ¡
class ¡Main ¡implements ¡Common3 ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡ShapeWindow ¡w ¡= ¡new ¡ShapeWindow(…); ¡ ¡ ¡ ¡ ¡Circle ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡Rectangle ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:add>(c); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:add>(r); ¡ ¡ ¡ ¡ ¡w.<ShapeWindow:paint>(); ¡ ¡ ¡ ¡ ¡c.<Circle:draw>(); ¡ ¡ ¡ ¡ ¡r.<Rectangle:draw>(); ¡ ¡ ¡} ¡ } ¡
class ¡Main ¡implements ¡Common3 ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common2 ¡w ¡= ¡new ¡ShapeWindow(…); ¡ ¡ ¡ ¡ ¡Common1 ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡Common1 ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common2:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common1:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common1:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡3: ¡subtree ¡type ¡abstrac/on ¡
12 ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡4: ¡subtree ¡fla9ening ¡
13 ¡
- recursively ¡traverse ¡each ¡subtree ¡
- copy ¡to ¡each ¡direct ¡subclass ¡
– instance ¡fields ¡ – instance ¡methods ¡ – implemented ¡interfaces ¡
- update ¡super ¡calls ¡
- update ¡field ¡accesses ¡
- move ¡up ¡subclass ¡
in ¡the ¡hierarchy ¡
- add ¡dummy ¡ ¡
methods ¡ ¡
class ¡Main ¡implements ¡Common3 ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common2 ¡w ¡= ¡new ¡ShapeWindow(…); ¡ ¡ ¡ ¡ ¡Common1 ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡Common1 ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common2:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common1:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common1:draw>(); ¡ ¡ ¡} ¡ } ¡ class ¡Main ¡implements ¡Common3 ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common2 ¡w ¡= ¡new ¡ShapeWindow(…); ¡// ¡w ¡can ¡hold ¡objects ¡of ¡2 ¡types ¡ ¡ ¡ ¡ ¡Common1 ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡ ¡// ¡c ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡Common1 ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡// ¡r ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡w.<Common2:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common2:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common1:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common1:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡5: ¡interface ¡merging ¡
14 ¡
class ¡Main ¡implements ¡Common ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common ¡w ¡= ¡new ¡ShapeWindow(…); ¡// ¡w ¡can ¡hold ¡objects ¡of ¡6 ¡types ¡ ¡ ¡ ¡ ¡Common ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡ ¡// ¡c ¡can ¡hold ¡objects ¡of ¡6 ¡types ¡ ¡ ¡ ¡ ¡Common ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡// ¡r ¡can ¡hold ¡objects ¡of ¡6 ¡types ¡ ¡ ¡ ¡ ¡w.<Common:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡5: ¡interface ¡merging ¡
15 ¡
16 ¡dummy ¡methods ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡5: ¡interface ¡merging ¡
16 ¡
class ¡Main ¡implements ¡Common3 ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common2 ¡w ¡= ¡new ¡ShapeWindow(…); ¡// ¡w ¡can ¡hold ¡objects ¡of ¡2 ¡types ¡ ¡ ¡ ¡ ¡Common1 ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡ ¡// ¡c ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡Common1 ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡// ¡r ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡w.<Common2:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common2:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common1:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common1:draw>(); ¡ ¡ ¡} ¡ } ¡
class ¡Main ¡implements ¡Common2 ¡{ ¡ ¡ ¡void ¡main(){ ¡ ¡ ¡ ¡ ¡Common2 ¡w ¡= ¡new ¡ShapeWindow(…); ¡// ¡w ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡Common1 ¡c ¡= ¡new ¡Circle(…); ¡ ¡ ¡ ¡ ¡ ¡// ¡c ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡Common1 ¡r ¡= ¡new ¡Rectangle(…); ¡ ¡ ¡// ¡r ¡can ¡hold ¡objects ¡of ¡3 ¡types ¡ ¡ ¡ ¡ ¡w.<Common2:add>(c); ¡ ¡ ¡ ¡ ¡w.<Common2:add>(r); ¡ ¡ ¡ ¡ ¡w.<Common2:paint>(); ¡ ¡ ¡ ¡ ¡c.<Common1:draw>(); ¡ ¡ ¡ ¡ ¡r.<Common1:draw>(); ¡ ¡ ¡} ¡ } ¡
Class ¡hierarchy ¡fla9ening ¡
Step ¡5: ¡interface ¡merging ¡
17 ¡
5 ¡dummy ¡methods ¡
Outline ¡
- Bytecode ¡obfusca/on ¡
- Class ¡hierarchy ¡fla9ening ¡
- Evalua/on ¡
- Conclusions ¡
18 ¡
Evalua/on ¡
19 ¡
DaCapo ¡benchmark ¡suite ¡
Name ¡ Descrip/on ¡ # ¡appl ¡types ¡ # ¡transf ¡classes ¡ # ¡jar ¡files ¡ ba/k ¡ Scalable ¡Vector ¡Graphics ¡processor ¡ 4573 ¡ 3505 ¡(77%) ¡ 6 ¡ eclipse ¡ Non-‑GUI ¡version ¡of ¡Eclipse ¡IDE ¡ 5947 ¡ 2258 ¡(38%) ¡ 48 ¡ fop ¡ XLS-‑FI ¡to ¡PDF ¡conversion ¡ 4479 ¡ 3349 ¡(75%) ¡ 7 ¡ luindex ¡ Document ¡indexing ¡based ¡on ¡Lucene ¡ 633 ¡ 526 ¡(83%) ¡ 3 ¡
Evalua/on ¡
20 ¡
DaCapo ¡benchmark ¡suite ¡
- bfuscator ¡on ¡top ¡of ¡Soot ¡
Evalua/on ¡
21 ¡
DaCapo ¡benchmark ¡suite ¡
- bfuscator ¡on ¡top ¡of ¡Soot ¡
Evalua/on ¡
22 ¡
[BD02] ¡ ¡Bansiya, ¡J. ¡and ¡Davis, ¡C. ¡G., ¡A ¡Hierarchical ¡Model ¡for ¡Object-‑Oriented ¡Design ¡Quality ¡Assessment, ¡In ¡ IEEE ¡Transac/ons ¡on ¡SoQware ¡Engineering, ¡volume ¡28, ¡2002. ¡
Quality ¡Model ¡for ¡Object-‑Oriented ¡Design ¡[BD02]: ¡understandability ¡metric ¡ understandability ¡
Protec/on ¡against ¡human ¡program ¡understanding ¡
Evalua/on ¡
23 ¡
distribu/on ¡of ¡points-‑to ¡set ¡sizes ¡for ¡ba/k ¡
Protec/on ¡against ¡sta/c ¡analysis ¡tools ¡
Evalua/on ¡
24 ¡
Code ¡size ¡
Evalua/on ¡
25 ¡
Execu/on ¡/me ¡
Outline ¡
- Bytecode ¡obfusca/on ¡
- Class ¡hierarchy ¡fla9ening ¡
- Evalua/on ¡
- Conclusions ¡
26 ¡
Conclusions ¡
27 ¡
- class ¡hierarchy ¡fla9ening ¡
- measurable ¡protec/on ¡
- rela/vely ¡low ¡run-‑/me ¡overhead ¡
- real-‑life ¡applica/ons ¡
- extensions ¡possible ¡
Ques/ons? ¡
Evalua/on ¡
29 ¡
Protec/on ¡against ¡human ¡program ¡understanding ¡
[BD02] ¡ ¡Bansiya, ¡J. ¡and ¡Davis, ¡C. ¡G., ¡A ¡Hierarchical ¡Model ¡for ¡Object-‑Oriented ¡Design ¡Quality ¡Assessment, ¡In ¡ IEEE ¡Transac/ons ¡on ¡SoQware ¡Engineering, ¡volume ¡28, ¡2002. ¡
Quality ¡Model ¡for ¡Object-‑Oriented ¡Design ¡[BD02]: ¡understandability ¡metric ¡ understandability ¡breakdown ¡for ¡ba/k ¡