Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to decompile the Android deployment program

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to decompile Android deployment program", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to decompile Android deployment program" this article.

Method 1: apk- > dexdexdextre java (recommended)

1. Download dex2jar at the download address (see attachment):

Http://code.google.com/p/dex2jar/downloads/list

two。 Download the class decompiler jad

Download address (see attachment):

Http://www.119.xdowns.com/uploadFile/2010-8/jd-gui-0.3.3.osx.i686.zip 3. Use winrar to extract the .apk file. We can see the classes.dex file. This is the bytecode file supported by the Android virtual machine Dalvik.

4. Enter the path where dex2jar.bat is located under cmd and enter dex2jar.bat D:\ project\ classes.dex. Where D:\ project\ classes.dex is where your classes.dex is located.

5. Then a classes.dex.dex2jar.jar file is generated in the classes.dex sibling directory

6. Use the jad tool to open the jar file, and you can see the code in the jar file. And can be directly saved as a java file.

Method 2: (recommended)

Apk- > encrypted XML- > decrypted XML

Apk- > dex à smali

In addition, the above operation can only get java code, but we may also need some XML files. After unzipping the APK file, we find that the XML files in it are all processed, and we can't see the source code.

Let's use the apktool provided by Google to get the xml file

1. Download apktool, you can go to the official download of Google (see attachment)

Address: http://code.google.com/p/android-apktool/

Apktool-1.0.0.tar.bz2 and apktool-install-windows-2.1_r01-1.zip are both packages.

two。 Extract the two downloaded files to a folder (for example, E disk root directory). Make sure the unzipped aapt.exe,apktool.bat,apktool.jar is in the same folder.

3. The .apk file to be cracked is also put into this folder.

4. Run CMD, use the cd command to go to the folder where these files are located, type apktool, and if you list some help, it will be successful (explain d for pressurized * * paths to the location of your apk. The second is the location to output)

Apktool d XXX.apk ABC decompiled XXX.apk to folder ABC (you must make sure there is no ABC folder in the current directory, otherwise an error will be reported)

5. The xml configuration file in apk is available in the unzipped folder.

In fact, you will get a smali folder in this way, go in and open one of the .smali files with notepad. By interpreting the information inside, you can get a full view of the code, but it is a bit laborious. Let's compare the .smali and .java source code with an example:

ApkInstaller.smali file:

.class public Lcom/tutor/apkinstaller/ApkInstaller; .super Landroid/app/Activity; .source "ApkInstaller.java" # instance fields .field private apkWeb:Landroid/webkit/WebView; # direct methods .method public constructor () V .registers 1 .prologue .line 8 invoke-direct {p0}, Landroid/app/Activity;- > () V return-void .end method # virtual methods .method public onCreate (Landroid/os/Bundle ) V .registers 5. Parameter "savedInstanceState" .prologue .line 13 invoke-super {p0, p1}, Landroid/app/Activity;- > onCreate (Landroid/os/Bundle;) V. line 14 const/high26 v2, 0x7f03 invoke-virtual {p0, v2}, Lcom/tutor/apkinstaller/ApkInstaller -> setContentView (I) V .line 15 const/high26 v2, 0x7f05 invoke-virtual {p0, v2}, Lcom/tutor/apkinstaller/ApkInstaller;- > findViewById (I) Landroid/view/View; move-result-object v2 check-cast v2, Landroid/webkit/WebView; iput-object v2, p0, Lcom/tutor/apkinstaller/ApkInstaller;- > apkWeb:Landroid/webkit/WebView; .line 16 iget-object v2, p0, Lcom/tutor/apkinstaller/ApkInstaller -> apkWeb:Landroid/webkit/WebView; invoke-virtual {v2}, Landroid/webkit/WebView;- > getSettings () Landroid/webkit/WebSettings; move-result-object v1 .line 17 .local v1, webSettings:Landroid/webkit/WebSettings; const/4 v2, 0x1 invoke-virtual {v1, v2}, Landroid/webkit/WebSettings -> setJavaScriptEnabled (Z) V .line 19 const-string v0, "http://frankiewei.net/apk/demos/main/index.html#home" .line 20 .local v0, apkUrl:Ljava/lang/String; iget-object v2, p0, Lcom/tutor/apkinstaller/ApkInstaller;- > apkWeb:Landroid/webkit/WebView; invoke-virtual {v2, v0}, Landroid/webkit/WebView;- > loadUrl (Ljava/lang/String ) V .line 21 return-void .end method

The source code for ApkInstaller.java is as follows:

Package com.tutor.apkinstaller; import android.app.Activity; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; public class ApkInstaller extends Activity {private WebView apkWeb; @ Override public void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.main); apkWeb = (WebView) findViewById (R.id.apk_web) WebSettings webSettings = apkWeb.getSettings (); webSettings.setJavaScriptEnabled (true); String apkUrl = "http://frankiewei.net/apk/demos/main/index.html#home"; apkWeb.loadUrl (apkUrl);}}

It is really a bit troublesome to understand whether there is any feeling through the comparison between the two. Therefore, it is recommended that we use method one to get the java code, and method two to get the xml file. This allows you to get the code for the entire project.

But sometimes method one may go wrong, the author has encountered this situation, this time can only use method two.

In addition, introduce another way, the code obtained in this way is not as clear as method 2, but let's introduce it.

Method 3: apk- > dex- > ddx

The ddx file can't see the source code, but you can see the structure of the class. Sometimes you may not be able to get the source code by using the * method, so use the second method to fix it.

Dedexer project home page (see attachment): http://dedexer.sourceforge.net/

The download address is also on this website. The downloaded file is ddx1.11.jar (currently 1.11)

1. Run CMD to enter the directory of ddx1.11.jar and enter the following command: d:\ WINDOWS\ system32 > java-jar ddx1.11.jar

two。 The following prompt appears

Usage: java-jar ddx.jar-o-D-r-d

Specify the directory where the generated files are placed

: dex source file.

-D-specifies that an error message is generated.

-o-specifies to generate a log file (dex.log).

3. Read the above information carefully according to:

Java-jar ddx1.11.jar-o-D-r-d

Press this prompt to enter:

Java-jar ddx1.11.jar-o-D-r-d c:\ dex\ gen c:\ dex\ classes.dex 4.

Run successfully, the ddx file is generated in the gen directory. Open it with a text editor and you can see the general structure of the class.

These are all the contents of the article "how to decompile Android deployments". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report