是否可以反编译 Android .apk 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3122635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:48:48  来源:igfitidea点击:

Is it possible to decompile an Android .apk file?

androidobfuscationapkdecompilingdex

提问by aryaxt

Are the users able to convert the apk file of my application back to the actual code? If they do - is there any way to prevent this?

用户能否将我的应用程序的 apk 文件转换回实际代码?如果他们这样做 - 有什么办法可以防止这种情况发生吗?

采纳答案by Matthew Flaschen

First, an apk fileis just a modified jar file. So the real question is can they decompile the dex files inside. The answer is sort of. There are already disassemblers, such as dedexerand smali. You can expect these to only get better, and theoretically it should eventually be possible to decompile to actual Java source (at least sometimes). See the previous question decompiling DEX into Java sourcecode.

首先,apk 文件只是一个修改后的 jar 文件。所以真正的问题是他们能否反编译里面的dex文件。答案是有点。已经有反汇编程序,例如dedexersmali。您可以期望这些只会变得更好,理论上最终应该可以反编译为实际的 Java 源代码(至少有时)。请参阅上一个将DEX 反编译为 Java 源代码的问题

What you should remember is obfuscation never works. Choose a good license and do your best to enforce it through the law. Don't waste time with unreliable technical measures.

你应该记住的是混淆永远不会奏效。选择一个好的许可证,并尽最大努力通过法律强制执行。不要在不可靠的技术措施上浪费时间。

回答by gtiwari333

Decompilation of APK file is possible. But it might be difficult to understand the code if it is obfuscated.

可以反编译 APK 文件。但如果代码被混淆,可能很难理解。

ApkTool to view resources inside APK File

ApkTool 查看 APK 文件中的资源

  • Extracts AndroidManifest.xml and everything in res folder(layout xml files, images, htmls used on webview etc..)
  • command : apktool.bat d sampleApp.apk
  • NOTE:You can achieve this by using zip utility like 7-zip. But, It also extracts the .smali file of all .class files.
  • 提取 AndroidManifest.xml 和 res 文件夹中的所有内容(布局 xml 文件、图像、webview 上使用的 html 等。)
  • 命令 : apktool.bat d sampleApp.apk
  • 注意:您可以使用 7-zip 等 zip 实用程序来实现此目的。但是,它还提取了所有 .class 文件的 .smali 文件。

Using dex2jar

使用 dex2jar

  • Generates .jar file from .apk file, we need JD-GUI to view the source code from this .jar.
  • command : dex2jar sampleApp.apk
  • 从.apk 文件生成.jar 文件,我们需要JD-GUI 从这个.jar 文件中查看源代码。
  • 命令 : dex2jar sampleApp.apk

Decompiling .jar using JD-GUI

使用 JD-GUI 反编译 .jar

  • decompiles the .class files (obfuscated- in a case of the android app, but a readable original code is obtained in a case of other .jar file). i.e., we get .java back from the application.
  • 反编译 .class 文件(混淆 - 在 android 应用程序的情况下,但在其他 .jar 文件的情况下获得可读的原始代码)。即,我们从应用程序中取回 .java。

回答by Andrew Rukin

I may also add, that nowadays it is possible to decompile Android application online, no software needed!

我还要补充一点,现在可以在线反编译Android应用程序,不需要任何软件!

Here are 2 options for you:

这里有 2 个选项供您选择:

回答by akhilesh Jha

Download this jadx tool https://sourceforge.net/projects/jadx/files/

下载这个 jadx 工具https://sourceforge.net/projects/jadx/files/

Unzip it and than in lib folder run jadx-gui-0.6.1.jar file now browse your apk file. It's done. Automatically apk will decompile and save it by pressing save button. Hope it will work for you. Thanks

解压缩它,然后在 lib 文件夹中运行 jadx-gui-0.6.1.jar 文件,现在浏览您的 apk 文件。完成。apk 会自动反编译并按保存按钮保存。希望它对你有用。谢谢

回答by crifan

Are the users able to convert the apk file of my application back to the actual code?

用户能否将我的应用程序的 apk 文件转换回实际代码?

yes.

是的。

People can use various tools to:

人们可以使用各种工具来:

  • analysis: your apk
  • decode/hack your apk
    • using FDex2to dump out dexfile
      • then using dex2jarto convert to jar
        • then using jadxto conver to javasource code
  • 分析:你的apk
  • 解码/破解你的apk
    • FDex2倾倒了dex文件
      • 然后使用dex2jar转换为jar
        • 然后jadx用于转换为java源代码

If they do - is there any way to prevent this?

如果他们这样做 - 有什么办法可以防止这种情况发生吗?

yes. Several (can combined) ways to prevent (certain degree) this:

是的。几种(可以组合)防止(一定程度)这种情况的方法:

  • low level: code obfuscation
    • using Android ProGuard
  • high level: use android harden scenario
  • 低级:代码混淆
    • 使用安卓 ProGuard
  • 高层次:使用android强化场景

More details can refer my Chinesetutorial: 安卓应用的安全和破解

更多详情可以参考我的中文教程:安卓应用的安全和破解

回答by polym

Sometimes you get broken code, when using dex2jar/apktool, most notably in loops. To avoid this, use jadx, which decompiles dalvik bytecode into java source code, without creating a .jar/.classfile first as dex2jardoes (apktool uses dex2jar I think). It is also open-source and in active development. It even has a GUI, for GUI-fanatics. Try it!

有时您会在使用dex2jar/时遇到损坏的代码,apktool尤其是在循环中。为避免这种情况,请使用jadx,它将 dalvik 字节码反编译为 java 源代码,而无需像这样先创建.jar/.class文件dex2jar(我认为 apktool 使用 dex2jar)。它也是开源的并且正在积极开发中。对于 GUI 狂热者来说,它甚至还有一个 GUI。尝试一下!