Android apk decompilation tool Introduction

Source: Internet
Author: User

First, the apk cannot be obfuscated by code (or optimized without compilation). If it is obfuscated, The decompiled code still cannot be understood. Of course, you do not know whether it is obfuscated before it is decompiled.
Various decompilation tools on the Internet are dazzled. This article is a simple sort of my work. The most reliable and original method is to use the following three tools: apktool + dex2jar + jd-gui. Most of the other tools are derived from these three tools, or packaging the three tools.
ApktoolOfficial features of https://code.google.com/p/android-apktool/ It is a tool for reverse engineering 3rd party, closed, binary Android apps. it can decode resources to nearly original form and rebuild them after making some modifications; it makes possible to debug smali code step by step. also it makes working with app easier because of project-like files structure and automation of some repetitive tasks like building apk, etc. https://code.google.com/p/android-apktool/downloads/list // official download decompilation apk, output resource file and source code smali file:
Usage: D: \ apktool. bat F: \ workspace \ tmp \ test.apk F: workspace \ tmp \ out
Dex2jarHttp://code.google.com/p/dex2jar/ // official function introduction http://code.google.com/p/dex2jar/downloads/list // official download

Dex2jar contains following compment

  1. Dex-reader is designed to read the Dalvik Executable (. dex/. odex) format. It has a light weight API similar with ASM. An example here
  2. Dex-translator is designed to do the convert job. It reads the dex instruction to dex-ir format, after some optimize, convert to ASM format.
  3. Dex-ir used by dex-translator, is designed to represent the dex instruction
  4. Dex-tools to work with. class files. here are examples:
    • Modify a apk
    • DeObfuscate a jar
    • D2j-smali[To be published]Disassemble dex to smali files and assemble dex from smali files. different implementation to smali/baksmali, same syntax, but we support escape in type desc "Lcom/dex2jar \ t \ u1234 ;"
    • Dex-writer[To be published]Write dex same way as dex-reader.
      Download the latest version from the official website and decompile the apk directly. The apk file name cannot contain the Chinese name. The new version of aex2jar does not need to replace the apk with zip to decompress it. decompile it directly: produce jar, open the file with jd, view the code in jd, or export it as a java file and generate it using dex2jar. jar file. dex2jarwill generate a someApk_dex2jar.jar file in the directory where someapk.apk is located. usage: linux sh/home/dex2jar-version/dex2jar. sh/home/someApk.apk windows C: \ dex2jar-version \ dex2jar. bat someApk.apk Note: dex2jar can only generate jar files and cannot generate resource files
      Levin: Both apktool and dex2jar can generate smali code. What are the similarities and differences between the two? I personally think that both will. dex files, that is, DalvikExecutable files, are decompiled into smali code. The difference is that apktool outputs one by one. smali code file, such as a single. in the smali code file, jd-gui cannot be opened (I have not found any tool to open it), and dex2jar generates a package *. jar-format smali source package. This jar-format smali source package can be converted to java code through jd-gui.

      Jd-guiYour Decompiler graphical UIJD-GUI is a standalone graphical utility that displays Java source codes of ". class" files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields.

      As mentioned above, most of the other tools are derived from these three tools, or the packaging of these three tools. You can see that the installation directory contains tools such as apktool.
      The following is a list of these tools and my usage experience:APKMultiTool: Foreign team development, Console interactive interface, used to decompile apk, modify, and re-sign and package. Only contributed source files can be decompiled, and java code cannot be decompiled.
      ApkDec: Android development community www.juapk.com development, graphical interface, can decompile the source file box smali jar package, currently only ApkDec-Release-0.1, win32 version, can not run on 64 for the machine. Looking for an official team, there is no result.Dodo APKTools: Domestic files. Only one smali file can be decompiled.Smali2Java: Domestic version. This decompilation software is awesome. It can restore smali files to java files with high fidelity. More than jd-gui to the next floor http://www.hensence.com/cn/smali2java/ // official function introduction, official download smali2java is a tool to decompile smali code into java code.
      What is smali? Smali is a language that represents the Android bytecode in the form of readable strings. It can be called the Android bytecode disassembly language. Baksmali or apktool can decompile Android application packages (apk or jar) into smali code.
      Levin: jd-gui Can decompile the smali code, indicating that the smali code is similar to. class code.
      The Decompilation process of smali2java is: dex bytecode --> smali code --> java code
      The smali2java tool is based on the smali file generated by apktool v1.5.0 (baksmali v1.3.4) and depends on the number of lines of code in the smali file (. line keyword) and variable alias (. local keyword) to restore the original java code to the maximum extent. The restored java code has the original variable name, and the code order is consistent with that of the original java code. Therefore, this tool also has limitations and is only applicable to smali files with the number of rows and variable alias information (java compiler compilation options can remove this information from the generated bytecode ).

      Conclusion: If you want to decompile resources and decompile the java source code, I recommend the following optimal method (saving time and effort, and improving the effect): Step 1: Use apktool, decompile all resource files Step 2: decompile high-fidelity java code using Smali2Java

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.