反编译 APK 上的 .smali 文件

发布于 2024-10-31 10:17:39 字数 163 浏览 3 评论 0原文

我下载了 APK 管理器,它可以让我解压 APK 文件。

但它只是解压它,并没有将 .smali 文件反编译为 .java。

是否可以将.smali反编译为.java?

I downloaded APK Manager that lets me unpack APK files.

But it only unpacks it and doesn't decompile the .smali file to .java.

Is it possible to decompile the .smali to .java?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

つ低調成傷 2024-11-07 10:17:39

不,APK 管理器会将 .dex 文件反编译为 .smali,并将二进制 .xml 反编译为人类可读的 xml。

顺序(基于APK Manager 4.9)是22选择包,然后9反编译它。如果您按 1 而不是 9,那么您将直接解压缩它(仅当您想要交换 .png 图像时有用)。

没有可用的工具可以反编译回 .java 文件,而且很可能没有任何工具。还有一种替代方案,即使用 dex2jar 将 dex 文件转换为 .class 文件,然后使用 jar 反编译器(例如免费的 jd -gui) 到纯文本 java.lang.虽然这个过程远非最佳,并且它不会生成工作代码,但它足够好,能够阅读它。

dex2jar: https://github.com/pxb1988/dex2jar

jd-gui: http://jd.benow.ca/

编辑: 我知道这里有一个问题非常相似的答案... 将 DEX 反编译为 Java 源代码

No, APK Manager decompiles the .dex file into .smali and binary .xml to human readable xml.

The sequence (based on APK Manager 4.9) is 22 to select the package, and then 9 to decompile it. If you press 1 instead of 9, then you will just unpack it (useful only if you want to exchange .png images).

There is no tool available to decompile back to .java files and most probably it won't be any. There is an alternative, which is using dex2jar to transform the dex file in to a .class file, and then use a jar decompiler (such as the free jd-gui) to plain text java. The process is far from optimal, though, and it won't generate working code, but it's decent enough to be able to read it.

dex2jar: https://github.com/pxb1988/dex2jar

jd-gui: http://jd.benow.ca/

Edit: I knew there was somewhere here in SO a question with very similar answers... decompiling DEX into Java sourcecode

樱&纷飞 2024-11-07 10:17:39

有一个新的跨平台 (java) 和开源工具,使您能够做到这一点,只需查看 https://bytecodeviewer.com< /a>

在此处输入图像描述

=========

编辑:
截至 2017 年 4 月,谷歌开发了一个新的开源工具,它的作用正是我们一直在寻找的 => https://github.com/google/android-classyshark

There is a new cross plateform (java) and open source tool, that enable you to do that, just checkout https://bytecodeviewer.com

enter image description here

=========

EDIT:
As of April 2017, there is a new open source tool developed by google, that is meant to do just what we have been looking for => https://github.com/google/android-classyshark

浅黛梨妆こ 2024-11-07 10:17:39

dex2jar 有助于反编译您的 apk,但不是 100%。 .smali 文件会遇到一些问题。 Dex2jar 无法将其转换为 java。我知道一款应用程序可以反编译你的 apk 源文件,并且 .smali 文件没有任何问题。这是一个链接 http://www.hensence.com/en/smali2java/

dex2jar helps to decompile your apk but not 100%. You will have some problems with .smali files. Dex2jar cannot convert it to java. I know one application that can decompile your apk source files and no problems with .smali files. Here is a link http://www.hensence.com/en/smali2java/

千纸鹤带着心事 2024-11-07 10:17:39

我的推荐是美德十工作室。该工具是免费的,但他们建议捐款。它将所有必要的步骤(解压 APK、baksmaliing、反编译等)组合到一个易于使用的基于 UI 的导入过程中。在五分钟之内,您就应该拥有 Java 源代码,这比弄清楚上述工具之一的命令行选项所需的时间还要短。

将 smali 反编译为 Java 是一个不精确的过程,尤其是当 smali 工件经过混淆器时。您可以在网络上找到多个反编译器,但只有其中一些仍然得到维护。有些会给你比其他更好的反编译代码。将“更好”理解为比其他人“更容易理解”。不要指望逆向工程的 Java 代码能够立即编译。 Virteous Ten Studio 内置了多个免费的 Java 反编译器,因此您可以轻松尝试不同的反编译器(“生成 Java 源代码”步骤),看看哪一个可以为您提供最佳结果,从而节省您自己查找这些反编译器并计算结果的时间。了解如何使用它们。其中包括 CFR,它是少数免费且仍在维护的反编译器之一。

作为输出,您将收到一个文件夹结构,其中包含所有反编译的 Java 源代码。然后,您可以将其导入 IntelliJ IDEA 或 Eclipse 中以进行进一步编辑、分析(例如,转到定义、查找用法)等。

My recommendation is Virtuous Ten Studio. The tool is free but they suggest a donation. It combines all the necessary steps (unpacking APK, baksmaliing, decompiling, etc.) into one easy-to-use UI-based import process. Within five minutes you should have Java source code, less than it takes to figure out the command line options of one of the above mentioned tools.

Decompiling smali to Java is an inexact process, especially if the smali artifacts went through an obfuscator. You can find several decompilers on the web but only some of them are still maintained. Some will give you better decompiled code than others. Read "better" as in "more understandable" than others. Don't expect that the reverse-engineered Java code will compile out of the box. Virtuous Ten Studio comes with multiple free Java decompilers built-in so you can easily try out different decompilers (the "Generate Java source" step) to see which one gives you the best results, saving you the time to find those decompilers yourself and figure out how to use them. Amongst them is CFR, which is one of the few free and still maintained decompilers.

As output you receive, amongst other things, a folder structure that contains all the decompiled Java source code. You can then import this into IntelliJ IDEA or Eclipse for further editing, analysis (e.g. Go to definition, Find usages), etc.

感性不性感 2024-11-07 10:17:39

我赞同这一点。

Dex2jar 将生成一个 WORKING jar,您可以将其添加为项目源,其中包含从 apktool 获取的 xml。

然而,JDGUI 生成的 .java 文件通常会出现错误。

我猜这与代码混淆有关。

I second that.

Dex2jar will generate a WORKING jar, which you can add as your project source, with the xmls you got from apktool.

However, JDGUI generates .java files which have ,more often than not, errors.

It has got something to do with code obfuscation I guess.

对风讲故事 2024-11-07 10:17:39

要获得将 .apk 文件转换为 .java 文件的实用视图,只需查看 https:// /www.youtube.com/watch?v=-AX4NYE-9V8 视频 。你会受益匪浅,理解更清楚。如果您使用的是 Mac OS,它会清楚地演示您所需的步骤。

完成此任务的基本要求。
1. http://code.google.com/p/dex2jar/
2. http://jd.benow.ca/

For getting the practical view of converting .apk file into .java files just check out https://www.youtube.com/watch?v=-AX4NYE-9V8 video . you will get more benefited and understand clearly. It clearly demonstrates the steps you required if you are using mac OS.

The basic requirement for getting this done.
1. http://code.google.com/p/dex2jar/
2. http://jd.benow.ca/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文