如何将Android DEX(虚拟机字节码)文件反编译成相应的Java源代码?
当前回答
很容易
获取这些工具:
Dex2jar将dex文件转换为jar文件 以查看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.apk
d2j-dex2jar.sh -f -o output_jar.jar dex_to_decompile.dex
注1:在Windows机器中,所有的.sh脚本都被.bat脚本取代
注2:在linux/mac上不要忘记sh或bash。完整的命令应该是:
sh d2j-dex2jar.sh -f -o output_jar.jar apk_to_decompile.apk
注意3:另外,请记住向dex2jar-X添加执行权限。例如sudo chmod -R + X dex2jar-2.0
dex2jar文档
步骤2:
在JD-GUI中打开罐子
其他回答
自从这些答案被发布以来,很多事情都发生了变化。现在有很多简单的GUI工具,比如:
APK Easy Tool for Windows (GUI tool, friendly)
Bytecode Viewer - APK/Java Reverse Engineering Suite
URET Android Reverser Toolkit
找到他们最好的地方是在XDA开发者论坛上。
下载APK文件后,您需要执行以下步骤以获得可编辑的java代码/文档。
Convert your apk file to zip (while start your download don't go with "save" option , just go with "save as" and mention your extension as .zip) by doing like this you may avoid APKTOOL... Extract the zip file , there you can find somefilename.dex. so now we need to convert dex -> .class To do that, you need "dex2jar"(you can download it from http://code.google.com/p/dex2jar/ , after extracted, in command prompt you have to mention like, [D:\dex2jar-0.09>dex2jar somefilename.dex] (Keep in mind that your somefilename.dex must be inside the same folder where you have keep your dex2jar.) Download jad from http://www.viralpatel.net/blogs/download/jad/jad.zip and extract it. Once extracted you can see two files like "jad.exe" and "Readme.txt" (sometimes "jad.txt" may there instead of "jad.exe", so just rename its extension as.exe to run) Finally, in command prompt you have to mention like [D:\jad>jad -sjava yourfilename.class] it will parse your class file into editable java document.
您可以尝试JADX (https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler),这是一个完美的DEX反编译工具。
是的,它也可以在线(my:0))新网站:http://www.javadecompilers.com/apk/
在使用dex2jar/apktool时,有时会出现坏代码,最明显的是在循环中。为了避免这种情况,可以使用jadx,它可以将dalvik字节码反编译成java源代码,而不需要像dex2jar那样先创建.jar/.class文件(我认为apktool使用dex2jar)。它也是开源的,正在积极开发中。它甚至有一个GUI,专为GUI爱好者设计。试一试!
我用过
Dex2jar + jd-gui javadecompilers.com enjarify Apktool
但没有比谷歌自己的工具更好的了
1)Android Studio 2.x: 构建>分析apk
2)Android Studio 3.0: 配置文件或调试APK
推荐文章
- 警告:API ' variable . getjavacompile()'已过时,已被' variable . getjavacompileprovider()'取代
- 安装APK时出现错误
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 碎片中的onCreateOptionsMenu
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- TextView粗体通过XML文件?
- 如何使线性布局的孩子之间的空间?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数
- c#和Java中的泛型有什么不同?和模板在c++ ?