Top Banner
04.10.2015 | Secure Software Engineering Group | Steven Arzt | 1 All Your Code Belongs To Us Dismantling Android Secrets With CodeInspect Steven Arzt
50

Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

Jun 05, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 1

All Your Code Belongs To Us Dismantling Android Secrets With CodeInspect

Steven Arzt

Page 2: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 2

Page 3: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 3

All Your Code Belongs To Us Dismantling Android Secrets With CodeInspect

Page 4: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4

#whoami

• 3rd year PhD student at TU Darmstadt

• Researcher in the Secure Software Engineering Group • Group lead: Eric Bodden

• Main interests: • Static code analysis

• Smartphone security

• Maintainer of Soot and FlowDroid

• sseblog.ec-spride.de

Page 5: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 5

Page 6: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 6

Android Distribution Process

Developer User

• Source code • Create, modify • Debug, inspect, understand

• Binary code • Run the app

Page 7: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 7

HOW EASY IS IT TO DISMANTLE YOUR APP?

Is this really true?

Page 8: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 8

Android App Piracy

How to secure my app against piracy I am developing an android app and I am planning to publish it (paid app). I have heard that it is very easy to pirate Android apps (much easier than iphone). I was wondering from your experience or what you know, how can increase the security of my app? I know that I can never get it 100% secured but I want to make it harder for people to pirate it or distribute it illegaly Any ideas, experiences, comments you can share? That will be greatly appreciated Source: stackoverflow.com

Page 9: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 9

Android App Piracy

Android Still Has A Massive Piracy Problem Ustwo Games, the developer behind the wildly popular mobile game “Monument Valley,” revealed in a series of tweets that only 5% of all Android installs of its game were paid for. In 2012, Gamasutra reported that piracy for a game called Shadowgun reached 90% on Android; a year later, developer Butterscotch Shenanigans reported that 95% of the 34,091 Android installs of its first game were “unofficial.” Source: uk.businessinsider.com

Page 10: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 10

Android App Piracy

Piracy On Android: How Bad Is It Really? In other words, Android users want things for free and are clever enough to know how to get those things for free. While there are a few steps that can be taken to make the cracking process less convenient, a determined pirate will be able to break through any kind of app protection if given enough time. Source: makeuseof.com

Page 11: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 11

CodeInspect

A new Binary Analysis Framework for Android and Java Bytecode

Page 12: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 12

Android Distribution Process

Developer User

• Source code • Create, modify • Debug, inspect, understand

• Binary code • Create, modify • Debug, inspect, understand

Page 13: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 13

Why?

vs.

Page 14: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 14

Android Distribution Process

Fraudster Investigator

Page 15: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 15

CodeInspect

A new Binary Analysis Framework for Android and Java Bytecode

Debug. Understand. Manipulate. without the source code

Page 16: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 16

CodeInspect

Page 17: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 17

CodeInspect

Packages and Classes

Manifest File

Assets

Jimple Code

Page 18: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 18

Jimple Code

Code Outline

Page 19: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 19

Jimple Code Code Outline

Syntax Errors Logcat Output Search Results

Looks and feels just like Eclipse!

Page 20: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 20

Jimple Code

Stack Trace Variables

Code Outline

Logcat Console

Page 21: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 21

CodeInspect

• Based on Eclipse RCP

• Work as you would on source code in Eclipse • Navigate through the code

• Add, change, and remove code

• Inject arbitrary Java code

• Start and debug your app

• Inspect and change runtime values

Page 22: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 22

ARCHITECTURE How does it work?

Page 23: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 23

CodeInspect Architecture

Page 24: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 24

CodeInspect Architecture

.dex .java .jimple .class .apk

Input / Output

• Callgraphs • Control flow graphs • Algorithms for compiler construction

• Code manipulation • Code synthesis

Page 25: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 25

The Jimple IR

• Between Dalvik / Java bytecode and Java source code

• Jimple: Java, but simple

• Originally optimized for static analyses

Jimple

Page 26: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 26

public void foo() { byte[] $arrbyte; java.io.FileOutputStream $FileOutputStream; … specialinvoke this.<android.app.Service: void onCreate()>(); $File = new java.io.File; specialinvoke $File.<java.io.File: void <init>(java.lang.String)>("/sdcard/test.apk"); specialinvoke $FileOutputStream.<java.io.FileOutputStream: void <init>(java.io.File)>($File); $arrbyte = newarray (byte)[1024]; $int = virtualinvoke $InputStream.<java.io.InputStream: int read(byte[])>($arrbyte); …

The Jimple IR

Method Declaration

Variable Declarations

Implementation

Page 27: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 27

Page 28: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 28

Page 29: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 29

Page 30: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 30

CASE STUDIES CodeInspect in Action

Page 31: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 31

CodeInspect

• Malware analysis • Debug malware

• Find backend credentials

• Remove anti-analysis checks

> 20.000 infected phones

Page 32: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 32

The BadAccents Malware

Page 33: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 33

LIVE DEMO CodeInspect in Action

Page 34: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 34

CodeInspect

• Software development • Inspect libraries

• Look for security vulnerabilities

• Understand exceptions and problems

• See what happens under the hood

Page 35: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 35

CodeInspect

• Don’t be evil • Remove license checks

• Reverse-engineer competitor apps

• Steal intellectual property

• Copyright laws apply!

Page 36: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 36

CONSEQUENCES FOR DEVELOPERS

What does this all mean?

Page 37: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 37

Consequences for Developers

• All apps are “open-source”

• Never hide secrets inside the app code • Backend credentials

• Encryption keys

• Piggybacking malware is simple

• Cracking apps is simple

Page 38: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 38

Consequences for Developers

• Backend-as-a-Service study

• Will be presented at Blackhat Europe in Amsterdam

18,670,00 records

56,000,000 data items

• E-Mail addresses • Health records • Employee databases • Customer databases • Server backups • Voice records

Page 39: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 39

Countermeasures

• String encryption • Use the debugger, get de-obfuscated result

• Code encryption • Use debugger to get the code as it is about to be loaded

• Hide calls in reflection • Use debugger to step into right target method

• Debugger detection • Patch the code to remove the check

Page 40: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 40

THE PLUG-IN SYSTEM Extending CodeInspect

Page 41: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 41

Data Flow Analysis Plugin

• Which data is read?

• What happens with the data?

• Where is the data sent to?

Page 42: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 42

Data Flow Analysis Plugin

Source

Sink

Page 43: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 43

Data Flow Analysis Plugin

Jimple Code

Data Flows

Propagation Path

Page 44: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 44

Data Flow Analysis Plugin

Data Flows

Page 45: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 45

Data Flow Analysis Plugin

Propagation Path

Page 46: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 46

Data Flow Analysis Plugin

Jimple Code

Page 47: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 47

Other Planned Plugins

• Runtime value reconstruction

• Interactive callgraph and control flow visualization

• Malware analysis assistance

• (Semi-)Automatic deobfuscation

• Plugins directly from research

Page 48: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 48

Obtaining CodeInspect

• Will be a commercial product

• Free 60 day demo license available • All features available

• No restrictions on target APKs

• E-Mail me

Page 49: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 49

Steven Arzt Secure Software Engineering Group (EC-SPRIDE) Email: [email protected] Blog: http://sse-blog.ec-spride.de Website: http://sse.ec-spride.de

www.codeinspect.de

Page 50: Dismantling Android Secrets With CodeInspect · Dismantling Android Secrets With CodeInspect. 04.10.2015 | Secure Software Engineering Group | Steven Arzt | 4 ... for Android and

04.10.2015 | Secure Software Engineering Group | Steven Arzt | 50