protecting source code

25
Godfrey Nolan

Upload: godfreynolan

Post on 08-May-2015

5.187 views

Category:

Technology


0 download

DESCRIPTION

Godfrey Nolan's class on Protecting Android Source code at AnDevCon 2012

TRANSCRIPT

Page 1: Protecting Source Code

Godfrey Nolan

Page 2: Protecting Source Code

Hear no evil, see no evil Decompiling APK demo Raising the bar

Page 3: Protecting Source Code

Easy access to APKs APK design Nobody using obfuscation

Page 4: Protecting Source Code
Page 5: Protecting Source Code
Page 6: Protecting Source Code

According to DuoSecurity Over 50% of Android phones are rootable

See Xray.io for more information Vulnerabilities

ASHMEM

Exploid

Gingerbreak

Levitator

Memoproid

etc.

Page 7: Protecting Source Code

Logins

API keys

Credit card information Fake apps

Page 8: Protecting Source Code

sdcard Rooting phone Download from forums

Page 9: Protecting Source Code
Page 10: Protecting Source Code

Obfuscation Android NDK SQLCipher for SQLite Google Closure for JavaScript in HTML5/CSS Don’t use keys - login each time Break tools

Dex2Jar and Baksmali

Google Encryption in Jelly Bean (RIP) Hide key info elsewhere (see resources)

Page 11: Protecting Source Code
Page 12: Protecting Source Code

Obfuscation Theory

Layout

Control

Data

Page 13: Protecting Source Code

Obfuscation Type Classification Transformation

Layout Scramble identifiers.

Control Computations Insert dead or irrelevant code.

Extend a loop condition.

Reducible to non-reducible.

Add redundant operands.

Remove programming idioms.

Parallelize code.

Aggregations Inline and outline methods.

Interleave methods.

Clone methods.

Loop transformations.

Ordering Reorder statements.

Reorder loops.

Reorder expressions.

Data Storage and encoding Change encoding.

Split variables.

Convert static data to procedural data.

Aggregation Merge scalar variables.

Factor a class.

Insert a bogus class.

Refactor a class.

Split an array.

Merge arrays.

Fold an array.

Flatten an array.

Ordering Reorder methods and instance variables.

Reorder arrays.

Page 14: Protecting Source Code

Obfuscators

ProGuard and DexGuard

DashO

Page 15: Protecting Source Code
Page 16: Protecting Source Code

Application size Performance Remove logging, debugging, testing code Protection

Page 17: Protecting Source Code

At the bytecode level

Dead code elimination

Constant propagation

Method Inlining

Class Merging

Remove logging code

Peephole optimizations

Devirtualization

Page 18: Protecting Source Code

Nothing is unbreakable, you can raise the bar:

Reflection

String encryption

Class encryption

Tamper detection

Debug detection

Emulator detection

Page 19: Protecting Source Code
Page 20: Protecting Source Code
Page 21: Protecting Source Code

Bug fixing Unit testing Obfuscation = defactoring

Page 22: Protecting Source Code

WordPress

ProGuard & DexGuard

DashO

HoseDex2Jar

NDK

Page 23: Protecting Source Code

DexToXML DexToSource Giveaway

What does Dex stand for?

Page 24: Protecting Source Code

http://www.strazzere.com/papers/DexEducation-PracticingSafeDex.pdf https://www.pcisecuritystandards.org/security_standards/documents.php?document=mobile_payment_security_guidelines1 http://xray.io http://www.netmite.com/android/mydroid/dalvik/docs/dalvik-bytecode.html http://source.android.com/tech/dalvik/dex-format.html http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html http://www.saikoa.com/dexguard http://www.preemptive.com/products/dasho/overview http://android.wordpress.org/development/ http://selinuxproject.org/page/SEAndroid

Page 25: Protecting Source Code

http://www.decompilingandroid.com @decompiling [email protected] http://www.riis.com