"Android App development" Android APK anti-compilation confusing recompile

Source: Internet
Author: User



Anti-compilation tool : Summed up the Linux, Windows, Mac version, put together on the CSDN download;

-- CSDN :

[Email protected]:~/decompiler$ tree-l 2.├──linux│├──apktool│├──dex2jar-0.0.9.15│└──jd-gui├──mac│├──apk tool│├──dex2jar-0.0.9.15│└──jd-gui-0.3.5.osx.i686.dmg├──windows│├──apktool│├──dex2jar-0.0.9.15│└──jd- gui.exe└── Source    └──apktool-source.zip10 directories, 4 files





I. decompile to Java source code



1. Introduction of Tools


Dex2jar Introduction : Convert. dex or. class suffix files to. jar files;

-- Latest version : Currently the latest version 0.0.9.15;

-- official address (need to turn over the wall) : http://code.google.com/p/dex2jar/ ;

-- (need to turn over the wall) : http://code.google.com/p/dex2jar/downloads/list;


Jd-gui Introduction : Use this tool to view the Java code in the. jar;

-- official address : http://jd.benow.ca/ ;



2. Anti-compilation process



(1) Ubuntu system anti-compilation


A. get the. dex suffix file : Modify the apk file suffix to obtain the Class.dex file;


B. perform anti-compilation : Copy the Classes.dex to the Dex2jar directory and execute the ./d2j-dex2jar.sh classes.dex command;

-- Execution Results :

[Email protected]:~/decompiler/linux/dex2jar-0.0.9.15$./d2j-dex2jar.sh Classes.dex Dex2jar Classes.dex Classes-dex2jar.jar

c. View the source code in Jd-gui : Drag the Classes-dex2jar.jar file into the Jd-gui to view the source code;




3. Confusing Code


Note: Files that are copied directly from eclipse cannot be confused if you do not use a signature file for packaging.


(1) Configuring confusing files


Edit Progard.cfg :

-- file contents :

-optimizationpasses 5- Dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations!code/ simplification/arithmetic,!field/*,!class/merging/* #组件相关的类不进行混淆, keep-keep public class * extends Android.app.activity-keep public class * extends Android.app.application-keep public class * extends Android.app.service-keep public class * extends Android.content.broadcastreceiver-keep public class * extends Android.content.contentprovider-keep public class * extends Android.app.backup.backupagenthelper-keep public class * Extends Android.preference.preference-keep public class com.android.vending.licensing.ilicensingservice# in all classes Native method does not confuse-keepclasseswithmembernames class * {native <methods>;} # The method name of the specified method for all classes is not confused-keepclasseswithmembers class * {public <init> (Android.content.Context, Android.util.AttributeSet);} #对全部类的指定方法的方法名不进行混淆-keepclasseswithmembers class * {public <init> (Android.content.Context, Android.util.AttributeSet, int);} # Keep Activity subclass-keepclassmembers class * extends android.app.Activity {public void * (Android.view.View);}    # The method names of the following specified methods are not confused for all classes of enum type enum-keepclassmembers enum * {public static **[] values (); public static * * VALUEOF (java.lang.String);} # classes that implement the Parcelable serialization interface do not confuse-keep class * Implements android.os.Parcelable {public static final Android.os.parcelable$cre Ator *;}


-- project.properties configuration obfuscation file :

Target=android-19proguard.config=proguard.cfg



(2) package apk file (Create new KeyStore)


A. set up a packaged project : Right-click the project Select Android Tools---Export Signed application package option, pop up the following dialog box, select the program to package, set it up Click Next;



B. Create KeyStore : Select Create New KeyStore, select a file, and then set the KeyStore user name and password;

- Location: KeyStore file;

-- Password : password;

-- Confirm : Confirm password, re-enter password;


c. Enter KeyStore details :

- alias: aliases;

-- Password : alias password;

-- Confirm : Confirm password;

-- validity (years) : expiry date, recommended 25 years;

-First and last name : developer name;

The following parameters may not be filled in

-- orgnizational Unit : Name of the organization;

-- orgnization : organization;

-City or location: cities;

State or provience : Provinces or States;

-- Country Code : country;


d. Select the apk file and pack : After clicking the Finish button, the package is finished;



(3) Pack the APK file (using an existing KeyStore file)


A. Select the packaged project : Right click on Project, select Android Tools---Export signed application package option;



B. Select signature file : Enter the signature file password;



c. Enter the alias password :



d. pack apk: Select the apk file to be packaged :




(4) Verifying the confusion effect


decompile : Change the apk file suffix to. zip, then remove the Classes.dex file to the Dex2jar root directory and execute the./d2j-dex2jar.sh classes.dex command;

[Email protected]:~/decompiler/linux/dex2jar-0.0.9.15$./d2j-dex2jar.sh Classes.dex Dex2jar Classes.dex Classes-dex2jar.jar

to view Java code in Jd-gui :





two. Apktools Anti-compilation



1. Apktools Introduction


Apktools Introduction :

-- Latest version : 2.0.0;

-- official website (need to turn over the wall) : https://code.google.com/p/android-apktool/ ;

-- new version : https://bitbucket.org/iBotPeaches/apktool/downloads ;

-- old version (need to turn over the wall) : https://code.google.com/p/android-apktool/downloads/list ;


files that need to be downloaded :

-- Apktool jar package : apktool1.5.2.tar.bz2

-- apktool boot tool (Linux) : apktool-install-linux-r05-ibot.tar.bz2

-- apktool boot tool (MAC) : apktool-install-macosx-r05-ibot.tar.bz2

-- apktool boot tool (wondows) : apktool-install-windows-r05-ibot.tar.bz2



2. Anti-compilation


to place the downloaded file in a file :



decompile : Put the apk file into the above directory and execute the command./apktool d wheelview.apk;

--Anti-compilation process:

[Email protected]:~/decompiler/linux/apktool$/apktool d wheelview.apk i:baksmaling ... I:loading Resource Table ... I:loaded.i:decoding Androidmanifest.xml with resources ... I:loading Resource table from file:/home/octopus/apktool/framework/1.apki:loaded.i:regular manifest Package ... I:decoding file-resources ... I:decoding Values */* xmls ... I:done.i:copying Assets and Libs ... [Email protected]:~/decompiler/linux/apktool$ lsaapt  apktool  apktool.jar  wheelview  wheelview.apk

-- Anti-compilation results: Anti-compilation results are in the Wheelview directory, res is a related resource file, Smali is the Smali assembly file;




3. recompile


Recompile command format :./apktool b apk Source directory apk file name;

-- Execute command :./apktool b wheelview wheelview1.apk, wheelview1.apk file can be generated;

[Email protected]:~/decompiler/linux/apktool$ lsaapt  apktool  apktool.jar  wheelview  wheelview.apk [email protected]:~/decompiler/linux/apktool$./apktool b wheelview WheelView1.apkI:Checking whether sources has Changed ... I:smaling ... I:checking whether resources has changed ... I:building Resources ... i:building apk file ... [Email protected]:~/decompiler/linux/apktool$ lsaapt  apktool  apktool.jar  wheelview  wheelview1.apk  wheelview.apk


"Android App development" Android APK anti-compilation confusing recompile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.