将 DEX 反编译为 Java 源代码 [英] decompiling DEX into Java sourcecode

查看:68
本文介绍了将 DEX 反编译为 Java 源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Android DEX(VM字节码)文件反编译成对应的Java源代码?

解决方案

很简单

获取这些工具:

  1. dex2jar 将 dex 文件转换为 jar 文件

  2. jd-gui 查看jar中的java文件

由于 dex2jar 做了一些优化,源代码可读性很强.

程序:

这里是如何反编译的过程:

第 1 步:

将 test_apk-debug.apk 中的 classes.dex 转换为 test_apk-debug_dex2jar.jar

d2j-dex2jar.sh -f -o output_jar.jar apk_to_decompile.apkd2j-dex2jar.sh -f -o output_jar.jar dex_to_decompile.dex

<块引用>

注1:在Windows机器中,所有.sh脚本都被.bat脚本替换

<块引用>

注意 2: 在 linux/mac 上不要忘记 shbash.完整的命令应该是:

sh d2j-dex2jar.sh -f -o output_jar.jar apk_to_decompile.apk

<块引用>

注意 3:另外,记得给 dex2jar-X.X 目录添加执行权限,例如sudo chmod -R +x dex2jar-2.0

dex2jar 文档

第 2 步:

在 JD-GUI 中打开 jar

How can one decompile Android DEX (VM bytecode) files into corresponding Java sourcecode?

解决方案

It's easy

Get these tools:

  1. dex2jar to translate dex files to jar files

  2. jd-gui to view the java files in the jar

The source code is quite readable as dex2jar makes some optimizations.

Procedure:

And here's the procedure on how to decompile:

Step 1:

Convert classes.dex in test_apk-debug.apk to test_apk-debug_dex2jar.jar

d2j-dex2jar.sh -f -o output_jar.jar apk_to_decompile.apk
d2j-dex2jar.sh -f -o output_jar.jar dex_to_decompile.dex

Note 1: In the Windows machines all the .sh scripts are replaced by .bat scripts

Note 2: On linux/mac don't forget about sh or bash. The full command should be:

sh d2j-dex2jar.sh -f -o output_jar.jar apk_to_decompile.apk 

Note 3: Also, remember to add execute permission to dex2jar-X.X directory e.g. sudo chmod -R +x dex2jar-2.0

dex2jar documentation

Step 2:

Open the jar in JD-GUI

这篇关于将 DEX 反编译为 Java 源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆