SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Downloaden Sie, um offline zu lesen
ProGuard
Optimizer and Obfuscator for Android
             Eric Lafortune
                 Saikoa
Eric Lafortune
●
    1991 – 1996   K.U.Leuven (Belgium), Phd Eng CompSci
●
    1996 – 1999   Cornell University (Ithaca, NY)
●
    1999 – 2011   Java GIS
●
    2012          Founder Saikoa
Maybe more importantly:
●
    1982 TMS-9900 processor
●
    1995 ARM2/ARM3 processor
●
    2001 Java bytecode
●
    2010 Dalvik bytecode
ProGuard
Open source

        Generic

                Shrinker
               Optimizer
               Obfuscator

                  For Java bytecode
ProGuard history
                   Java applications

       Applets                                Android apps
                            Midlets


    2002                               2010         2012


●
    May 2002     First download!
●
    Sep 2010     Recommended for protecting LVL
●
    Dec 2010     Part of Android SDK
●
    Jan 2012     Startup Saikoa
Why use ProGuard?
●
    Application size
●
    Performance
●
    Remove logging, debugging, testing code
●
    Battery life
●
    Protection
Application size

                       classes.dex size                              .apk size

             Without   With              Without   With
                              Reduction                   Reduction
            ProGuard ProGuard           ProGuard ProGuard

ApiDemos       716 K         482 K          33%          2.6 M         2.5 M           4%

ApiDemos
               ~6 M          542 K         ~90%          ~8 M          2.5 M         ~70%
in Scala*




  * [Stéphane Micheloud, http://lampwww.epfl.ch/~michelou/android/library-code-shrinking.html]
Performance: CaffeineMark
Without ProGuard                      With ProGuard
Sieve score      = 6833               Sieve score        = 6666
Loop score       = 14831              Loop score         = 15473
Logic score      = 19038              Logic score        = 47840
String score     = 7694               String score       = 7717
Float score      = 6425               Float score        = 6488
Method score = 4850                   Method score = 5229
Overall score = 8794                  Overall score = 10436
                                          Improvement: 18%
    [Acer Iconia Tab A500, nVidia Tegra 2, 1.0 GHz, Android 3.2.1]
Battery life
Extreme example:
                  “5 x better battery life,
            by removing verbose logging code
                 in a background service”
(but don't count on it)
Tip        How to enable ProGuard?
project.properties:


       # To enable ProGuard to shrink and obfuscate
           your code, uncomment this
       #proguard.config=
           ${sdk.dir}/tools/proguard/proguard-android.txt:
           proguard-project.txt




→ only applied when building release versions
Build process




                                          ProGuard
                                           ProGuard
[Android documentation]
Shrinking
Also called treeshaking, minimizing, shrouding
Shrinking
●
    Classes, fields, methods
Entry points
1) Activities, applications, services, fragments,...
→ provided automatically by Android build process


    -keep public class * extends android.app.Activity
    -keep public class * extends android.app.Application
    -keep public class * extends android.app.Service
    …
Tip                    Entry points
2) Introspection, e.g. Google License Verification Library
→ must be specified in proguard-project.txt


       -keep public interface
           com.android.vending.licensing.ILicensingService
Entry points
More introspection, e.g. Google vending library
→ must be specified in proguard-project.txt

   -keepclassmembers public class
      com.google.android.vending.expansion.downloader.impl.DownloadsDB$* {
       public static final java.lang.String[][] SCHEMA;
       public static final java.lang.String     TABLE_NAME;
   }
Entry points
More introspection, e.g. Guice, RoboGuice
→ must be specified in proguard-project.txt:

   -keepclassmembers class * {
       @javax.inject.**            <fields>;
       @com.google.inject.**       <fields>;
       @roboguice.**               <fields>;
       @roboguice.event.Observes   <methods>;
   }
Tip                Notes and warnings
“Closed-world assumption”
       Warning:    twitter4j.internal.logging.Log4JLoggerFactory:
           can't   find referenced class org.apache.log4j.Logger
       Warning:    twitter4j.internal.logging.SLF4JLoggerFactory:
           can't   find referenced class org.slf4j.LoggerFactory
       ...


       Warning: com.dropbox.client2.DropboxAPI:
         can't find referenced class org.json.simple.JSONArray


→ if debug build works fine,
   then ok to ignore in proguard-project.txt:
       ­dontwarn twitter4j.internal.logging.**
       ­dontwarn com.dropbox.client2.**
Optimization
At the bytecode instruction level:
●
    Dead code elimination
●
    Constant propagation
●
    Method inlining
●
    Class merging
●
    Remove logging code
●
    Peephole optimizations
●
    Devirtualization
●
    ...
Dead code elimination


   boolean debug = false;
   …

   if (debug) Log.v(“.....”);
   …




Note: showing equivalent source code instead of bytecode
Dead code elimination



   boolean debug = false;
   …

   if (debug) Log.v(“.....”);
   …




Note: showing equivalent source code instead of bytecode
Constant propagation
Inside methods:

   int f1 = 6;
   …
   int f2 = 7;
   …
   int answer = f1 * f2;
Constant propagation
Inside methods:

   int f1 = 6;
   …
   int f2 = 7;
   …
   int answer = f1 * f2;



               …
               int answer = 6 * 7;
Constant propagation
Inside methods:

   int f1 = 6;
   …
   int f2 = 7;
   …
   int answer = f1 * f2;



               …
               int answer = 6 * 7;



                           …
                           int answer = 42;
Constant propagation
Across methods:
   int answer = computeAnswer(6, 7);


  int computeAnswer(int f1, int f2) {
      return f1 * f2;
  }
Constant propagation
Across methods:
   int answer = computeAnswer(6, 7);


  int computeAnswer(int f1, int f2) {
      return f1 * f2;
  }


            int computeAnswer(int f1, int f2) {
                return 6 * 7;
            }
Constant propagation
Across methods:
   int answer = computeAnswer(6, 7);


  int computeAnswer(int f1, int f2) {
      return f1 * f2;
  }


            int computeAnswer(int f1, int f2) {
                return 6 * 7;
            }


                      int computeAnswer() {
                          return 42;
                      }
Constant propagation
Across methods:
   int answer = computeAnswer(6, 7);          int answer = 42;


  int computeAnswer(int f1, int f2) {
      return f1 * f2;
  }


            int computeAnswer(int f1, int f2) {
                return 6 * 7;
            }


                      int computeAnswer() {
                          return 42;
                      }
Method inlining
Short methods (or methods that are only invoked once):
   int answer = image.getPixel(i, j);


   int getPixel(int x, int y) {
       return array[y * width + x];
   }
Method inlining
Short methods (or methods that are only invoked once):
   int answer = image.getPixel(i, j);


   int getPixel(int x, int y) {
       return array[y * width + x];
   }




   int answer = image.array[j * image.width + i];
Class merging: horizontally

          Class A




  Class B           Class C




Class D     Class E
Class merging: horizontally

          Class A                  Class A




  Class B           Class C       Class B/C




Class D     Class E           Class D    Class E
Class merging: vertically

      Class A




      Class B




Class C     Class D
Class merging: vertically

      Class A

                          Class A/B


      Class B




Class C     Class D   Class C     Class D
Tail recursion simplification
int answer = computeAnswer(1, 2, 3, 7);

int computeAnswer(int f1, int f2, int f3, int f4) {
    if (f2 == 1 && f3 == 1 && f4 == 1) {
        return f1;
    } else {
        return computeAnswer(f1 * f2, f3, f4, 1);
    }
}
Tail recursion simplification
int answer = computeAnswer(1, 2, 3, 7);

int computeAnswer(int f1, int f2, int f3, int f4) {
    if (f2 == 1 && f3 == 1 && f4 == 1) {
        return f1;
    } else {
        return computeAnswer(f1 * f2, f3, f4, 1);
    }
}


      int computeAnswer(int f1, int f2, int f3, int f4) {
        do {
          if (f2 == 1 && f3 == 1 && f4 == 1) {
              return f1;
          } else {
              f1 = f1 * f2; f2 = f3, f3 = f4, f4 = 1;
          }
        } while (true);
      }
Tail recursion simplification
                                            int answer = 42;
int answer = computeAnswer(1, 2, 3, 7);

int computeAnswer(int f1, int f2, int f3, int f4) {
    if (f2 == 1 && f3 == 1 && f4 == 1) {
        return f1;
    } else {
        return computeAnswer(f1 * f2, f3, f4, 1);
    }
}


      int computeAnswer(int f1, int f2, int f3, int f4) {
        do {
          if (f2 == 1 && f3 == 1 && f4 == 1) {
              return f1;
          } else {
              f1 = f1 * f2; f2 = f3, f3 = f4, f4 = 1;
          }
        } while (true);
      }
Tip   How to enable optimization?
project.properties:


  # To enable ProGuard to shrink and obfuscate
      your code, uncomment this
  proguard.config=
      ${sdk.dir}/tools/proguard/proguard-android-optimize.txt:
      proguard-project.txt
Tip              Remove logging code
Specify assumptions in proguard-project.txt:

       ­assumenosideeffects class android.util.Log {
           public static boolean isLoggable(java.lang.String, int);
           public static int v(...);
           public static int i(...);
           public static int w(...);
           public static int d(...);
           public static int e(...);
           public static java.lang.String getStackTraceString
                                                (java.lang.Throwable);
       }
Obfuscation
Traditional name obfuscation:


●
    Rename identifiers:
      class/field/method names

●
    Remove debug information:
      line numbers, local variable names,...
Obfuscation
public class MyComputationClass {
    private MySettings settings;
    private MyAlgorithm algorithm;
    private int         answer;

    public int computeAnswer(int input) {
        …
        return answer;
    }                          public class a {
}                                  private b    a;
                                   private c    b;
                                   private int c;

                                     public int a(int a) {
                                         …
                                         return c;
                                     }
                               }
Complementary steps




Optimization                 Obfuscation




      Irreversibly remove information
ProGuard guide – Android SDK




             developer.android.com
             developer.android.com
ProGuard website




       proguard.sourceforge.net
       proguard.sourceforge.net
ProGuard manual




      proguard.sourceforge.net
      proguard.sourceforge.net
Startup: Saikoa
●
    Open source: ProGuard
●
    Services:   Professional ProGuard support
●
    Product:    DexGuard
ProGuard - DexGuard
                     Compatible

Open source          Closed source

   Generic             Specialized

    Shrinker              Shrinker
   Optimizer             Optimizer
   Obfuscator            Obfuscator
                          Protector
 For Java bytecode
                          For Android
Motivations for hacking/cracking
●
    Anti-malware research    ●
                                 Different ads
●
    Reverse-engineering      ●
                                 Different market
    protocols, formats,...   ●
                                 Extorsion
●
    Fun                      ●
                                 Extract assets
●
    Translation              ●
                                 Extract API keys
●
    Game cheating            ●
                                 Insert malware (SMS,...)
●
    Software piracy          ●
                                 ...
●
    Remove ads
Solutions?
●
    Ignore it
●
    Different business model (open source, service)
●
    Regular updates
●
    Lock down device
●
    Server
●
    Remove motivations
●
    Obfuscation, application protection
More application protection
Nothing is unbreakable, but you can raise the bar:
●
    Reflection
●
    String encryption
●
    Class encryption
●
    Tamper detection
●
    Debug detection
●
    Emulator detection
●
    …
→ Automatically applied by DexGuard
Saikoa website




        www.saikoa.com
        www.saikoa.com
Questions?

                       Open source
ProGuard

             Shrinking
            Optimization
            Obfuscation
                                     Saikoa
Java bytecode


                           DexGuard
    Dalvik bytecode

Weitere ähnliche Inhalte

Was ist angesagt?

Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmerMiguel Vilaca
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
Declarative Gesture Spotting Using Inferred and Refined Control Points
Declarative Gesture Spotting Using Inferred and Refined Control PointsDeclarative Gesture Spotting Using Inferred and Refined Control Points
Declarative Gesture Spotting Using Inferred and Refined Control PointsBeat Signer
 
Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...
Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...
Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...Marcel Bruch
 
重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2Chris Huang
 
Java level 1 Quizzes
Java level 1 QuizzesJava level 1 Quizzes
Java level 1 QuizzesSteven Luo
 
重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1Chris Huang
 
Refactoring-ch7 moving feature btw objects
Refactoring-ch7 moving feature btw objectsRefactoring-ch7 moving feature btw objects
Refactoring-ch7 moving feature btw objectsfungfung Chen
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3 rohassanie
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 NurembergMarcel Bruch
 
Eclipse Code Recommenders @ MAJUG 2011
Eclipse Code Recommenders @ MAJUG 2011Eclipse Code Recommenders @ MAJUG 2011
Eclipse Code Recommenders @ MAJUG 2011Marcel Bruch
 
Mutation Testing at BzhJUG
Mutation Testing at BzhJUGMutation Testing at BzhJUG
Mutation Testing at BzhJUGSTAMP Project
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulationIntro C# Book
 
Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Intel® Software
 

Was ist angesagt? (20)

03slide
03slide03slide
03slide
 
2621008 - C++ 3
2621008 -  C++ 32621008 -  C++ 3
2621008 - C++ 3
 
05slide
05slide05slide
05slide
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
Declarative Gesture Spotting Using Inferred and Refined Control Points
Declarative Gesture Spotting Using Inferred and Refined Control PointsDeclarative Gesture Spotting Using Inferred and Refined Control Points
Declarative Gesture Spotting Using Inferred and Refined Control Points
 
Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...
Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...
Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden Tec...
 
重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2
 
Java level 1 Quizzes
Java level 1 QuizzesJava level 1 Quizzes
Java level 1 Quizzes
 
重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1
 
Refactoring-ch7 moving feature btw objects
Refactoring-ch7 moving feature btw objectsRefactoring-ch7 moving feature btw objects
Refactoring-ch7 moving feature btw objects
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 Nuremberg
 
Eclipse Code Recommenders @ MAJUG 2011
Eclipse Code Recommenders @ MAJUG 2011Eclipse Code Recommenders @ MAJUG 2011
Eclipse Code Recommenders @ MAJUG 2011
 
Mutation Testing at BzhJUG
Mutation Testing at BzhJUGMutation Testing at BzhJUG
Mutation Testing at BzhJUG
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
Grails Transactions
Grails TransactionsGrails Transactions
Grails Transactions
 
Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*
 
TDD Hands-on
TDD Hands-onTDD Hands-on
TDD Hands-on
 
Lecture21
Lecture21Lecture21
Lecture21
 

Ähnlich wie OWF12/PAUG Conf Days Pro guard optimizer and obfuscator for android, eric lafortune, ceo at saikoa

Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKGuardSquare
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon Berlin
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKGuardSquare
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialTsukasa Sugiura
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Performance #5 cpu and battery
Performance #5  cpu and batteryPerformance #5  cpu and battery
Performance #5 cpu and batteryVitali Pekelis
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScriptJungsoo Nam
 
Optimization in Programming languages
Optimization in Programming languagesOptimization in Programming languages
Optimization in Programming languagesAnkit Pandey
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android TipsKenichi Kambara
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbaiCIBIL
 
Eric Lafortune - Fighting application size with ProGuard and beyond
Eric Lafortune - Fighting application size with ProGuard and beyondEric Lafortune - Fighting application size with ProGuard and beyond
Eric Lafortune - Fighting application size with ProGuard and beyondGuardSquare
 
Tdd with python unittest for embedded c
Tdd with python unittest for embedded cTdd with python unittest for embedded c
Tdd with python unittest for embedded cBenux Wei
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Windows Developer
 

Ähnlich wie OWF12/PAUG Conf Days Pro guard optimizer and obfuscator for android, eric lafortune, ceo at saikoa (20)

Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
 
Pruning your code
Pruning your codePruning your code
Pruning your code
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and Tutorial
 
從零開始學 Android
從零開始學 Android從零開始學 Android
從零開始學 Android
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Performance #5 cpu and battery
Performance #5  cpu and batteryPerformance #5  cpu and battery
Performance #5 cpu and battery
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
Optimization in Programming languages
Optimization in Programming languagesOptimization in Programming languages
Optimization in Programming languages
 
Android - Anatomy of android elements & layouts
Android - Anatomy of android elements & layoutsAndroid - Anatomy of android elements & layouts
Android - Anatomy of android elements & layouts
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips
 
Clean code
Clean codeClean code
Clean code
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbai
 
Clean Code 2
Clean Code 2Clean Code 2
Clean Code 2
 
Eric Lafortune - Fighting application size with ProGuard and beyond
Eric Lafortune - Fighting application size with ProGuard and beyondEric Lafortune - Fighting application size with ProGuard and beyond
Eric Lafortune - Fighting application size with ProGuard and beyond
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
 
Tdd with python unittest for embedded c
Tdd with python unittest for embedded cTdd with python unittest for embedded c
Tdd with python unittest for embedded c
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 

Mehr von Paris Open Source Summit

#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...
#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...
#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...Paris Open Source Summit
 
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...Paris Open Source Summit
 
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...Paris Open Source Summit
 
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, ArduinoParis Open Source Summit
 
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...Paris Open Source Summit
 
#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...
#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...
#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...Paris Open Source Summit
 
#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix
#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix
#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, ZabbixParis Open Source Summit
 
#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria
#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria
#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, InriaParis Open Source Summit
 
#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...
#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...
#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...Paris Open Source Summit
 
#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches ...
#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches  ...#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches  ...
#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches ...Paris Open Source Summit
 
#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...
#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...
#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...Paris Open Source Summit
 
#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...
#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...
#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...Paris Open Source Summit
 
#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...
#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...
#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...Paris Open Source Summit
 
#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...
#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...
#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...Paris Open Source Summit
 
#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...
#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...
#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...Paris Open Source Summit
 
#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...
#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...
#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...Paris Open Source Summit
 
#OSSPARIS19 - Table ronde : souveraineté des données
#OSSPARIS19 - Table ronde : souveraineté des données #OSSPARIS19 - Table ronde : souveraineté des données
#OSSPARIS19 - Table ronde : souveraineté des données Paris Open Source Summit
 
#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...
#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...
#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...Paris Open Source Summit
 
#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...
#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...
#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...Paris Open Source Summit
 
#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...
#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...
#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...Paris Open Source Summit
 

Mehr von Paris Open Source Summit (20)

#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...
#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...
#OSSPARIS19 : Control your Embedded Linux remotely by using WebSockets - Gian...
 
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
 
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
 
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
 
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
 
#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...
#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...
#OSSPARIS19 : Detecter des anomalies de séries temporelles à la volée avec Wa...
 
#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix
#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix
#OSSPARIS19 : Supervision d'objets connectés industriels - Eric DOANE, Zabbix
 
#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria
#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria
#OSSPARIS19: Introduction to scikit-learn - Olivier Grisel, Inria
 
#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...
#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...
#OSSPARIS19 - Fostering disruptive innovation in AI with JEDI - André Loesekr...
 
#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches ...
#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches  ...#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches  ...
#OSSPARIS19 : Comment ONLYOFFICE aide à organiser les travaux de recherches ...
 
#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...
#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...
#OSSPARIS19 : MDPH : une solution collaborative open source pour l'instructio...
 
#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...
#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...
#OSSPARIS19 - Understanding Open Source Governance - Gilles Gravier, Wipro Li...
 
#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...
#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...
#OSSPARIS19 : Publier du code Open Source dans une banque : Mission impossibl...
 
#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...
#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...
#OSSPARIS19 : Libre à vous ! Raconter les libertés informatiques à la radio -...
 
#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...
#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...
#OSSPARIS19 - Le logiciel libre : un enjeu politique et social - Etienne Gonn...
 
#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...
#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...
#OSSPARIS19 - Conflits d’intérêt & concurrence : la place de l’éditeur dans l...
 
#OSSPARIS19 - Table ronde : souveraineté des données
#OSSPARIS19 - Table ronde : souveraineté des données #OSSPARIS19 - Table ronde : souveraineté des données
#OSSPARIS19 - Table ronde : souveraineté des données
 
#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...
#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...
#OSSPARIS19 - Comment financer un projet de logiciel libre - LUDOVIC DUBOST, ...
 
#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...
#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...
#OSSPARIS19 - BlueMind v4 : les dessous technologiques de 10 ans de travail p...
 
#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...
#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...
#OSSPARIS19 - Tuto de première installation de VITAM, un système d'archivage ...
 

OWF12/PAUG Conf Days Pro guard optimizer and obfuscator for android, eric lafortune, ceo at saikoa

  • 1. ProGuard Optimizer and Obfuscator for Android Eric Lafortune Saikoa
  • 2. Eric Lafortune ● 1991 – 1996 K.U.Leuven (Belgium), Phd Eng CompSci ● 1996 – 1999 Cornell University (Ithaca, NY) ● 1999 – 2011 Java GIS ● 2012 Founder Saikoa Maybe more importantly: ● 1982 TMS-9900 processor ● 1995 ARM2/ARM3 processor ● 2001 Java bytecode ● 2010 Dalvik bytecode
  • 3. ProGuard Open source Generic Shrinker Optimizer Obfuscator For Java bytecode
  • 4. ProGuard history Java applications Applets Android apps Midlets 2002 2010 2012 ● May 2002 First download! ● Sep 2010 Recommended for protecting LVL ● Dec 2010 Part of Android SDK ● Jan 2012 Startup Saikoa
  • 5. Why use ProGuard? ● Application size ● Performance ● Remove logging, debugging, testing code ● Battery life ● Protection
  • 6. Application size classes.dex size .apk size Without With Without With Reduction Reduction ProGuard ProGuard ProGuard ProGuard ApiDemos 716 K 482 K 33% 2.6 M 2.5 M 4% ApiDemos ~6 M 542 K ~90% ~8 M 2.5 M ~70% in Scala* * [Stéphane Micheloud, http://lampwww.epfl.ch/~michelou/android/library-code-shrinking.html]
  • 7. Performance: CaffeineMark Without ProGuard With ProGuard Sieve score = 6833 Sieve score = 6666 Loop score = 14831 Loop score = 15473 Logic score = 19038 Logic score = 47840 String score = 7694 String score = 7717 Float score = 6425 Float score = 6488 Method score = 4850 Method score = 5229 Overall score = 8794 Overall score = 10436 Improvement: 18% [Acer Iconia Tab A500, nVidia Tegra 2, 1.0 GHz, Android 3.2.1]
  • 8. Battery life Extreme example: “5 x better battery life, by removing verbose logging code in a background service” (but don't count on it)
  • 9. Tip How to enable ProGuard? project.properties: # To enable ProGuard to shrink and obfuscate your code, uncomment this #proguard.config= ${sdk.dir}/tools/proguard/proguard-android.txt: proguard-project.txt → only applied when building release versions
  • 10. Build process ProGuard ProGuard [Android documentation]
  • 11. Shrinking Also called treeshaking, minimizing, shrouding
  • 12. Shrinking ● Classes, fields, methods
  • 13. Entry points 1) Activities, applications, services, fragments,... → provided automatically by Android build process -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service …
  • 14. Tip Entry points 2) Introspection, e.g. Google License Verification Library → must be specified in proguard-project.txt -keep public interface com.android.vending.licensing.ILicensingService
  • 15. Entry points More introspection, e.g. Google vending library → must be specified in proguard-project.txt -keepclassmembers public class com.google.android.vending.expansion.downloader.impl.DownloadsDB$* { public static final java.lang.String[][] SCHEMA; public static final java.lang.String TABLE_NAME; }
  • 16. Entry points More introspection, e.g. Guice, RoboGuice → must be specified in proguard-project.txt: -keepclassmembers class * { @javax.inject.** <fields>; @com.google.inject.** <fields>; @roboguice.** <fields>; @roboguice.event.Observes <methods>; }
  • 17. Tip Notes and warnings “Closed-world assumption” Warning: twitter4j.internal.logging.Log4JLoggerFactory: can't find referenced class org.apache.log4j.Logger Warning: twitter4j.internal.logging.SLF4JLoggerFactory: can't find referenced class org.slf4j.LoggerFactory ... Warning: com.dropbox.client2.DropboxAPI: can't find referenced class org.json.simple.JSONArray → if debug build works fine, then ok to ignore in proguard-project.txt: ­dontwarn twitter4j.internal.logging.** ­dontwarn com.dropbox.client2.**
  • 18. Optimization At the bytecode instruction level: ● Dead code elimination ● Constant propagation ● Method inlining ● Class merging ● Remove logging code ● Peephole optimizations ● Devirtualization ● ...
  • 19. Dead code elimination boolean debug = false; … if (debug) Log.v(“.....”); … Note: showing equivalent source code instead of bytecode
  • 20. Dead code elimination boolean debug = false; … if (debug) Log.v(“.....”); … Note: showing equivalent source code instead of bytecode
  • 21. Constant propagation Inside methods: int f1 = 6; … int f2 = 7; … int answer = f1 * f2;
  • 22. Constant propagation Inside methods: int f1 = 6; … int f2 = 7; … int answer = f1 * f2; … int answer = 6 * 7;
  • 23. Constant propagation Inside methods: int f1 = 6; … int f2 = 7; … int answer = f1 * f2; … int answer = 6 * 7; … int answer = 42;
  • 24. Constant propagation Across methods: int answer = computeAnswer(6, 7); int computeAnswer(int f1, int f2) {     return f1 * f2; }
  • 25. Constant propagation Across methods: int answer = computeAnswer(6, 7); int computeAnswer(int f1, int f2) { return f1 * f2; } int computeAnswer(int f1, int f2) { return 6 * 7; }
  • 26. Constant propagation Across methods: int answer = computeAnswer(6, 7); int computeAnswer(int f1, int f2) { return f1 * f2; } int computeAnswer(int f1, int f2) { return 6 * 7; } int computeAnswer() { return 42; }
  • 27. Constant propagation Across methods: int answer = computeAnswer(6, 7); int answer = 42; int computeAnswer(int f1, int f2) { return f1 * f2; } int computeAnswer(int f1, int f2) { return 6 * 7; } int computeAnswer() { return 42; }
  • 28. Method inlining Short methods (or methods that are only invoked once): int answer = image.getPixel(i, j); int getPixel(int x, int y) { return array[y * width + x]; }
  • 29. Method inlining Short methods (or methods that are only invoked once): int answer = image.getPixel(i, j); int getPixel(int x, int y) { return array[y * width + x]; } int answer = image.array[j * image.width + i];
  • 30. Class merging: horizontally Class A Class B Class C Class D Class E
  • 31. Class merging: horizontally Class A Class A Class B Class C Class B/C Class D Class E Class D Class E
  • 32. Class merging: vertically Class A Class B Class C Class D
  • 33. Class merging: vertically Class A Class A/B Class B Class C Class D Class C Class D
  • 34. Tail recursion simplification int answer = computeAnswer(1, 2, 3, 7); int computeAnswer(int f1, int f2, int f3, int f4) { if (f2 == 1 && f3 == 1 && f4 == 1) { return f1; } else { return computeAnswer(f1 * f2, f3, f4, 1); } }
  • 35. Tail recursion simplification int answer = computeAnswer(1, 2, 3, 7); int computeAnswer(int f1, int f2, int f3, int f4) { if (f2 == 1 && f3 == 1 && f4 == 1) { return f1; } else { return computeAnswer(f1 * f2, f3, f4, 1); } } int computeAnswer(int f1, int f2, int f3, int f4) {   do {     if (f2 == 1 && f3 == 1 && f4 == 1) {         return f1;     } else {         f1 = f1 * f2; f2 = f3, f3 = f4, f4 = 1;     }   } while (true); }
  • 36. Tail recursion simplification int answer = 42; int answer = computeAnswer(1, 2, 3, 7); int computeAnswer(int f1, int f2, int f3, int f4) { if (f2 == 1 && f3 == 1 && f4 == 1) { return f1; } else { return computeAnswer(f1 * f2, f3, f4, 1); } } int computeAnswer(int f1, int f2, int f3, int f4) { do { if (f2 == 1 && f3 == 1 && f4 == 1) { return f1; } else { f1 = f1 * f2; f2 = f3, f3 = f4, f4 = 1; } } while (true); }
  • 37. Tip How to enable optimization? project.properties: # To enable ProGuard to shrink and obfuscate your code, uncomment this proguard.config= ${sdk.dir}/tools/proguard/proguard-android-optimize.txt: proguard-project.txt
  • 38. Tip Remove logging code Specify assumptions in proguard-project.txt: ­assumenosideeffects class android.util.Log {     public static boolean isLoggable(java.lang.String, int);     public static int v(...);     public static int i(...);     public static int w(...);     public static int d(...);     public static int e(...);     public static java.lang.String getStackTraceString                                          (java.lang.Throwable); }
  • 39. Obfuscation Traditional name obfuscation: ● Rename identifiers: class/field/method names ● Remove debug information: line numbers, local variable names,...
  • 40. Obfuscation public class MyComputationClass { private MySettings settings; private MyAlgorithm algorithm; private int answer; public int computeAnswer(int input) { … return answer; } public class a { } private b a; private c b; private int c; public int a(int a) { … return c; } }
  • 41. Complementary steps Optimization Obfuscation Irreversibly remove information
  • 42. ProGuard guide – Android SDK developer.android.com developer.android.com
  • 43. ProGuard website proguard.sourceforge.net proguard.sourceforge.net
  • 44. ProGuard manual proguard.sourceforge.net proguard.sourceforge.net
  • 45. Startup: Saikoa ● Open source: ProGuard ● Services: Professional ProGuard support ● Product: DexGuard
  • 46. ProGuard - DexGuard Compatible Open source Closed source Generic Specialized Shrinker Shrinker Optimizer Optimizer Obfuscator Obfuscator Protector For Java bytecode For Android
  • 47. Motivations for hacking/cracking ● Anti-malware research ● Different ads ● Reverse-engineering ● Different market protocols, formats,... ● Extorsion ● Fun ● Extract assets ● Translation ● Extract API keys ● Game cheating ● Insert malware (SMS,...) ● Software piracy ● ... ● Remove ads
  • 48. Solutions? ● Ignore it ● Different business model (open source, service) ● Regular updates ● Lock down device ● Server ● Remove motivations ● Obfuscation, application protection
  • 49. More application protection Nothing is unbreakable, but you can raise the bar: ● Reflection ● String encryption ● Class encryption ● Tamper detection ● Debug detection ● Emulator detection ● … → Automatically applied by DexGuard
  • 50. Saikoa website www.saikoa.com www.saikoa.com
  • 51. Questions? Open source ProGuard Shrinking Optimization Obfuscation Saikoa Java bytecode DexGuard Dalvik bytecode