简体   繁体   English

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

[英]Is it possible to decompile an Android .apk file?

Are the users able to convert the apk file of my application back to the actual code?用户能否将我的应用程序的 apk 文件转换回实际代码? If they do - is there any way to prevent this?如果他们这样做 - 有什么办法可以防止这种情况发生吗?

First, an apk file is just a modified jar file.首先, apk 文件只是一个修改后的 jar 文件。 So the real question is can they decompile the dex files inside.所以真正的问题是他们能否反编译里面的dex文件。 The answer is sort of.答案是有点。 There are already disassemblers, such as dedexer and smali .已经有反汇编程序,例如dedexersmali You can expect these to only get better, and theoretically it should eventually be possible to decompile to actual Java source (at least sometimes).您可以期望这些只会变得更好,理论上最终应该可以反编译为实际的 Java 源代码(至少有时)。 See the previous question decompiling DEX into Java sourcecode .请参阅上一个将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.不要在不可靠的技术措施上浪费时间。

Decompilation of APK file is possible. 可以反编译 APK 文件。 But it might be difficult to understand the code if it is obfuscated. 但如果代码被混淆,可能很难理解。

Use Aapt (part of the Android SDK) or AXMLParser (from AndroGuard) to analyse and view info of an APK File使用Aapt (Android SDK 的一部分)或AXMLParser (来自 AndroGuard)来分析和查看 APK 文件的信息

  • Retrieves the content of the AndroidManifest.xml file检索 AndroidManifest.xml 文件的内容

  • Shows various information (eg permissions, activities, services, broadcast receivers, ...)显示各种信息(例如权限、活动、服务、广播接收器等)

  • Command:命令:

    Aapt适应

     aapt dump badging sampleApp.apk aapt dump permissions sampleApp.apk aapt dump xmltree sampleApp.apk

    AXMLParser AXML解析器

     apkinfo sampleApp.apk

Use ApkTool or NinjaDroid to disassemble and view the resources of an APK File使用ApkToolNinjaDroid反汇编和查看 APK 文件的资源

  • Disassembles the bytecode to smali/assembly将字节码反汇编为 smali/assembly

  • Extracts the AndroidManifest.xml, the CERT.RSA file and everything in res folder (layout xml files, images, htmls used on webview etc..)提取 AndroidManifest.xml、CERT.RSA 文件和 res 文件夹中的所有内容(布局 xml 文件、图像、webview 上使用的 html 等。)

  • Command:命令:

    ApkTool应用工具

    apktool.bat d sampleApp.apk java -jar apktool.jar -q decode -f sampleApp.apk -o myOutputDir

    NinjaDroid忍者机器人

    ninjadroid MyApk.apk --all --extract myOutputDir/
  • NOTE: You can achieve something similar by using zip utility like 7-zip.注意:您可以使用 7-zip 之类的 zip 实用程序来实现类似的功能。 But, these tools also extract the .smali files of all .class files.但是,这些工具也会提取所有 .class 文件的 .smali 文件。

Use dex2jar to decompile the DEX files of an APK File into Java code使用dex2jar将一个APK文件的DEX文件反编译成Java代码

  • Generates the .jar file from a .apk file (note that the Java code of Android apps is usually obfuscated)从 .apk 文件生成 .jar 文件(注意 Android 应用程序的 Java 代码通常被混淆)

  • Needs JD-GUI to view the source code from the output .jar file需要 JD-GUI 从输出的 .jar 文件中查看源代码

  • Command:命令:

     dex2jar sampleApp.apk d2j-dex2jar.sh -f sampleApp.apk -o myOutputDir/sampleApp.jar

Use JD-GUI to view the .jar file使用 JD-GUI 查看 .jar 文件

  • Decompiles the .class files (obfuscated in a case of Android apps, but not in a case of other .jar files) and shows the corresponding Java code反编译 .class 文件(在 Android 应用程序的情况下会混淆,但在其他 .jar 文件的情况下不会)并显示相应的 Java 代码

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 个选项供您选择:

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.解压缩它,然后在 lib 文件夹中运行 jadx-gui-0.6.1.jar 文件,现在浏览您的 apk 文件。 It's done.完成。 Automatically apk will decompile and save it by pressing save button. apk 会自动反编译并按保存按钮保存。 Hope it will work for you.希望它对你有用。 Thanks谢谢

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分析:你的apk
  • decode/hack your apk解码/破解你的apk
    • using FDex2 to dump out dex file使用FDex2转储dex文件
      • then using dex2jar to convert to jar然后使用dex2jar转换为jar
        • then using jadx to conver to java source code然后使用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使用 Android ProGuard
  • high level: use android harden scenario高层次:使用android强化场景

More details can refer my Chinese tutorial: 安卓应用的安全和破解更多详情可以参考我的中文教程: 安卓应用的安全和破解

Sometimes you get broken code, when using dex2jar / apktool , most notably in loops.有时您会在使用dex2jar / apktool时遇到损坏的代码,尤其是在循环中。 To avoid this, use jadx , which decompiles dalvik bytecode into java source code, without creating a .jar / .class file first as dex2jar does (apktool uses dex2jar I think).为避免这种情况,请使用jadx ,它将 dalvik 字节码反编译为 java 源代码,而无需像dex2jar那样首先创建.jar / .class文件(我认为 apktool 使用 dex2jar)。 It is also open-source and in active development.它也是开源的并且正在积极开发中。 It even has a GUI, for GUI-fanatics.对于 GUI 狂热者来说,它甚至还有一个 GUI。 Try it!尝试一下!

Yes, there are tons of software available to decompile a .apk file.是的,有大量软件可用于反编译 .apk 文件。

Recently, I had compiled an ultimate list of 47 best APK decompilers on my website.最近,我在我的网站上编制了 47 个最佳 APK 反编译器的最终列表。 I arranged them into 4 different sections.我把它们分成 4 个不同的部分。

  1. Open Source APK Decompilers开源 APK 反编译器
  2. Online APK Decompilers在线 APK 反编译器
  3. APK Decompiler for Windows, Mac or Linux适用于 Windows、Mac 或 Linux 的 APK 反编译器
  4. APK Decompiler Apps APK 反编译器应用

I hope this collection will be helpful to you.我希望这个合集对你有帮助。

Link: https://www.edopedia.com/blog/best-apk-decompilers/链接: https : //www.edopedia.com/blog/best-apk-decompilers/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM