当前位置:操作系统 > 安卓/Android >>

ubuntu环境下反编译android apk

使用ApkTool反编译Apk
下载  apktool1.4.3.tar.bz2 、apktool-install-linux-r04-brut1.tar.bz2 两个包,并解压到统一个目录中,解压后得到aapt  apktool  apktool.jar 。解压安装完成后输入以下命令解压:
[plain]
<SPAN xmlns="http://www.w3.org/1999/xhtml">$ ./apktool d apk/xgd_android_test.apk  
I: Baksmaling... 
I: Loading resource table... 
I: Loaded. 
I: Loading resource table from file: /home/yangyupeng/apktool/framework/1.apk 
I: Loaded. 
I: Decoding file-resources... 
W: Cant find 9patch chunk in file: "drawable-mdpi/navbar.9.png". Renaming it to *.png. 
I: Decoding values*/* XMLs... 
I: Done. 
I: Copying assets and libs... 
</SPAN> 

$ ./apktool d apk/xgd_android_test.apk
I: Baksmaling...
I: Loading resource table...
I: Loaded.
I: Loading resource table from file: /home/yangyupeng/apktool/framework/1.apk
I: Loaded.
I: Decoding file-resources...
W: Cant find 9patch chunk in file: "drawable-mdpi/navbar.9.png". Renaming it to *.png.
I: Decoding values*/* XMLs...
I: Done.
I: Copying assets and libs...

显示如上,注意apktool的参数,d表示decode,b表示build,此时在当前目录生成apk的解压文件:

[html]
<SPAN xmlns="http://www.w3.org/1999/xhtml"><SPAN xmlns="http://www.w3.org/1999/xhtml">1/xgd_android_test$ ls 
AndroidManifest.xml  apktool.yml  lib  res  smali 
</SPAN></SPAN> 

1/xgd_android_test$ ls
AndroidManifest.xml  apktool.yml  lib  res  smali

这里有apk的源码(smali)、图片、xml配置和语言配置等等信息。


使用dex2jar和JD-JUI这两个工具查看java源码
下载dex2jar、JD-JUI 两个包,解压。
把apk的后缀名改成zip,并解压得到classes.dex文件,在dex2jar目录中输入如下命令得到.jar文件:
[plain]
<SPAN xmlns="http://www.w3.org/1999/xhtml">$ ./dex2jar.sh classes.dex  
this cmd is deprecated, use the d2j-dex2jar if possible 
dex2jar version: translator-0.0.9.9 
dex2jar classes.dex -> classes_dex2jar.jar 
Done. 
</SPAN> 

$ ./dex2jar.sh classes.dex
this cmd is deprecated, use the d2j-dex2jar if possible
dex2jar version: translator-0.0.9.9
dex2jar classes.dex -> classes_dex2jar.jar
Done.

再使用JD-JUI打开该文件就能查看源代码:

\
与源代码对比:
[java]
<SPAN xmlns="http://www.w3.org/1999/xhtml">package xgd.android; 
 
import android.app.Activity; 
import android.os.Bundle; 
 
public class ICCardActivity extends Activity{ 
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        // TODO Auto-generated method stub  
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.iccard); 
    } 
 
 

</SPAN> 

package xgd.android;

import android.app.Activity;
import android.os.Bundle;

public class ICCardActivity extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.iccard);
    }


}


 

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,