76
DexLego: Reassembleable Bytecode Extraction for Aiding Static Analysis Zhenyu Ning and Fengwei Zhang COMPASS Lab Wayne State University 1

DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

DexLego: Reassembleable Bytecode Extractionfor Aiding Static Analysis

Zhenyu Ning and Fengwei Zhang

COMPASS LabWayne State University

1

Page 2: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Outline

I Introduction

I System Overview

I Implementation

I Evaluation

I Conclusions

2

Page 3: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Outline

I Introduction

I System Overview

I Implementation

I Evaluation

I Conclusions

3

Page 4: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Introduction

Why still doing static analysis?

4

Page 5: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Packing Technique

Android Application

DEX File

ResourceFiles

5

Page 6: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Packing Technique

Android Application

DEX File

ResourceFiles

PackedAndroid Application

Packer’sDEX File

EncryptedDEX File

ResourceFiles

6

Page 7: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Packing Technique

I Previous Android Unpacking Systems: DexHunter [1],AppSpear [2]

I Assuming a clear transition between the packer’s code and theoriginal code.

I Using method-level collection to collect code.

7

Page 8: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Self-modifying Code

1 public void example() {

2 helper();

3 Log.d("Hello World!");

4 }

8

Page 9: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Self-modifying Code

1 public void example() {

2 helper();

3 Log.d("Hello World!");

4 }

1 public void example() {

2 helper();

3 Log.d("Password is 1234!")

4 }

I Android allows the applications modify its bytecode atruntime.

I These changes cannot be detected by current static analysistools.

9

Page 10: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Reflection

1 public class Main extends Activity {

2 protected void onCreate(Bundle savedInstanceState) {

3 //...

4 // 55 is the index of method "reflectiveLeak" in the method

array of class "Main"

5 Method reflectiveLeakMethod = getClass().getMethods()[55];

6 reflectiveLeakMethod.invoke(this, "sensitive data");

7 }

8

9 public void reflectiveLeak(String data) {

10 // leak data

11 SmsManager.getDefault().sendTextMessage("800-123-456", null,

data, null, null);

12 }

13 }

10

Page 11: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Dynamic Code Loading

I Additional DEX files can be downloaded from cloud atruntime.

I Malicious activities in these DEX files are ignored by currentstatic analysis tools.

11

Page 12: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Introduction

Why not using dynamic analysis?

12

Page 13: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Dynamic Analysis

Challenges of Dynamic Analysis

I Implicit Flows

I Performance Overhead vs Accuracy

13

Page 14: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Our Goal

DexLego: Instruction-level collecting and offlinereassembling

I Use dynamic approach to collect executed instruction.

I Improve the current static analysis via offline reassembling.

14

Page 15: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Outline

I Introduction

I System Overview

I Implementation

I Evaluation

I Conclusions

15

Page 16: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

System Overview

Android Application

StaticAnalysis Tools

Collected Files

ReassembledApplication

Code CoverageImprovement

Module

Executing andInstruction-level Collecting

OfflineReassembling

16

Page 17: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

System Overview

Android Application

StaticAnalysis Tools

Collected Files

ReassembledApplication

Code CoverageImprovement

Module

Executing andInstruction-level Collecting

OfflineReassembling

17

Page 18: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

System Overview

Android Application

StaticAnalysis Tools

Collected Files

ReassembledApplication

Code CoverageImprovement

Module

Executing andInstruction-level Collecting

OfflineReassembling7

18

Page 19: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

System Overview

Android Application

StaticAnalysis Tools

Collected Files

ReassembledApplication

Code CoverageImprovement

Module

Executing andInstruction-level Collecting

OfflineReassembling7

19

Page 20: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

System Overview

Android Application

StaticAnalysis Tools

Collected Files

ReassembledApplication

Code CoverageImprovement

Module

Executing andInstruction-level Collecting

OfflineReassembling7

20

Page 21: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

System Overview

Android Application

StaticAnalysis Tools

Collected Files

ReassembledApplication

Code CoverageImprovement

Module

Executing andInstruction-level Collecting

OfflineReassembling7

21

Page 22: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Outline

I Introduction

I System Overview

I Implementation

I Evaluation

I Conclusions

22

Page 23: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

Simply list the executing instructionsone-by-one?

23

Page 24: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

1 public void example() {

2 int i;

3 for (i = 0; i < 10000; ++i) {

4 Log.d("Hello World!");

5 }

6 }

24

Page 25: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

1 public void example() {

2 int i;

3 for (i = 0; i < 10000; ++i) {

4 Log.d("Hello World!");

5 }

6 }

1 public void example() {

2 Log.d("Hello World!");

3 Log.d("Hello World!");

4 Log.d("Hello World!");

5 Log.d("Hello World!");

6 Log.d("Hello World!");

7 Log.d("Hello World!");

8 Log.d("Hello World!");

9 Log.d("Hello World!");

10 ...

11 }

25

Page 26: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

I Record both the index and the content of each instruction.

I Instruction with same index and content will not berepeatedly collected.

26

Page 27: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

How about self-modifying code?

27

Page 28: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

I Collection Tree

I A independent tree for each execution of each method.

I Each node indicates a piece of changed code.

28

Page 29: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 benign();

13 helper();

14 }

15 }

29

Page 30: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 benign();

13 helper();

14 }

15 }

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 malicious();

13 helper();

14 }

15 }

30

Page 31: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 benign();

13 helper();

14 }

15 }

Root Node

31

Page 32: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

i = 0

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {12 benign();

13 helper();

14 }

15 }

Root Node

for (int i = 0; i < 2; ++i) {

}

32

Page 33: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

i = 0

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 benign();

13 helper();

14 }

15 }

Root Node

for (int i = 0; i < 2; ++i) {benign();

}

33

Page 34: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

i = 0

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 benign();

13 helper();

14 }

15 }

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

34

Page 35: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

i = 1

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {12 malicious();

13 helper();

14 }

15 }

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

35

Page 36: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

i = 1

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 malicious();

13 helper();

14 }

15 }

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

Child Node

malicious();

36

Page 37: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Instruction-level Collection

i = 1

1 // No malicious activities

2 public void benign() {}

3

4 // Leak data

5 public void malicious() {}

6

7 // Modify line 12 to

"malicious()" at runtime

8 public void helper() {}

9

10 public void execute() {

11 for (int i = 0; i < 2; ++i) {

12 malicious();

13 helper();

14 }

15 }

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

Child Node

malicious();

37

Page 38: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Bytecode Reassembling

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

Child Node

malicious();

38

Page 39: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Bytecode Reassembling

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

Child Node

malicious();

1 public void execute() {

2 for (int i = 0; i < 2; ++i) {

3 benign();

4 helper();

5 }

6 }

39

Page 40: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Bytecode Reassembling

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

Child Node

malicious();

1 public void execute() {

2 for (int i = 0; i < 2; ++i) {

3 if (RANDOM VALUE) {4 benign();

5 } else {6

7 }8 helper();

9 }

10 }

40

Page 41: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Bytecode Reassembling

Root Node

for (int i = 0; i < 2; ++i) {benign();helper();

}

Child Node

malicious();

1 public void execute() {

2 for (int i = 0; i < 2; ++i) {

3 if (RANDOM_VALUE) {

4 benign();

5 } else {

6 malicious();

7 }

8 helper();

9 }

10 }

41

Page 42: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Implementation

I Replace the reflective calls with the direct calls duringbytecode collection.

I Use force execution to improve the code coverage.

42

Page 43: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Outline

I Introduction

I System Overview

I Implementation

I Evaluation

I Conclusions

43

Page 44: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

I Testbed Specification

I LG Nexus 5X

I A dual-core 1.8 GHZ Cortex-A57 cluster and a quad-core 1.4GHZ Cortex-A53 cluster

I Android 6.0 and TWRP Recovery

44

Page 45: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

Can we correctly reconstruct thebehavior of apps?

45

Page 46: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

Table: Test Result of Different Packers.

Applications HTMLViewer Calculator Calendar Contacts

# of Instructions 217 2,507 78,598 103,602

360 [3] X X X XAlibaba [4] X X X XTencent [5] X X X XBaidu [6] X X X XBangcle [7] X X X X

46

Page 47: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

How is DexLego comparing with othertools?

47

Page 48: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

EvaluationI 134 samples from DroidBench [8].I 3 static analysis tools: FlowDroid [9], DroidSafe [10],

HornDroid [11].I 2 unpacking tools: DexHunter [1], AppSpear [2].

FlowDroid DroidSafe HornDroid

40%

60%

80%

100%

F-M

easu

re

Original DexHunter AppSpear DexLego

Figure: F-Measure of DroidBench samples.

48

Page 49: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

Can DexLego work with real-worldpacked apps?

49

Page 50: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

Table: Analysis Result of Packed Real-world Applications.

Package Name Version # of Installs Original Reassembled

com.lenovo.anyshare 3.6.68 100 million 0 4com.moji.mjweather 6.0102.02 1 million 0 5com.rongcai.show 3.4.9 100 thousand 0 3

com.wawoo.snipershootwar 2.6 10 million 0 4com.wawoo.gunshootwar 2.6 10 million 0 5com.alex.lookwifipassword 2.9.6 100 thousand 0 2

com.gome.eshopnew 4.3.5 15.63 million 0 3com.szzc.ucar.pilot 3.4.0 3.59 million 0 5com.pingan.pabank.activity 2.6.9 7.9 million 0 14

50

Page 51: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

How about code coverage?

51

Page 52: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

Table: Samples from F-Droid [12].

Package Name Version # of Instructions

be.ppareit.swiftp 2.14.2 8,812fr.gaulupeau.apps.InThePoche 2.0.0b1 29,231org.gnucash.android 2.1.7 56,565org.liberty.android.fantastischmemopro 10.9.993 57,575com.fastaccess.github 2.1.0 93,913

Table: Code Coverage with F-Droid Applications.

Class Method Line Branch Instruction

Sapienz [13] 44% 37% 32% 20% 32%Sapienz + DexLego 87% 88% 82% 78% 82%

52

Page 53: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Evaluation

Performance overhead?

53

Page 54: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

EvaluationI 7.5x, 1.4x, and 2.3x overhead on Java score, native score, and

overall score, respectively.

Java Native Overall103

104

105

Scor

e

Unmodified ART DexLego

Figure: Performance Measured by CF-Bench [14].

54

Page 55: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Outline

I Introduction

I System Overview

I Implementation

I Evaluation

I Conclusions

55

Page 56: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Conclusions

I DexLego leverages instruction-level bytecode collecting andoffline reassembling to aid existing static analysis tools.

I It helps to overcome the weakness of static analysis andincreases the analysis accuracy with reasonable performanceoverhead.

56

Page 57: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

References I[1] Y. Zhang, X. Luo, and H. Yin, “DexHunter: Toward extracting hidden code from packed Android

applications,” in Proceedings of the 20th European Symposium on Research in Computer Security(ESORICS’15)., 2015.

[2] W. Yang, Y. Zhang, J. Li, J. Shu, B. Li, W. Hu, and D. Gu, “AppSpear: Bytecode decrypting and DEXreassembling for packed Android malware,” in Proceedings of the 18th International Symposium on Researchin Attacks, Intrusions and Defenses (RAID’15), 2015.

[3] Qihoo 360 Inc., “360Protector,” http://jiagu.360.cn/protection, 2014.

[4] Alibaba Inc., “AliProtector,” http://jaq.alibaba.com/, 2014.

[5] Tencent Inc., “TencentProtector,” http://legu.qcloud.com/, 2014.

[6] Baidu Inc., “BaiduProtector,” http://app.baidu.com/jiagu/, 2014.

[7] Bangcle Ltd., “BangcleProtector,” https://www.bangcle.com/, 2013.

[8] EC SPRIDE Secure Software Engineering Group, “DroidBench,”https://github.com/secure-software-engineering/DroidBench, 2013.

[9] S. Arzt, S. Rasthofer, C. Fritz, E. Bodden, A. Bartel, J. Klein, Y. Le Traon, D. Octeau, and P. McDaniel,“FlowDroid: Precise context, flow, field, object-sensitive and lifecycle-aware taint analysis for Android apps,”in Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design andImplementation (PLDI’14), 2014.

[10] M. I. Gordon, D. Kim, J. H. Perkins, L. Gilham, N. Nguyen, and M. C. Rinard, “Information flow analysis ofAndroid applications in DroidSafe,” in Proceedings of the 22nd Network and Distributed System SecuritySymposium (NDSS’15), 2015.

[11] S. Calzavara, I. Grishchenko, and M. Maffei, “HornDroid: Practical and sound static analysis of Androidapplications by SMT solving,” in Proceedings of the 1st IEEE European Symposium on Security and Privacy(EuroS&P’16), 2016.

57

Page 58: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

References II[12] F-Droid, “F-Droid,” https://f-droid.org/, 2011.

[13] K. Mao, M. Harman, and Y. Jia, “Sapienz: Multi-objective automated testing for Android applications,” inProceedings of the 25th ACM SIGSOFT International Symposium on Software Testing and Analysis(ISSTA’16), 2016.

[14] Chainfire, “CF-Bench,” https://play.google.com/store/apps/details?id=eu.chainfire.cfbench, 2013.

58

Page 59: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Thank you!

[email protected]

http://compass.cs.wayne.edu

59

Page 60: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0dex pc

60

Page 61: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2dex pc

61

Page 62: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?dex pc

62

Page 63: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

dex pc

63

Page 64: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

dex pc

64

Page 65: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

dex pc

65

Page 66: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4

dex pc

66

Page 67: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4

dex pc

67

Page 68: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

malicious()

dex pc

68

Page 69: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4

dex pc

69

Page 70: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4dex pc

70

Page 71: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4

dex pc

71

Page 72: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4

dex pc

72

Page 73: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

benign()

helper()

v1 = v1 + 1

goto −4

return

dex pc

???

73

Page 74: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

3

goto ?

goto ?

dex pc

74

Page 75: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

benign()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

3

goto 2

goto ?

benign()

dex pc

75

Page 76: DexLego: Reassembleable Bytecode Extraction for Aiding ...Dynamic Analysis Challenges of Dynamic Analysis I Implicit Flows I Performance ... M. I. Gordon, D. Kim, J. H. Perkins, L

Branch Instruction

v1 = 0

v2 = 2

v1 >= v2?

6

malicious()

helper()

v1 = v1 + 1

goto −5

return

v1 = 0

v2 = 2

v1 >= v2?

3

goto 2

goto 5

benign()

helper()

v1 = v1 + 1

goto −7

return

dex pc

76