[Android Application Development] Android APK decompilation obfuscation, decompilation, and androidapk

Source: Internet
Author: User

[Android Application Development] Android APK decompilation obfuscation, decompilation, and androidapk



Decompilation Tool: Summarize the linux, windows, and mac versions, and put them on CSDN for download;

--CSDN:Http://download.csdn.net/detail/han1202012/8221787

Octopus @ octopus :~ /Decompiler $ tree-L 2. ├ ── linux │ ── apktool │ ── dex2jar-0.0.9.15 │ jd-gui ── mac │ ── apktool │ ── dex2jar-0.0.9.15 │ ── jd-gui-0.3.5.osx.i686.dmg ── windows │ ── apkTool │ ├ ── dex2jar-0.0.9.15 │ ── jd-gui.exe └ ── source code ── apktool-source.zip10 directories, 4 files





1. decompile to Java source code



1. Tool Introduction


Dex2jar Introduction: Convert the. dex or. class suffix file to a. jar file;

--Latest Version: The latest version 0.0.9.15;

--Official Address (Wall flip required):Http://code.google.com/p/dex2jar/;

--(Wall flip required):Http://code.google.com/p/dex2jar/downloads/list;


Jd-gui Overview: Use this tool to view the java code in. jar;

--Official Website address:Http://jd.benow.ca/;



2. decompilation Process



(1) decompilation of Ubuntu


A. Obtain the. dex suffix file.: Modify the suffix of the apk file to obtain the class. dex file;


B. Execute Decompilation: Copy classes. dex to the dex2jar directory and run./D2j-dex2jar.sh classes. dexCommand;

--Execution result:

octopus@octopus:~/decompiler/linux/dex2jar-0.0.9.15$ ./d2j-dex2jar.sh classes.dex dex2jar classes.dex -> classes-dex2jar.jar

C. view source code in jd-gui: Drag the classes-dex2jar.jar file into jd-gui to view the source code;




3. obfuscation code


Note: If the signature file is not used for packaging, the files directly copied from eclipse cannot be confused;


(1) configuration obfuscation File


Edit progard. cfg:

-- File Content:

-Optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations! Code/simplification/arithmetic ,! Field /*,! Class/merging/* # classes related to components are not obfuscated. 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 # native methods in all classes are not Obfuscated-keepclasseswithmembernames class * {native <methods> ;} # Do not confuse the method names of the specified methods of all classes-keepclasseswithmembers class * {public <init> (android. content. context, android. util. attributeSet) ;}# do not confuse the method names of the specified methods of all classes-keepclasseswithmembers class * {public <init> (android. content. context, android. util. attributeSet, int) ;}# reserve the Activity subclass-keepclassmembers class * extends android. app. activity {public void * (android. view. view) ;}# do not confuse the method names of the specified methods under all classes of the enum type-keepclassmembers enum * {public static ** [] values (); public static ** valueOf (java. lang. string) ;}# classes that implement the Parcelable serialization interface are not Obfuscated-keep class * implements android. OS. parcelable {public static final android. OS. parcelable $ Creator *;}


--Project. properties configuration confusion File:

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



(2) package the apk file (create a new keystore)


A. Set the packaging project: Right-click the project and choose Android Tools --> Export Signed Application Package. The following dialog box is displayed. Select the program to be packaged, set it, and click Next;



B. Create a keystore: Select Create new keystore, select a file, and set the keystore user name and password;

--Location: Keystore file;

-- Password: Password;

--Confirm: Confirm the password and re-enter the password;


C. Enter the keystore details:

--Alias: Alias;

--Password: Alias password;

--Confirm: Confirm the password;

--Validity (years): Validity period. It is recommended to be 25 years;

--First and Last Name: Developer name;

The following parameters are optional.

--Orgnizational Unit: Organization name;

--Orgnization: Organization;

--City or Location: City;

--State or Provience: Province or state;

--Country Code: Country;


D. Select and package the apk File: Click finish to complete packaging;



(3) package the apk file (use the existing keystore file)


A. Select the packaged Project: Right-click the project and choose Android Tools --> Export Signed Application Package;



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



C. Enter the alias Password:



D. Package apk: select the apk file to package:




(4) Verify the obfuscation Effect


Decompilation: Change the suffix of the apk file to. zip, and then extract the classes. dex file to the dex2jar root directory and execute the./d2j-dex2jar.sh classes. dex command;

octopus@octopus:~/decompiler/linux/dex2jar-0.0.9.15$ ./d2j-dex2jar.sh classes.dex dex2jar classes.dex -> classes-dex2jar.jar

View Java code in jd-gui:





Ii. decompilation of Apktools



1. Introduction to Apktools


Apktools Overview:

--Latest Version: 2.0.0;

--Official website (Wall flip required):Https://code.google.com/p/android-apktool/;

--New Version:Https://bitbucket.org/iBotPeaches/apktool/downloads;

--Old Version (Wall flip required):Https://code.google.com/p/android-apktool/downloads/list;


Files 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. Decompilation


Put the downloaded file into a file:



Decompilation: Put the apk file in the directory above and execute the command./apktool d WheelView.apk;

-- Decompilation process:

octopus@octopus:~/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...octopus@octopus:~/decompiler/linux/apktool$ lsaapt  apktool  apktool.jar  WheelView  WheelView.apk

-- Decompilation result: The Decompilation results are all in the WheelView directory. res contains related resource files, while smali contains smali assembly files;




3. recompile


Recompile Command Format:./Apktool B apk source directory apk file name;

--Execute Command:./Apktool B WheelView WheelView1.apk, which can generate the WheelView1.apk file;

octopus@octopus:~/decompiler/linux/apktool$ lsaapt  apktool  apktool.jar  WheelView  WheelView.apkoctopus@octopus:~/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...octopus@octopus:~/decompiler/linux/apktool$ lsaapt  apktool  apktool.jar  WheelView  WheelView1.apk  WheelView.apk


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.